r23231 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23230‎ | r23231 | r23232 >
Date:16:57, 22 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Bug in "page" table name (written literal in some places, breaks with DB prefixes)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -548,7 +548,8 @@
549549 $this->m_sortkey = $query->sortkey;
550550 $this->m_sortfield = false;
551551
552 - $from = $db->tableName('page');
 552+ $pagetable = $db->tableName('page');
 553+ $from = $pagetable;
553554 $where = '';
554555 $curtables = array('PAGE' => $from);
555556 $this->createSQLQuery($query->getDescription(), $from, $where, $db, $curtables);
@@ -562,7 +563,7 @@
563564 if ( $smwgIQSortingEnabled ) {
564565 $order = $query->ascending ? 'ASC' : 'DESC';
565566 if ( ($this->m_sortfield == false) && ($this->m_sortkey == false) ) {
566 - $sql_options['ORDER BY'] = "page.page_title $order "; // default
 567+ $sql_options['ORDER BY'] = "$pagetable.page_title $order "; // default
567568 } elseif ($this->m_sortfield != false) {
568569 $sql_options['ORDER BY'] = $this->m_sortfield . " $order ";
569570 } // else: sortkey given but not found: do not sort
@@ -571,7 +572,7 @@
572573 // Execute query and format result as array
573574 if ($query->querymode == SMWQuery::MODE_COUNT) {
574575 $res = $db->select($from,
575 - 'COUNT(DISTINCT page.page_id) AS count',
 576+ "COUNT(DISTINCT $pagetable.page_id) AS count",
576577 $where,
577578 'SMW::getQueryResult',
578579 $sql_options );
@@ -581,7 +582,7 @@
582583 list( $startOpts, $useIndex, $tailOpts ) = $db->makeSelectOptions( $sql_options );
583584 $result = '<div style="border: 1px dotted black; background: #A1FB00; padding: 20px; ">' .
584585 '<b>SQL-Query</b><br />' .
585 - 'SELECT DISTINCT page.page_title as title, page.page_namespace as namespace' .
 586+ "SELECT DISTINCT $pagetable.page_title as title, $pagetable.page_namespace as namespace" .
586587 ' FROM ' . $from . ' WHERE ' . $where . $tailOpts . '<br />' .
587588 '<b>SQL-Query options</b><br />';
588589 foreach ($sql_options as $key => $value) {
@@ -592,7 +593,7 @@
593594 } // else: continue
594595
595596 $res = $db->select($from,
596 - 'DISTINCT page.page_title as title, page.page_namespace as namespace',
 597+ "DISTINCT $pagetable.page_title as title, $pagetable.page_namespace as namespace",
597598 $where,
598599 'SMW::getQueryResult',
599600 $sql_options );

Status & tagging log