Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -93,6 +93,8 @@ |
94 | 94 | public function refreshConceptCache( Title $concept ) { |
95 | 95 | global $smwgQMaxLimit, $smwgQConceptFeatures, $wgDBtype; |
96 | 96 | |
| 97 | + $fname = 'SMW::refreshConceptCache'; |
| 98 | + |
97 | 99 | $cid = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '', '' ); |
98 | 100 | $cid_c = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '', '', false ); |
99 | 101 | |
— | — | @@ -101,7 +103,7 @@ |
102 | 104 | return $this->m_errors; |
103 | 105 | } |
104 | 106 | |
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' ) ); |
106 | 108 | $di = end( $values ); |
107 | 109 | $desctxt = ( $di !== false ) ? $di->getConceptQuery() : false; |
108 | 110 | $this->m_errors = array(); |
— | — | @@ -127,27 +129,34 @@ |
128 | 130 | } |
129 | 131 | |
130 | 132 | // 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' ); |
132 | 135 | |
133 | 136 | 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 )"; |
138 | 141 | } else { // MySQL just uses INSERT IGNORE, no extra conditions |
139 | 142 | $where = $qobj->where; |
140 | 143 | } |
141 | 144 | |
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 ); |
147 | 152 | |
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 ); |
152 | 161 | $this->m_errors[] = "No concept description found."; |
153 | 162 | } |
154 | 163 | |
— | — | @@ -504,7 +513,7 @@ |
505 | 514 | } |
506 | 515 | } elseif ( $description instanceof SMWConceptDescription ) { // fetch concept definition and insert it here |
507 | 516 | $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 ...) |
509 | 518 | // This should be faster, but we must implement the unescaping that concepts do on getWikiValue() |
510 | 519 | $row = $this->m_dbs->selectRow( |
511 | 520 | 'smw_conc2', |