From 2584c980b14703e22019fa1afe7e8f62c7d6b49b Mon Sep 17 00:00:00 2001 From: Steffen Gebert Date: Sun, 31 Oct 2010 19:20:16 +0000 Subject: [PATCH] Fixed bug #15583: Core calls deprecated function tslib_pibase::pi_list_query() git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9236 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++ typo3/sysext/cms/tslib/class.tslib_pibase.php | 69 ++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1c16a54851..66b6eb040c4 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-10-31 Steffen Gebert + + * Fixed bug #15583: Core calls deprecated function tslib_pibase::pi_list_query() + 2010-10-31 Susanne Moog * Added feature 15645: Make checkboxes at the bottom of modules configurable (Thanks to Jörg Klein) diff --git a/typo3/sysext/cms/tslib/class.tslib_pibase.php b/typo3/sysext/cms/tslib/class.tslib_pibase.php index 7f2e9849b79..9c12fa320bb 100644 --- a/typo3/sysext/cms/tslib/class.tslib_pibase.php +++ b/typo3/sysext/cms/tslib/class.tslib_pibase.php @@ -1053,6 +1053,7 @@ class tslib_pibase { * @todo Deprecated but still used in the Core! */ function pi_list_query($table,$count=0,$addWhere='',$mm_cat='',$groupBy='',$orderBy='',$query='',$returnQueryArray=FALSE) { + t3lib_div::logDeprecatedFunction(); // Begin Query: if (!$query) { @@ -1144,9 +1145,73 @@ class tslib_pibase { * @param string If set, this is taken as the first part of the query instead of what is created internally. Basically this should be a query starting with "FROM [table] WHERE ... AND ...". The $addWhere clauses and all the other stuff is still added. Only the tables and PID selecting clauses are bypassed. May be deprecated in the future! * @return pointer SQL result pointer */ - function pi_exec_query($table,$count=0,$addWhere='',$mm_cat='',$groupBy='',$orderBy='',$query='') { - $queryParts = $this->pi_list_query($table,$count,$addWhere,$mm_cat,$groupBy,$orderBy,$query, TRUE); + function pi_exec_query($table, $count=0 ,$addWhere='' ,$mm_cat='' ,$groupBy='' ,$orderBy='', $query='') { + // Begin Query: + if (!$query) { + // Fetches the list of PIDs to select from. + // TypoScript property .pidList is a comma list of pids. If blank, current page id is used. + // TypoScript property .recursive is a int+ which determines how many levels down from the pids in the pid-list subpages should be included in the select. + $pidList = $this->pi_getPidList($this->conf['pidList'], $this->conf['recursive']); + if (is_array($mm_cat)) { + $query = 'FROM ' . $table . ',' . $mm_cat['table'] . ',' . $mm_cat['mmtable'] . LF . + ' WHERE ' . $table . '.uid=' . $mm_cat['mmtable'] . '.uid_local AND ' . $mm_cat['table'] . '.uid=' . $mm_cat['mmtable'] . '.uid_foreign ' . LF . + (strcmp($mm_cat['catUidList'],'') ? ' AND ' . $mm_cat['table'] . '.uid IN (' . $mm_cat['catUidList'] . ')' : '') . LF . + ' AND ' . $table . '.pid IN (' . $pidList . ')' . LF . + $this->cObj->enableFields($table) . LF; // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT selected, if they should not! Almost ALWAYS add this to your queries! + } else { + $query='FROM ' . $table . ' WHERE pid IN (' . $pidList . ')' . LF . + $this->cObj->enableFields($table) . LF; // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT selected, if they should not! Almost ALWAYS add this to your queries! + } + } + + // Split the "FROM ... WHERE" string so we get the WHERE part and TABLE names separated...: + list($TABLENAMES, $WHERE) = preg_split('/WHERE/i', trim($query), 2); + $TABLENAMES = trim(substr(trim($TABLENAMES), 5)); + $WHERE = trim($WHERE); + + // Add '$addWhere' + if ($addWhere) { + $WHERE .= ' ' . $addWhere . LF; + } + + // Search word: + if ($this->piVars['sword'] && $this->internal['searchFieldList']) { + $WHERE .= $this->cObj->searchWhere($this->piVars['sword'], $this->internal['searchFieldList'], $table) . LF; + } + + if ($count) { + $queryParts = array( + 'SELECT' => 'count(*)', + 'FROM' => $TABLENAMES, + 'WHERE' => $WHERE, + 'GROUPBY' => '', + 'ORDERBY' => '', + 'LIMIT' => '' + ); + } else { + // Order by data: + if (!$orderBy && $this->internal['orderBy']) { + if (t3lib_div::inList($this->internal['orderByList'], $this->internal['orderBy'])) { + $orderBy = 'ORDER BY ' . $table . '.' . $this->internal['orderBy'] . ($this->internal['descFlag'] ? ' DESC' : ''); + } + } + + // Limit data: + $pointer = $this->piVars['pointer']; + $pointer = intval($pointer); + $results_at_a_time = t3lib_div::intInRange($this->internal['results_at_a_time'], 1, 1000); + $LIMIT = ($pointer * $results_at_a_time) . ',' . $results_at_a_time; + // Add 'SELECT' + $queryParts = array( + 'SELECT' => $this->pi_prependFieldsWithTable($table, $this->pi_listFields), + 'FROM' => $TABLENAMES, + 'WHERE' => $WHERE, + 'GROUPBY' => $GLOBALS['TYPO3_DB']->stripGroupBy($groupBy), + 'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), + 'LIMIT' => $LIMIT + ); + } return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); } -- 2.20.1