public function testDeleteReferencesFromPropertyTablesFor()
 {
     $tableDefinition = $connection = $this->getMockBuilder('\\SMW\\SQLStore\\TableDefinition')->disableOriginalConstructor()->getMock();
     $tableDefinition->expects($this->once())->method('usesIdSubject')->will($this->returnValue(true));
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('selectRow')->will($this->returnValue(false));
     $connection->expects($this->at(1))->method('delete')->with($this->equalTo(\SMW\SQLStore\SQLStore::ID_TABLE));
     $this->store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $this->store->expects($this->any())->method('getPropertyTables')->will($this->returnValue(array($tableDefinition)));
     $instance = new PropertyTableOutdatedReferenceDisposer($this->store);
     $instance->removeAnyReferenceFromPropertyTablesFor(42);
 }
 /**
  * @param integer $id
  * @param UpdateJob[] &$updatejobs
  */
 private function createUpdateJobsForSmwIdRange($id, &$updatejobs, &$emptyrange)
 {
     // update by internal SMW id --> make sure we get all objects in SMW
     $db = $this->store->getConnection('mw.db');
     $res = $db->select(\SMWSql3SmwIds::TABLE_NAME, array('smw_id', 'smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject', 'smw_proptable_hash'), array("smw_id >= {$id} ", " smw_id < " . $db->addQuotes($id + $this->iterationLimit)), __METHOD__);
     foreach ($res as $row) {
         $emptyrange = false;
         // note this even if no jobs were created
         if ($this->namespaces && !in_array($row->smw_namespace, $this->namespaces)) {
             continue;
         }
         // Find page to refresh, even for special properties:
         if ($row->smw_title != '' && $row->smw_title[0] != '_') {
             $titleKey = $row->smw_title;
         } elseif ($row->smw_namespace == SMW_NS_PROPERTY && $row->smw_iw == '' && $row->smw_subobject == '') {
             $titleKey = str_replace(' ', '_', DIProperty::findPropertyLabel($row->smw_title));
         } else {
             $titleKey = '';
         }
         if ($row->smw_subobject !== '' && $row->smw_iw !== SMW_SQL3_SMWDELETEIW) {
             // leave subobjects alone; they ought to be changed with their pages
         } elseif ($this->isPlainObjectValue($row)) {
             $this->propertyTableOutdatedReferenceDisposer->attemptToRemoveOutdatedEntryFromIDTable($row->smw_id);
         } elseif ($row->smw_iw === '' && $titleKey != '') {
             // objects representing pages
             $title = Title::makeTitleSafe($row->smw_namespace, $titleKey);
             if ($title !== null) {
                 $updatejobs[] = $this->newUpdateJob($title);
             }
         } elseif ($row->smw_iw == SMW_SQL3_SMWREDIIW && $titleKey != '') {
             // TODO: special treatment of redirects needed, since the store will
             // not act on redirects that did not change according to its records
             $title = Title::makeTitleSafe($row->smw_namespace, $titleKey);
             if ($title !== null && !$title->exists()) {
                 $updatejobs[] = $this->newUpdateJob($title);
             }
         } elseif ($row->smw_iw == SMW_SQL3_SMWIW_OUTDATED || $row->smw_iw == SMW_SQL3_SMWDELETEIW) {
             // remove outdated internal object references
             $this->propertyTableOutdatedReferenceDisposer->removeAnyReferenceFromPropertyTablesFor($row->smw_id);
         } elseif ($titleKey != '') {
             // "normal" interwiki pages or outdated internal objects -- delete
             $diWikiPage = new DIWikiPage($titleKey, $row->smw_namespace, $row->smw_iw);
             $emptySemanticData = new SemanticData($diWikiPage);
             $this->store->updateData($emptySemanticData);
         }
     }
     $db->freeResult($res);
 }