public function testRegister()
 {
     $instance = new PropertyRegistry();
     $instance->register();
     $this->assertNotEmpty(DIProperty::findPropertyLabel(PropertyRegistry::SBL_PARENTPAGE));
     $this->assertSame(SBL_PROP_PARENTPAGE, DIProperty::findPropertyLabel(PropertyRegistry::SBL_PARENTPAGE));
 }
 /**
  * @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);
 }
Пример #3
0
 /**
  * @note This method does not make additional checks therefore it is assumed
  * that the input hash is derived or generated from HashBuilder::getSegmentedHashId
  *
  * @since 2.1
  *
  * @param string
  *
  * @return DIWikiPage|null
  */
 public static function newDiWikiPageFromHash($hash)
 {
     list($title, $namespace, $interwiki, $subobjectName) = explode('#', $hash, 4);
     // A leading underscore is an internal SMW convention to describe predefined
     // properties and as such need to be transformed into a valid representation
     if ($title[0] === '_') {
         $title = str_replace(' ', '_', DIProperty::findPropertyLabel($title));
     }
     return new DIWikiPage($title, $namespace, $interwiki, $subobjectName);
 }
Пример #4
0
 /**
  * Normalize the information for an SMW object (page etc.) and return
  * the predefined ID if any. All parameters are call-by-reference and
  * will be changed to perform any kind of built-in normalization that
  * SMW requires. This mainly applies to predefined properties that
  * should always use their property key as a title, have fixed
  * sortkeys, etc. Some very special properties also have fixed IDs that
  * do not require any DB lookups. In such cases, the method returns
  * this ID; otherwise it returns 0.
  *
  * @note This function could be extended to account for further kinds
  * of normalization and predefined ID. However, both getSMWPropertyID
  * and makeSMWPropertyID must then also be adjusted to do the same.
  *
  * @since 1.8
  * @param string $title DB key
  * @param integer $namespace namespace
  * @param string $iw interwiki prefix
  * @param string $subobjectName
  * @param string $sortkey
  * @return integer predefined id or 0 if none
  */
 protected function getPredefinedData(&$title, &$namespace, &$iw, &$subobjectName, &$sortkey)
 {
     if ($namespace == SMW_NS_PROPERTY && ($iw === '' || $iw == SMW_SQL3_SMWINTDEFIW) && $title != '') {
         // Check if this is a predefined property:
         if ($title[0] != '_') {
             // This normalization also applies to
             // subobjects of predefined properties.
             $newTitle = SMW\DIProperty::findPropertyID(str_replace('_', ' ', $title));
             if ($newTitle) {
                 $title = $newTitle;
                 $sortkey = SMW\DIProperty::findPropertyLabel($title);
                 if ($sortkey === '') {
                     $iw = SMW_SQL3_SMWINTDEFIW;
                 }
             }
         }
         // Check if this is a property with a fixed SMW ID:
         if ($subobjectName === '' && array_key_exists($title, self::$special_ids)) {
             return self::$special_ids[$title];
         }
     }
     return 0;
 }