r91455 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91454‎ | r91455 | r91456 >
Date:13:52, 5 July 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
manually build SQL query string to maintain MW 1.16 compatibility + comments on how to change it when support for MW 1.16 is dropped
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -952,10 +952,19 @@
953953 $this->updateRedirects( $oldtitle->getDBkey(), $oldtitle->getNamespace(), $newtitle->getDBkey(), $newtitle->getNamespace() );
954954
955955 // Associate internal objects (subobjects) with the new title:
956 - $db->update( 'smw_ids',
957 - array( 'smw_title' => $newtitle->getDBkey(), 'smw_namespace' => $newtitle->getNamespace(), 'smw_iw' => '' ),
958 - array( 'smw_title' => $oldtitle->getDBkey(), 'smw_namespace' => $oldtitle->getNamespace(), 'smw_iw' => '', 'smw_subobject!' => array( '' ) ), // array() needed for ! to work
959 - __METHOD__ );
 956+ $table = $db->tableName( 'smw_ids' );
 957+ $values = array( 'smw_title' => $newtitle->getDBkey(), 'smw_namespace' => $newtitle->getNamespace(), 'smw_iw' => '' );
 958+ $sql = "UPDATE $table SET " . $db->makeList( $values, LIST_SET ) .
 959+ ' WHERE smw_title = ' . $db->addQuotes( $oldtitle->getDBkey() ) . ' AND ' .
 960+ 'smw_namespace = ' . $db->addQuotes( $oldtitle->getNamespace() ) . ' AND ' .
 961+ 'smw_iw = ' . $db->addQuotes( '' ) . ' AND ' .
 962+ 'smw_subobject != ' . $db->addQuotes( '' );
 963+ $db->query( $sql, __METHOD__ );
 964+// The below code can be used instead when moving to MW 1.17 (support for '!' in Database::makeList()):
 965+// $db->update( 'smw_ids',
 966+// array( 'smw_title' => $newtitle->getDBkey(), 'smw_namespace' => $newtitle->getNamespace(), 'smw_iw' => '' ),
 967+// array( 'smw_title' => $oldtitle->getDBkey(), 'smw_namespace' => $oldtitle->getNamespace(), 'smw_iw' => '', 'smw_subobject!' => array( '' ) ), // array() needed for ! to work
 968+// __METHOD__ );
960969 }
961970
962971 wfProfileOut( "SMWSQLStore2::changeTitle (SMW)" );
@@ -2249,10 +2258,15 @@
22502259
22512260 // also find subobjects used by this ID ...
22522261 $res = $db->select( 'smw_ids', 'smw_id',
2253 - array( 'smw_title' => $subject->getDBkey(),
2254 - 'smw_namespace' => $subject->getNamespace(),
2255 - 'smw_iw' => $subject->getInterwiki(),
2256 - 'smw_subobject!' => array( '' ) ), // ! (NOT) in MW only supported for array values!
 2262+ 'smw_title = ' . $db->addQuotes( $subject->getDBkey() ) . ' AND ' .
 2263+ 'smw_namespace = ' . $db->addQuotes( $subject->getNamespace() ) . ' AND ' .
 2264+ 'smw_iw = ' . $db->addQuotes( $subject->getInterwiki() ) . ' AND ' .
 2265+ 'smw_subobject != ' . $db->addQuotes( '' ),
 2266+// The below code can be used instead when moving to MW 1.17 (support for '!' in Database::makeList()):
 2267+// array( 'smw_title' => $subject->getDBkey(),
 2268+// 'smw_namespace' => $subject->getNamespace(),
 2269+// 'smw_iw' => $subject->getInterwiki(),
 2270+// 'smw_subobject!' => array( '' ) ), // ! (NOT) in MW only supported for array values!
22572271 __METHOD__ );
22582272 $subobjects = array();
22592273