WikiLambda
MediaWiki WikiLambda extension
Loading...
Searching...
No Matches
MediaWiki\Extension\WikiLambda\ZObjectStore Class Reference

Public Member Functions

 __construct (ILoadBalancer $loadBalancer, TitleFactory $titleFactory, WikiPageFactory $wikiPageFactory, RevisionStore $revisionStore)
 
 getNextAvailableZid ()
 Find next available ZID in the database to create a new ZObject.
 
 fetchZObjectByTitle (Title $title, ?int $requestedRevision=null)
 Fetch the ZObject given its title and return it wrapped in a ZObjectContent object.
 
 fetchBatchZObjects ( $zids)
 Returns an array of ZPersistentObjects fetched from the DB given an array of their Zids.
 
 createNewZObject (string $data, string $summary, User $user)
 Create a new ZObject, with a newly assigned ZID, and store it in the Database.
 
 updateZObject (string $zid, string $data, string $summary, User $user, int $flags=EDIT_UPDATE)
 Create or update a ZObject it in the Database.
 
 deleteZObjectLabelsByZid (string $zid)
 Delete the labels from the wikilambda_zobject_labels database that correspond to the given ZID.
 
 deleteZObjectLabelConflictsByZid (string $zid)
 Delete the label conflicts from the wikilambda_zobject_label_conflicts database that correspond to the given ZID.
 
 findZObjectLabelConflicts ( $zid, $ztype, $labels)
 Query the wikilambda_zobject_labels database for primary labels that have the same combination of language code and value for a different ZID than the given in the parameters.
 
 insertZObjectLabels ( $zid, $ztype, $labels, $returnType=null)
 Insert labels into the wikilambda_zobject_labels database for a given ZID and Type.
 
 insertZObjectLabelConflicts ( $zid, $conflicts)
 Insert label conflicts into the wikilambda_zobject_label_conflicts database for a given ZID.
 
 insertZObjectAliases ( $zid, $ztype, $aliases, $returnType=null)
 Insert alias (secondary labels) into the wikilambda_zobject_labels database for a given ZID and Type.
 
 fetchZidsOfType ( $ztype)
 Gets from the secondary database a list of all Zids belonging to a given type.
 
 fetchAllZids ()
 Get a list of all Zids persisted in the database.
 
 searchZObjectLabels ( $label, $exact, $languages, $type, $returnType, $strictReturnType, $continue, $limit)
 Search labels in the secondary database, filtering by language Zids, type or label string.
 
 fetchZObjectLabel ( $zid, $languageCode, $fallback=true)
 Fetch the label in the secondary database for a given object by Zid, in a given language.
 
 fetchZFunctionReturnType ( $zid)
 Get the return type of a given Function Zid or null if not available.
 
 findFirstZImplementationFunction ()
 Search implementations in the secondary database, return the first one This function is primarily used for the example API request.
 
 findReferencedZObjectsByZFunctionIdAsList ( $zid, $type)
 Converts findReferencedZObjectsByZFunctionId into a list of zids.
 
 findReferencedZObjectsByZFunctionId ( $zid, $type, $continue=null, $limit=10)
 Search implementations in the secondary database and return all matching a given ZID.
 
 insertZFunctionReference ( $refId, $zFunctionId, $type)
 Add a record to the database for a given ZObject ID and ZFunction ID.
 
 deleteZFunctionReference ( $refId)
 Remove a given ZObject ref from the secondary database.
 
 deleteFromLabelsSecondaryTables ( $zids)
 Delete data related to the given zids from the secondary labels table.
 
 deleteFromFunctionsSecondaryTables ( $zids)
 Delete data related to the given zids from the secondary function joins table.
 
 clearLabelsSecondaryTables ()
 Clear all data from the secondary labels table.
 
 clearFunctionsSecondaryTables ()
 Clear all data from the secondary function joins table.
 

Protected Attributes

 $titleFactory
 
 $wikiPageFactory
 
 $revisionStore
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\WikiLambda\ZObjectStore::__construct ( ILoadBalancer $loadBalancer,
TitleFactory $titleFactory,
WikiPageFactory $wikiPageFactory,
RevisionStore $revisionStore )
Parameters
ILoadBalancer$loadBalancer
TitleFactory$titleFactory
WikiPageFactory$wikiPageFactory
RevisionStore$revisionStore

Member Function Documentation

◆ clearFunctionsSecondaryTables()

MediaWiki\Extension\WikiLambda\ZObjectStore::clearFunctionsSecondaryTables ( )

Clear all data from the secondary function joins table.

This method is only for its use by reloadBuiltinData with the –force flag.

Returns
void

◆ clearLabelsSecondaryTables()

MediaWiki\Extension\WikiLambda\ZObjectStore::clearLabelsSecondaryTables ( )

Clear all data from the secondary labels table.

This method is only for its use by reloadBuiltinData with the –force flag.

Returns
void

◆ createNewZObject()

MediaWiki\Extension\WikiLambda\ZObjectStore::createNewZObject ( string $data,
string $summary,
User $user )

Create a new ZObject, with a newly assigned ZID, and store it in the Database.

Parameters
string$data
string$summary
User$user
Returns
ZObjectPage

◆ deleteFromFunctionsSecondaryTables()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteFromFunctionsSecondaryTables ( $zids)

Delete data related to the given zids from the secondary function joins table.

This method is only for its use by reloadBuiltinData with the –force flag.

Parameters
string[]$zidslist of zids to clear, if null, clear all rows
Returns
void

◆ deleteFromLabelsSecondaryTables()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteFromLabelsSecondaryTables ( $zids)

Delete data related to the given zids from the secondary labels table.

This method is only for its use by reloadBuiltinData with the –force flag.

Parameters
string[]$zidslist of zids to clear, if null, clear all rows
Returns
void

◆ deleteZFunctionReference()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZFunctionReference ( $refId)

Remove a given ZObject ref from the secondary database.

Parameters
string$refIdthe ZObject ID
Returns
void

◆ deleteZObjectLabelConflictsByZid()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZObjectLabelConflictsByZid ( string $zid)

Delete the label conflicts from the wikilambda_zobject_label_conflicts database that correspond to the given ZID.

Parameters
string$zid

◆ deleteZObjectLabelsByZid()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZObjectLabelsByZid ( string $zid)

Delete the labels from the wikilambda_zobject_labels database that correspond to the given ZID.

Parameters
string$zid

◆ fetchAllZids()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllZids ( )

Get a list of all Zids persisted in the database.

Returns
string[] All persisted Zids

◆ fetchBatchZObjects()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchBatchZObjects ( $zids)

Returns an array of ZPersistentObjects fetched from the DB given an array of their Zids.

Note that this will only fetch the latest revision of a ZObject; if you want a specific revision, you need to use ZObjectStore::fetchZObjectByTitle() instead.

Parameters
string[]$zids
Returns
ZPersistentObject[]

◆ fetchZFunctionReturnType()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZFunctionReturnType ( $zid)

Get the return type of a given Function Zid or null if not available.

Parameters
string$zid
Returns
string|null

◆ fetchZidsOfType()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZidsOfType ( $ztype)

Gets from the secondary database a list of all Zids belonging to a given type.

Parameters
string$ztype
Returns
string[]

◆ fetchZObjectByTitle()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZObjectByTitle ( Title $title,
?int $requestedRevision = null )

Fetch the ZObject given its title and return it wrapped in a ZObjectContent object.

Parameters
Title$titleThe ZObject to fetch
int | null$requestedRevisionThe revision ID of the page to fetch. If unset, the latest is returned.
Returns
ZObjectContent|bool Found ZObject

◆ fetchZObjectLabel()

MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZObjectLabel ( $zid,
$languageCode,
$fallback = true )

Fetch the label in the secondary database for a given object by Zid, in a given language.

Returns null if no labels are found in the given language or any other language in that language's fallback chain, including English (Z1002). If the language code given is not recognised, this will fall back to returning the English label, if available.

Parameters
string$zidTerm to search in the label database
string$languageCodeCode of the language in which to fetch the label
bool$fallbackWhether to only match in the given language, or use the language fallback change (default behaviour).
Returns
string|null

◆ findFirstZImplementationFunction()

MediaWiki\Extension\WikiLambda\ZObjectStore::findFirstZImplementationFunction ( )

Search implementations in the secondary database, return the first one This function is primarily used for the example API request.

Returns
string

◆ findReferencedZObjectsByZFunctionId()

MediaWiki\Extension\WikiLambda\ZObjectStore::findReferencedZObjectsByZFunctionId ( $zid,
$type,
$continue = null,
$limit = 10 )

Search implementations in the secondary database and return all matching a given ZID.

Parameters
string$zidthe ZID of the ZFunction
string$typethe type of the ZFunction reference
string | null$continueId to start. If null (the default), start from the first result.
int$limitMaximum number of results to return. Defaults to 10
Returns
IResultWrapper

◆ findReferencedZObjectsByZFunctionIdAsList()

MediaWiki\Extension\WikiLambda\ZObjectStore::findReferencedZObjectsByZFunctionIdAsList ( $zid,
$type )

Converts findReferencedZObjectsByZFunctionId into a list of zids.

Parameters
string$zidthe ZID of the ZFunction
string$typethe type of the ZFunction reference
Returns
string[] All ZIDs of referenced ZObjects associated to the ZFunction

◆ findZObjectLabelConflicts()

MediaWiki\Extension\WikiLambda\ZObjectStore::findZObjectLabelConflicts ( $zid,
$ztype,
$labels )

Query the wikilambda_zobject_labels database for primary labels that have the same combination of language code and value for a different ZID than the given in the parameters.

These will be considered conflicting labels.

Parameters
string$zid
string$ztype
array$labelsArray of labels, where the key is the language code and the value is the string representation of the label in that language
Returns
array Conflicts found in the wikilambda_zobject_labels database

◆ getNextAvailableZid()

MediaWiki\Extension\WikiLambda\ZObjectStore::getNextAvailableZid ( )

Find next available ZID in the database to create a new ZObject.

Returns
string Next available ZID

◆ insertZFunctionReference()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZFunctionReference ( $refId,
$zFunctionId,
$type )

Add a record to the database for a given ZObject ID and ZFunction ID.

Parameters
string$refIdthe ZObject ref ID
string$zFunctionIdthe ZFunction ID
string$typethe type of the ZFunction reference
Returns
void|bool

◆ insertZObjectAliases()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZObjectAliases ( $zid,
$ztype,
$aliases,
$returnType = null )

Insert alias (secondary labels) into the wikilambda_zobject_labels database for a given ZID and Type.

Parameters
string$zid
string$ztype
array$aliasesSet of labels, where the key is the language code and the value is an array of strings
string | null$returnType
Returns
void|bool

◆ insertZObjectLabelConflicts()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZObjectLabelConflicts ( $zid,
$conflicts )

Insert label conflicts into the wikilambda_zobject_label_conflicts database for a given ZID.

Parameters
string$zid
array$conflictsArray of labels, where the key is the language code and the value is the other ZID for which this label is repeated
Returns
void|bool

◆ insertZObjectLabels()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZObjectLabels ( $zid,
$ztype,
$labels,
$returnType = null )

Insert labels into the wikilambda_zobject_labels database for a given ZID and Type.

Parameters
string$zid
string$ztype
array$labelsArray of labels, where the key is the language code and the value is the string representation of the label in that language
string | null$returnType
Returns
void|bool

◆ searchZObjectLabels()

MediaWiki\Extension\WikiLambda\ZObjectStore::searchZObjectLabels ( $label,
$exact,
$languages,
$type,
$returnType,
$strictReturnType,
$continue,
$limit )

Search labels in the secondary database, filtering by language Zids, type or label string.

Parameters
string$labelTerm to search in the label database
bool$exactWhether to search by exact match
string[]$languagesList of language Zids to filter by
string | null$typeZid of the type to filter by. If null, don't filter by type.
string | null$returnTypeZid of the return type to filter by. If null, don't filter by return type.
bool$strictReturnTypeWhether to exclude Z1s as return type.
string | null$continueId to start. If null, start from the first result.
int$limitMaximum number of results to return.
Returns
IResultWrapper

◆ updateZObject()

MediaWiki\Extension\WikiLambda\ZObjectStore::updateZObject ( string $zid,
string $data,
string $summary,
User $user,
int $flags = EDIT_UPDATE )

Create or update a ZObject it in the Database.

Parameters
string$zid
string$data
string$summary
User$user
int$flags
Returns
ZObjectPage
+ Here is the call graph for this function:

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