Fixed bug #11764: Performance improvement: speed up list module by improving internal...
authorRupert Germann <rupi@gmx.li>
Mon, 24 Aug 2009 09:32:16 +0000 (09:32 +0000)
committerRupert Germann <rupi@gmx.li>
Mon, 24 Aug 2009 09:32:16 +0000 (09:32 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5814 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_recordlist.php
t3lib/class.t3lib_transl8tools.php
typo3/class.db_list.inc
typo3/class.db_list_extra.inc

index ea9056f..05c347a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-24  Rupert Germann  <rupi@gmx.li>
+
+       * Fixed bug #11764: Performance improvement: speed up list module by improving internal handling of localisations
+
 2009-08-23  Rupert Germann  <rupi@gmx.li>
 
        * Fixed bug #11769: publish function in adminPanel is broken
index 2d6a5c4..d505b55 100644 (file)
@@ -107,7 +107,7 @@ class t3lib_recordList {
 
        var $pageOverlays = array();                    // Contains page translation languages
        var $languageIconTitles = array();              // Contains sys language icons and titles
-
+       var $translateTools;                                    // translateTools object
 
        /**
         * constructor for t3lib_recordList
@@ -379,8 +379,7 @@ class t3lib_recordList {
                        'sys_language_uid'
                );
 
-               $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
-               $this->languageIconTitles = $t8Tools->getSystemLanguages($this->id, $this->backPath);
+               $this->languageIconTitles = $this->translateTools->getSystemLanguages($this->id, $this->backPath);
        }
 
        /**
index 1eb1b28..35a7440 100644 (file)
@@ -129,15 +129,19 @@ class t3lib_transl8tools  {
         * @param       string          Table name
         * @param       integer         Record uid
         * @param       integer         Language uid. If zero, then all languages are selected.
+        * @param       array           The record to be translated
         * @return      array           Array with information. Errors will return string with message.
         */
-       function translationInfo($table,$uid,$sys_language_uid=0)       {
+       function translationInfo($table, $uid, $sys_language_uid = 0, $row = NULL) {
                global $TCA;
 
                if ($TCA[$table] && $uid)       {
                        t3lib_div::loadTCA($table);
 
-                       $row = t3lib_BEfunc::getRecordWSOL($table,$uid);
+                       if ($row === NULL) {
+                               $row = t3lib_BEfunc::getRecordWSOL($table, $uid);
+                       }
+
                        if (is_array($row))     {
                                $trTable = $this->getTranslationTable($table);
                                if ($trTable)   {
@@ -146,11 +150,11 @@ class t3lib_transl8tools  {
 
                                                                // Look for translations of this record, index by language field value:
                                                        $translationsTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                                               'uid,'.$TCA[$trTable]['ctrl']['languageField'],
+                                                               $this->selFieldList,
                                                                $trTable,
-                                                               'pid='.intval($table==='pages' ? $row['uid'] : $row['pid']).    // Making exception for pages of course where the translations will always be ON the page, not on the level above...
+                                                               $TCA[$trTable]['ctrl']['transOrigPointerField'] . '=' . intval($uid) .
+                                                                       ' AND pid=' . intval($table === 'pages' ? $row['uid'] : $row['pid']).   // Making exception for pages of course where the translations will always be ON the page, not on the level above...
                                                                        ' AND '.$TCA[$trTable]['ctrl']['languageField'].(!$sys_language_uid ? '>0' : '='.intval($sys_language_uid)).
-                                                                       ' AND '.$TCA[$trTable]['ctrl']['transOrigPointerField'].'='.intval($uid).
                                                                        t3lib_BEfunc::deleteClause($trTable).
                                                                        t3lib_BEfunc::versioningPlaceholderClause($trTable)
                                                        );
index 2188e7f..fcfdcda 100644 (file)
@@ -225,6 +225,7 @@ class recordList extends t3lib_recordList {
 
                        // Initialize languages:
                if ($this->localizationView)    {
+                       $this->translateTools = t3lib_div::makeInstance('t3lib_transl8tools');
                        $this->initializeLanguages();
                }
        }
index 0f20e1d..b911136 100644 (file)
@@ -120,6 +120,7 @@ class localRecordList extends recordList {
        var $duplicateStack=array();                    // Used to track which elements has duplicates and how many
 
        var $references;                                                // References of the current record
+       var $translations;                                              // Translations of the current record
 
        public function __construct() {
                parent::__construct();
@@ -376,6 +377,7 @@ class localRecordList extends recordList {
                $selectFields = array_unique($selectFields);            // Unique list!
                $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
                $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
+               $this->translateTools->selFieldList = $selFieldList;
 
                /**
                 * @hook                        DB-List getTable
@@ -540,28 +542,16 @@ class localRecordList extends recordList {
                                        // Render item row if counter < limit
                                        if ($cc < $this->iLimit) {
                                                $cc++;
+                                               $this->translations = FALSE;
                                                $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
 
                                                        // If localization view is enabled it means that the selected records are either default or All language and here we will not select translations which point to the main record:
                                                if ($this->localizationView && $l10nEnabled)    {
-
-                                                               // Look for translations of this record:
-                                                       $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                                               $selFieldList,
-                                                               $table,
-                                                               'pid='.$row['pid'].
-                                                                       ' AND '.$TCA[$table]['ctrl']['languageField'].'>0'.
-                                                                       ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
-                                                                       t3lib_BEfunc::deleteClause($table).
-                                                                       t3lib_BEfunc::versioningPlaceholderClause($table)
-                                                       );
-
                                                                // For each available translation, render the record:
-                                                       if (is_array($translations)) {
-                                                               foreach($translations as $lRow) {
+                                                       if (is_array($this->translations)) {
+                                                               foreach ($this->translations as $lRow) {
                                                                                // In offline workspace, look for alternative record:
                                                                        t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace);
-
                                                                        if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))  {
                                                                                $currentIdList[] = $lRow['uid'];
                                                                                $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
@@ -1439,8 +1429,8 @@ class localRecordList extends recordList {
                        1 => '',
                );
 
-               $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
-               $translations = $t8Tools->translationInfo($table,$row['uid']);
+               $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row);
+               $this->translations = $translations['translations'];
 
                        // Language title and icon:
                $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);