From: Rupert Germann Date: Mon, 24 Aug 2009 09:32:16 +0000 (+0000) Subject: Fixed bug #11764: Performance improvement: speed up list module by improving internal... X-Git-Tag: TYPO3_4-3-0beta1~250 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/08eb445735251b910b8d5aebc41ce060f3762707 Fixed bug #11764: Performance improvement: speed up list module by improving internal handling of localisations git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5814 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index ea9056f3c389..05c347af554e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-24 Rupert Germann + + * Fixed bug #11764: Performance improvement: speed up list module by improving internal handling of localisations + 2009-08-23 Rupert Germann * Fixed bug #11769: publish function in adminPanel is broken diff --git a/t3lib/class.t3lib_recordlist.php b/t3lib/class.t3lib_recordlist.php index 2d6a5c4324d1..d505b5505db8 100644 --- a/t3lib/class.t3lib_recordlist.php +++ b/t3lib/class.t3lib_recordlist.php @@ -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); } /** diff --git a/t3lib/class.t3lib_transl8tools.php b/t3lib/class.t3lib_transl8tools.php index 1eb1b2820b11..35a74403bfab 100644 --- a/t3lib/class.t3lib_transl8tools.php +++ b/t3lib/class.t3lib_transl8tools.php @@ -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) ); diff --git a/typo3/class.db_list.inc b/typo3/class.db_list.inc index 2188e7fbe573..fcfdcda931f5 100644 --- a/typo3/class.db_list.inc +++ b/typo3/class.db_list.inc @@ -225,6 +225,7 @@ class recordList extends t3lib_recordList { // Initialize languages: if ($this->localizationView) { + $this->translateTools = t3lib_div::makeInstance('t3lib_transl8tools'); $this->initializeLanguages(); } } diff --git a/typo3/class.db_list_extra.inc b/typo3/class.db_list_extra.inc index 0f20e1d30dd7..b911136f5a7f 100644 --- a/typo3/class.db_list_extra.inc +++ b/typo3/class.db_list_extra.inc @@ -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']]);