r108968 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108967‎ | r108968 | r108969 >
Date:12:08, 15 January 2012
Author:mkroetzsch
Status:deferred (Comments)
Tags:
Comment:
some style improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -93,6 +93,8 @@
9494 public function refreshConceptCache( Title $concept ) {
9595 global $smwgQMaxLimit, $smwgQConceptFeatures, $wgDBtype;
9696
 97+ $fname = 'SMW::refreshConceptCache';
 98+
9799 $cid = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '', '' );
98100 $cid_c = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '', '', false );
99101
@@ -101,7 +103,7 @@
102104 return $this->m_errors;
103105 }
104106
105 - $values = $this->m_store->getPropertyValues( SMWDIWikiPage::newFromTitle( $concept ), new SMWDIProperty( '_CONC' ) );// two lines due to "strict standards" warning
 107+ $values = $this->m_store->getPropertyValues( SMWDIWikiPage::newFromTitle( $concept ), new SMWDIProperty( '_CONC' ) );
106108 $di = end( $values );
107109 $desctxt = ( $di !== false ) ? $di->getConceptQuery() : false;
108110 $this->m_errors = array();
@@ -127,27 +129,34 @@
128130 }
129131
130132 // Update database:
131 - $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' );
 133+ $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), $fname );
 134+ $smw_conccache = $this->m_dbs->tablename( 'smw_conccache' );
132135
133136 if ( $wgDBtype == 'postgres' ) { // PostgresQL: no INSERT IGNORE, check for duplicates explicitly
134 - $where = $qobj->where . ( $qobj->where ? ' AND ':'' ) .
135 - 'NOT EXISTS (SELECT NULL FROM ' . $this->m_dbs->tableName( 'smw_conccache' ) .
136 - ' WHERE ' . $this->m_dbs->tablename( 'smw_conccache' ) . '.s_id = ' . $qobj->alias . '.s_id ' .
137 - ' AND ' . $this->m_dbs->tablename( 'smw_conccache' ) . '.o_id = ' . $qobj->alias . '.o_id )';
 137+ $where = $qobj->where . ( $qobj->where ? ' AND ' : '' ) .
 138+ "NOT EXISTS (SELECT NULL FROM $smw_conccache" .
 139+ " WHERE {$smw_conccache}.s_id = {$qobj->alias}.s_id " .
 140+ " AND {$smw_conccache}.o_id = {$qobj->alias}.o_id )";
138141 } else { // MySQL just uses INSERT IGNORE, no extra conditions
139142 $where = $qobj->where;
140143 }
141144
142 - $this->m_dbs->query( "INSERT " . ( ( $wgDBtype == 'postgres' ) ? "":"IGNORE " ) . "INTO " . $this->m_dbs->tableName( 'smw_conccache' ) .
143 - " SELECT DISTINCT $qobj->joinfield AS s_id, $cid AS o_id FROM " .
144 - $this->m_dbs->tableName( $qobj->jointable ) . " AS $qobj->alias" . $qobj->from .
145 - ( $where ? " WHERE ":'' ) . $where . " LIMIT $smwgQMaxLimit",
146 - 'SMW::refreshConceptCache' );
 145+ $this->m_dbs->query( "INSERT " . ( ( $wgDBtype == 'postgres' ) ? '' : 'IGNORE ' ) .
 146+ "INTO $smw_conccache" .
 147+ " SELECT DISTINCT {$qobj->joinfield} AS s_id, $cid AS o_id FROM " .
 148+ $this->m_dbs->tableName( $qobj->jointable ) . " AS {$qobj->alias}" .
 149+ $qobj->from .
 150+ ( $where ? ' WHERE ' : '' ) . $where . " LIMIT $smwgQMaxLimit",
 151+ $fname );
147152
148 - $this->m_dbs->update( 'smw_conc2', array( 'cache_date' => strtotime( "now" ), 'cache_count' => $this->m_dbs->affectedRows() ), array( 's_id' => $cid ), 'SMW::refreshConceptCache' );
149 - } else { // just delete old data if there is any
150 - $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' );
151 - $this->m_dbs->update( 'smw_conc2', array( 'cache_date' => null, 'cache_count' => null ), array( 's_id' => $cid ), 'SMW::refreshConceptCache' );
 153+ $this->m_dbs->update( 'smw_conc2',
 154+ array( 'cache_date' => strtotime( "now" ), 'cache_count' => $this->m_dbs->affectedRows() ),
 155+ array( 's_id' => $cid ), $fname );
 156+ } else { // no concept found; just delete old data if there is any
 157+ $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), $fname );
 158+ $this->m_dbs->update( 'smw_conc2',
 159+ array( 'cache_date' => null, 'cache_count' => null ),
 160+ array( 's_id' => $cid ), $fname );
152161 $this->m_errors[] = "No concept description found.";
153162 }
154163
@@ -504,7 +513,7 @@
505514 }
506515 } elseif ( $description instanceof SMWConceptDescription ) { // fetch concept definition and insert it here
507516 $cid = $this->m_store->getSMWPageID( $description->getConcept()->getDBkey(), SMW_NS_CONCEPT, '', '' );
508 - // We bypass the storage interface here (which is legal as we controll it, and safe if we are careful with changes ...)
 517+ // We bypass the storage interface here (which is legal as we control it, and safe if we are careful with changes ...)
509518 // This should be faster, but we must implement the unescaping that concepts do on getWikiValue()
510519 $row = $this->m_dbs->selectRow(
511520 'smw_conc2',

Comments

#Comment by Nikerabbit (talk | contribs)   12:40, 15 January 2012

Can't you just use __METHOD__ instead of specifying $fname manually?

#Comment by Krinkle (talk | contribs)   12:55, 15 January 2012

Probably PHP pre-5.0.0 habbits :)