Semantic MediaWiki and related extensions
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
SMW\SQLStore\EntityStore\EntityIdManager Class Reference

Public Member Functions

 __construct (SQLStore $store, SQLStoreFactory $factory)
 
 setEqualitySupport (int $equalitySupport)
 
 applyChangesFromListener (string $key, ChangeRecord $changeRecord)
 
 findRedirectSource (DIWikiPage $target, ?string $flag=null)
 
 isRedirect (DIWikiPage $subject)
 
 findRedirect ( $title, $namespace)
 
 addRedirect ( $id, $title, $namespace)
 
 updateRedirect ( $id, $title, $namespace)
 
 deleteRedirect ( $title, $namespace)
 
 getSMWPageIDandSort ( $title, $namespace, $iw, $subobjectName, &$sortkey, $canonical, $fetchHashes=false)
 
 isUnique (DataItem $dataItem)
 
 findDuplicates ()
 
 findIdsByTitle ( $title, $namespace, $iw=null, $subobjectName='')
 
 exists (DIWikiPage $subject)
 
 getId (DIWikiPage $subject)
 
 getSMWPageID ( $title, $namespace, $iw, $subobjectName, $canonical=true, $fetchHashes=false)
 
 makeSMWPageID ( $title, $namespace, $iw, $subobjectName, $canonical=true, $sortkey='', $fetchHashes=false)
 
 getPropertyInterwiki (DIProperty $property)
 
 updateInterwikiField ( $sid, DIWikiPage $subject, $interwiki=null)
 
 findAssociatedRev ( $title, $namespace='', $iw='')
 
 updateRevField ( $sid, $rev_id)
 
 getSMWPropertyID (DIProperty $property)
 
 makeSMWPropertyID (DIProperty $property)
 
 moveSMWPageID ( $curid, $targetid=0)
 
 computeSha1 ( $args='')
 
 warmUpCache ( $list=[], $flag=null)
 
 setCache ( $title, $namespace, $interwiki, $subobject, $id, $sortkey)
 
 getDataItemById ( $id)
 
 getDataItemsFromList (array $idlist, RequestOptions $requestOptions=null)
 
 getDataItemPoolHashListFor (array $idlist, RequestOptions $requestOptions=null)
 
 deleteCache ( $title, $namespace, $interwiki, $subobject)
 
 initCache ()
 
 getPropertyTableHashes ( $sid)
 
 setPropertyTableHashes ( $sid, $hash=null)
 
 preload (array $subjects)
 
 updateFieldMaps ( $sid, array $sequenceMap=null, array $countMap=null)
 
 getSequenceMap ( $sid, $key=null)
 
 loadSequenceMap (array $ids)
 

Public Attributes

const MAX_CACHE_SIZE = 1000
 
const POOLCACHE_ID = 'smw.sqlstore'
 
 $store
 

Static Public Attributes

static $special_ids = []
 

Protected Member Functions

 getDatabaseIdAndSort ( $title, $namespace, $iw, $subobjectName, &$sortkey, $canonical, $fetchHashes)
 
 makeDatabaseId ( $title, $namespace, $iw, $subobjectName, $canonical, $sortkey, $fetchHashes)
 
 getPredefinedData (&$title, &$namespace, &$iw, &$subobjectName, &$sortkey)
 

Detailed Description

Class to access the SMW IDs table in SQLStore3. Provides transparent in-memory caching facilities.

Documentation for the SMW IDs table: This table is a dictionary that assigns integer IDs to pages, properties, and other objects used by SMW. All tables that refer to such objects store these IDs instead. If the ID information is lost (e.g., table gets deleted), then the data stored in SMW is no longer meaningful: all tables need to be dropped, recreated, and refreshed to get back to a working database.

The table has a column for storing interwiki prefixes, used to refer to pages on external sites (like in MediaWiki). This column is also used to mark some special objects in the table, using "interwiki prefixes" that cannot occur in MediaWiki:

Note
Do not call the constructor of SMWDIWikiPage using data from the SMW IDs table; use SMWDIHandlerWikiPage::dataItemFromDBKeys() instead. The table does not always contain data as required wiki pages. Especially predefined properties are represented by language-independent keys rather than proper titles. SMWDIHandlerWikiPage takes care of this.

GNU GPL v2+

Since
1.8
Author
Markus Krötzsch
mwjames

Constructor & Destructor Documentation

◆ __construct()

SMW\SQLStore\EntityStore\EntityIdManager::__construct ( SQLStore  $store,
SQLStoreFactory  $factory 
)
Since
1.8
Parameters
SQLStore$store

Member Function Documentation

◆ addRedirect()

SMW\SQLStore\EntityStore\EntityIdManager::addRedirect (   $id,
  $title,
  $namespace 
)
See also
RedirectStore::addRedirect
Since
2.1
Parameters
integer$id
string$title
integer$namespace

◆ applyChangesFromListener()

SMW\SQLStore\EntityStore\EntityIdManager::applyChangesFromListener ( string  $key,
ChangeRecord  $changeRecord 
)

This method applies changes from when the Settings change listener receives change events from Settings:set.

Since
3.2
Parameters
string$key
ChangeRecord$changeRecord

◆ computeSha1()

SMW\SQLStore\EntityStore\EntityIdManager::computeSha1 (   $args = '')
Since
3.0
Parameters
string | array$args
Returns
string

◆ deleteCache()

SMW\SQLStore\EntityStore\EntityIdManager::deleteCache (   $title,
  $namespace,
  $interwiki,
  $subobject 
)

Remove any cache entry for the given data. The key consists of the parameters $title, $namespace, $interwiki, and $subobject. The cached data is $id and $sortkey.

Since
1.8
Parameters
string$title
integer$namespace
string$interwiki
string$subobject

◆ deleteRedirect()

SMW\SQLStore\EntityStore\EntityIdManager::deleteRedirect (   $title,
  $namespace 
)
See also
RedirectStore::deleteRedirect
Since
2.1
Parameters
string$title
integer$namespace

◆ exists()

SMW\SQLStore\EntityStore\EntityIdManager::exists ( DIWikiPage  $subject)
Since
2.4
Parameters
DIWikiPage$subject
boolean

◆ findAssociatedRev()

SMW\SQLStore\EntityStore\EntityIdManager::findAssociatedRev (   $title,
  $namespace = '',
  $iw = '' 
)
Since
3.0
Parameters
DIWikiPage | string$title
integer$namespace
string$iw

◆ findDuplicates()

SMW\SQLStore\EntityStore\EntityIdManager::findDuplicates ( )
Since
3.0
Returns
[]

◆ findIdsByTitle()

SMW\SQLStore\EntityStore\EntityIdManager::findIdsByTitle (   $title,
  $namespace,
  $iw = null,
  $subobjectName = '' 
)
Since
2.3
Parameters
string$titleDB key
integer$namespacenamespace
string | null$iwinterwiki prefix
string$subobjectNamename of subobject
array

◆ findRedirect()

SMW\SQLStore\EntityStore\EntityIdManager::findRedirect (   $title,
  $namespace 
)
See also
RedirectStore::findRedirect
Since
2.1
Parameters
string$titleDB key
integer$namespace
Returns
integer

◆ findRedirectSource()

SMW\SQLStore\EntityStore\EntityIdManager::findRedirectSource ( DIWikiPage  $target,
?string  $flag = null 
)
Since
3.2
Parameters
DIWikiPage$target
string | null$flag
Returns
string|bool

◆ getDatabaseIdAndSort()

SMW\SQLStore\EntityStore\EntityIdManager::getDatabaseIdAndSort (   $title,
  $namespace,
  $iw,
  $subobjectName,
$sortkey,
  $canonical,
  $fetchHashes 
)
protected

Find the numeric ID used for the page of the given normalized title, namespace, interwiki, and subobjectName. Predefined IDs are not taken into account (however, they would still be found correctly by an avoidable database read if they are stored correctly in the database; this should always be the case). In all other aspects, the method works just like getSMWPageIDandSort().

Since
1.8
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectNamename of subobject
string$sortkeycall-by-ref will be set to sortkey
boolean$canonicalshould redirects be resolved?
boolean$fetchHashesshould the property hashes be obtained and cached?
Returns
integer SMW id or 0 if there is none

◆ getDataItemById()

SMW\SQLStore\EntityStore\EntityIdManager::getDataItemById (   $id)
Since
2.1
Parameters
integer$id
Returns
DIWikiPage|null

◆ getDataItemPoolHashListFor()

SMW\SQLStore\EntityStore\EntityIdManager::getDataItemPoolHashListFor ( array  $idlist,
RequestOptions  $requestOptions = null 
)
Deprecated:
since 3.0, use SMWSql3SmwIds::getDataItemsFromList

◆ getDataItemsFromList()

SMW\SQLStore\EntityStore\EntityIdManager::getDataItemsFromList ( array  $idlist,
RequestOptions  $requestOptions = null 
)
Since
2.3
Parameters
integer$id
RequestOptions | null$requestOptions
Returns
string[]

◆ getId()

SMW\SQLStore\EntityStore\EntityIdManager::getId ( DIWikiPage  $subject)
Note
SMWSql3SmwIds::getSMWPageID has some issues with the cache as it returned 0 even though an object was matchable, using this method is safer then trying to encipher getSMWPageID related methods.

It uses the PoolCache which means Lru is in place to avoid memory leakage.

Since
2.4
Parameters
DIWikiPage$subject
Returns
int

◆ getPredefinedData()

SMW\SQLStore\EntityStore\EntityIdManager::getPredefinedData ( $title,
$namespace,
$iw,
$subobjectName,
$sortkey 
)
protected

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
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectName
string$sortkey
Returns
integer predefined id or 0 if none

◆ getPropertyInterwiki()

SMW\SQLStore\EntityStore\EntityIdManager::getPropertyInterwiki ( DIProperty  $property)

Properties have a mechanisms for being predefined (i.e. in PHP instead of in wiki). Special "interwiki" prefixes separate the ids of such predefined properties from the ids for the current pages (which may, e.g., be moved, while the predefined object is not movable).

Todo:
This documentation is out of date. Right now, the special interwiki is used only for special properties without a label, i.e., which cannot be shown to a user. This allows us to filter such cases from all queries that retrieve lists of properties. It should be checked that this is really the only use that this has throughout the code.
Since
1.8
Parameters
DIProperty$property
Returns
string

◆ getPropertyTableHashes()

SMW\SQLStore\EntityStore\EntityIdManager::getPropertyTableHashes (   $sid)

Return an array of hashes with table names as keys. These hashes are used to compare new data with old data for each property-value table when updating data

Since
1.8
Parameters
integer$subjectIdID of the page as stored in the SMW IDs table
Returns
array

◆ getSequenceMap()

SMW\SQLStore\EntityStore\EntityIdManager::getSequenceMap (   $sid,
  $key = null 
)
Since
3.1
Parameters
integer$sid
string | null$key
Returns
array

◆ getSMWPageID()

SMW\SQLStore\EntityStore\EntityIdManager::getSMWPageID (   $title,
  $namespace,
  $iw,
  $subobjectName,
  $canonical = true,
  $fetchHashes = false 
)

Convenience method for calling getSMWPageIDandSort without specifying a sortkey (if not asked for).

Since
1.8
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectNamename of subobject
boolean$canonicalshould redirects be resolved?
boolean$fetchHashesshould the property hashes be obtained and cached?
Returns
integer SMW id or 0 if there is none

◆ getSMWPageIDandSort()

SMW\SQLStore\EntityStore\EntityIdManager::getSMWPageIDandSort (   $title,
  $namespace,
  $iw,
  $subobjectName,
$sortkey,
  $canonical,
  $fetchHashes = false 
)

Find the numeric ID used for the page of the given title, namespace, interwiki, and subobject. If $canonical is set to true, redirects are taken into account to find the canonical alias ID for the given page. If no such ID exists, 0 is returned. The Call-By-Ref parameter $sortkey is set to the current sortkey, or to '' if no ID exists.

If $fetchhashes is true, the property table hash blob will be retrieved in passing if the opportunity arises, and cached internally. This will speed up a subsequent call to getPropertyTableHashes() for this id. This should only be done if such a call is intended, both to safe the previous cache and to avoid extra work (even if only a little) to fill it.

Since
1.8
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectNamename of subobject
string$sortkeycall-by-ref will be set to sortkey
boolean$canonicalshould redirects be resolved?
boolean$fetchHashesshould the property hashes be obtained and cached?
Returns
integer SMW id or 0 if there is none

◆ getSMWPropertyID()

SMW\SQLStore\EntityStore\EntityIdManager::getSMWPropertyID ( DIProperty  $property)

Fetch the ID for an DIProperty object. This method achieves the same as getSMWPageID(), but avoids additional normalization steps that have already been performed when creating an DIProperty object.

Note
There is no distinction between properties and inverse properties here. A property and its inverse have the same ID in SMW.
Parameters
DIProperty$property
Returns
integer

◆ initCache()

SMW\SQLStore\EntityStore\EntityIdManager::initCache ( )
Since
3.0

◆ isRedirect()

SMW\SQLStore\EntityStore\EntityIdManager::isRedirect ( DIWikiPage  $subject)
Since
2.1
Parameters
DIWikiPage$subject
Returns
boolean

◆ isUnique()

SMW\SQLStore\EntityStore\EntityIdManager::isUnique ( DataItem  $dataItem)
Since
3.0
Parameters
DataItem$dataItem
Returns
boolean

◆ loadSequenceMap()

SMW\SQLStore\EntityStore\EntityIdManager::loadSequenceMap ( array  $ids)
Since
3.1
Parameters
array$ids

◆ makeDatabaseId()

SMW\SQLStore\EntityStore\EntityIdManager::makeDatabaseId (   $title,
  $namespace,
  $iw,
  $subobjectName,
  $canonical,
  $sortkey,
  $fetchHashes 
)
protected

Find the numeric ID used for the page of the given normalized title, namespace, interwiki, and subobjectName. Predefined IDs are not taken into account (however, they would still be found correctly by an avoidable database read if they are stored correctly in the database; this should always be the case). In all other aspects, the method works just like makeSMWPageID(). Especially, if no ID exists, a new ID is created and returned.

Since
1.8
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectNamename of subobject
boolean$canonicalshould redirects be resolved?
string$sortkeycall-by-ref will be set to sortkey
boolean$fetchHashesshould the property hashes be obtained and cached?
Returns
integer SMW id or 0 if there is none

◆ makeSMWPageID()

SMW\SQLStore\EntityStore\EntityIdManager::makeSMWPageID (   $title,
  $namespace,
  $iw,
  $subobjectName,
  $canonical = true,
  $sortkey = '',
  $fetchHashes = false 
)

Find the numeric ID used for the page of the given title, namespace, interwiki, and subobjectName. If $canonical is set to true, redirects are taken into account to find the canonical alias ID for the given page. If no such ID exists, a new ID is created and returned. In any case, the current sortkey is set to the given one unless $sortkey is empty.

Note
Using this with $canonical==false can make sense, especially when the title is a redirect target (we do not want chains of redirects). But it is of no relevance if the title does not have an id yet.
Since
1.8
Parameters
string$titleDB key
integer$namespacenamespace
string$iwinterwiki prefix
string$subobjectNamename of subobject
boolean$canonicalshould redirects be resolved?
string$sortkeycall-by-ref will be set to sortkey
boolean$fetchHashesshould the property hashes be obtained and cached?
Returns
integer SMW id or 0 if there is none

◆ makeSMWPropertyID()

SMW\SQLStore\EntityStore\EntityIdManager::makeSMWPropertyID ( DIProperty  $property)

Fetch and possibly create the ID for an DIProperty object. The method achieves the same as getSMWPageID() but avoids additional normalization steps that have already been performed when creating an DIProperty object.

See also
getSMWPropertyID
Parameters
DIProperty$property
Returns
integer

◆ moveSMWPageID()

SMW\SQLStore\EntityStore\EntityIdManager::moveSMWPageID (   $curid,
  $targetid = 0 
)
See also
IdChanger::move
Since
1.8
Parameters
integer$curid
integer$targetid

◆ preload()

SMW\SQLStore\EntityStore\EntityIdManager::preload ( array  $subjects)
Since
3.2
Parameters
DIWikiPage[]$subjects
Returns
FieldList

◆ setCache()

SMW\SQLStore\EntityStore\EntityIdManager::setCache (   $title,
  $namespace,
  $interwiki,
  $subobject,
  $id,
  $sortkey 
)

Add or modify a cache entry. The key consists of the parameters $title, $namespace, $interwiki, and $subobject. The cached data is $id and $sortkey.

Since
1.8
Parameters
string$title
integer$namespace
string$interwiki
string$subobject
integer$id
string$sortkey

◆ setEqualitySupport()

SMW\SQLStore\EntityStore\EntityIdManager::setEqualitySupport ( int  $equalitySupport)
Since
3.2
Parameters
integer$equalitySupport

◆ setPropertyTableHashes()

SMW\SQLStore\EntityStore\EntityIdManager::setPropertyTableHashes (   $sid,
  $hash = null 
)

Update the proptable_hash for a given page.

Since
1.8
Parameters
integer$sidID of the page as stored in SMW IDs table
string[]of hash values with table names as keys

◆ updateFieldMaps()

SMW\SQLStore\EntityStore\EntityIdManager::updateFieldMaps (   $sid,
array  $sequenceMap = null,
array  $countMap = null 
)
Since
3.2
Parameters
integer$sid
array$sequenceMap
array$countMap

◆ updateInterwikiField()

SMW\SQLStore\EntityStore\EntityIdManager::updateInterwikiField (   $sid,
DIWikiPage  $subject,
  $interwiki = null 
)
Since
2.1
Parameters
integer$sid
DIWikiPage$subject
integer | string | null$interwiki

◆ updateRedirect()

SMW\SQLStore\EntityStore\EntityIdManager::updateRedirect (   $id,
  $title,
  $namespace 
)
See also
RedirectStore::updateRedirect
Since
3.0
Parameters
integer$id
string$title
integer$namespace

◆ updateRevField()

SMW\SQLStore\EntityStore\EntityIdManager::updateRevField (   $sid,
  $rev_id 
)
Since
3.0
Parameters
integer$sid
integer$sid

◆ warmUpCache()

SMW\SQLStore\EntityStore\EntityIdManager::warmUpCache (   $list = [],
  $flag = null 
)
Since
3.0
Parameters
array$list
string | null$flag

The documentation for this class was generated from the following file:

About | General disclaimer | Privacy policy