r91539 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91538‎ | r91539 | r91540 >
Date:09:06, 6 July 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
take advantage of cache when making IDs for objects without a sortkey; safes a few reads for properties when storing data
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -2000,7 +2000,11 @@
20012001 wfProfileIn( 'SMWSQLStore2::makeSMWPageID (SMW)' );
20022002
20032003 $oldsort = '';
2004 - $id = $this->getSMWPageIDandSort( $title, $namespace, $iw, $subobjectName, $oldsort, $canonical );
 2004+ if ( $sortkey != '' ) { // get the old sortkey (requires DB access):
 2005+ $id = $this->getSMWPageIDandSort( $title, $namespace, $iw, $subobjectName, $oldsort, $canonical );
 2006+ } else { // only get the id, can use caches:
 2007+ $id = $this->getSMWPageID( $title, $namespace, $iw, $subobjectName, $canonical );
 2008+ }
20052009
20062010 if ( $id == 0 ) {
20072011 $db = wfGetDB( DB_MASTER );
@@ -2035,7 +2039,7 @@
20362040 * Properties have a mechanisms for being predefined (i.e. in PHP instead
20372041 * of in wiki). Special "interwiki" prefixes separate the ids of such
20382042 * predefined properties from the ids for the current pages (which may,
2039 - * e.g. be moved, while the predefined object is not movable).
 2043+ * e.g., be moved, while the predefined object is not movable).
20402044 */
20412045 protected function getPropertyInterwiki( SMWDIProperty $property ) {
20422046 if ( $property->isUserDefined() ) {
@@ -2065,7 +2069,8 @@
20662070 if ( ( !$property->isUserDefined() ) && ( array_key_exists( $property->getKey(), self::$special_ids ) ) ) {
20672071 return self::$special_ids[$property->getKey()]; // very important property with fixed id
20682072 } else {
2069 - return $this->makeSMWPageID( $property->getKey(), SMW_NS_PROPERTY, $this->getPropertyInterwiki( $property ), '', true );
 2073+ return $this->makeSMWPageID( $property->getKey(), SMW_NS_PROPERTY,
 2074+ $this->getPropertyInterwiki( $property ), '', true );
20702075 }
20712076 }
20722077