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

Public Member Functions

 __construct (IConnectionProvider $dbProvider, TitleFactory $titleFactory, WikiPageFactory $wikiPageFactory, RevisionStore $revisionStore, UserGroupManager $userGroupManager, LoggerInterface $logger)
 
 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.
 
 updateZObjectAsSystemUser (string $zid, string $data, string $summary, int $flags=EDIT_UPDATE)
 Create or update a ZObject it in the Database as a System User.
 
 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.
 
 insertZLanguageToLanguagesCache (string $zid, string $languageCode)
 Insert language code into the wikilambda_zlanguages database for a given ZID.
 
 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.
 
 fetchAllZLanguageObjects ()
 Gets from the secondary database a list of all natural language ZIDs, mapping from ZID to BCP47 (or MediaWiki) language code.
 
 fetchAllZLanguageCodes ()
 Gets from the secondary database a list of all supported natural languages, mapping from ZID to BCP47 (or MediaWiki) language code.
 
 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.
 
 findZTesterResult (?string $functionZID, ?int $functionRevision, ?string $implementationZID, ?int $implementationRevision, ?string $testerZID, ?int $testerRevision)
 Search test run results in the secondary tester results table; the latest result (highest database ID) will be used.
 
 insertZTesterResult (string $functionZID, int $functionRevision, string $implementationZID, int $implementationRevision, string $testerZID, int $testerRevision, bool $testerResult, string $testerResponse)
 Cache a test run result in the secondary tester results table.
 
 deleteZFunctionFromZTesterResultsCache (string $refId)
 Remove a given ZFunction's results from the secondary tester results table.
 
 deleteZImplementationFromZTesterResultsCache (string $refId)
 Remove a given ZImplementation's results from the secondary tester results table.
 
 deleteZTesterFromZTesterResultsCache (string $refId)
 Remove a given ZTester's results from the secondary tester results table.
 
 deleteZLanguageFromLanguagesCache (string $zid)
 Remove a given ZNaturalLanguage's entry from the secondary languages table.
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\WikiLambda\ZObjectStore::__construct ( IConnectionProvider $dbProvider,
TitleFactory $titleFactory,
WikiPageFactory $wikiPageFactory,
RevisionStore $revisionStore,
UserGroupManager $userGroupManager,
LoggerInterface $logger )
Parameters
IConnectionProvider$dbProvider
TitleFactory$titleFactory
WikiPageFactory$wikiPageFactory
RevisionStore$revisionStore
UserGroupManager$userGroupManager
LoggerInterface$logger

Member Function Documentation

◆ 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

◆ deleteZFunctionFromZTesterResultsCache()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZFunctionFromZTesterResultsCache ( string $refId)

Remove a given ZFunction's results from the secondary tester results table.

Parameters
string$refIdthe ZID of the ZFunction whose results you wish to delete
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

◆ deleteZImplementationFromZTesterResultsCache()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZImplementationFromZTesterResultsCache ( string $refId)

Remove a given ZImplementation's results from the secondary tester results table.

Parameters
string$refIdthe ZID of the ZImplementation whose results you wish to delete
Returns
void

◆ deleteZLanguageFromLanguagesCache()

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

Remove a given ZNaturalLanguage's entry from the secondary languages table.

Parameters
string$zidthe ZID of the ZNaturalLanguage you wish to delete
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

◆ deleteZTesterFromZTesterResultsCache()

MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZTesterFromZTesterResultsCache ( string $refId)

Remove a given ZTester's results from the secondary tester results table.

Parameters
string$refIdthe ZID of the ZTester whose results you wish to delete
Returns
void

◆ fetchAllZids()

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

Get a list of all Zids persisted in the database.

Returns
string[] All persisted Zids

◆ fetchAllZLanguageCodes()

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

Gets from the secondary database a list of all supported natural languages, mapping from ZID to BCP47 (or MediaWiki) language code.

Returns
array<string>

◆ fetchAllZLanguageObjects()

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

Gets from the secondary database a list of all natural language ZIDs, mapping from ZID to BCP47 (or MediaWiki) language code.

Returns
array<string,string>

◆ 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 | null$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

◆ findZTesterResult()

MediaWiki\Extension\WikiLambda\ZObjectStore::findZTesterResult ( ?string $functionZID,
?int $functionRevision,
?string $implementationZID,
?int $implementationRevision,
?string $testerZID,
?int $testerRevision )

Search test run results in the secondary tester results table; the latest result (highest database ID) will be used.

Parameters
?string$functionZIDThe ZID of the ZFunction
?int$functionRevisionThe revision ID of the ZFunction
?string$implementationZIDThe ZID of the ZImplementation
?int$implementationRevisionThe revision ID of the ZImplementation
?string$testerZIDThe ZID of the ZTester
?int$testerRevisionThe revision ID of the ZTester
Returns
?ZResponseEnvelope

◆ 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

◆ insertZLanguageToLanguagesCache()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZLanguageToLanguagesCache ( string $zid,
string $languageCode )

Insert language code into the wikilambda_zlanguages database for a given ZID.

Parameters
string$zid
string$languageCode
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

◆ insertZTesterResult()

MediaWiki\Extension\WikiLambda\ZObjectStore::insertZTesterResult ( string $functionZID,
int $functionRevision,
string $implementationZID,
int $implementationRevision,
string $testerZID,
int $testerRevision,
bool $testerResult,
string $testerResponse )

Cache a test run result in the secondary tester results table.

Parameters
string$functionZIDThe ZID of the ZFunction
int$functionRevisionThe revision ID of the ZFunction
string$implementationZIDThe ZID of the ZImplementation
int$implementationRevisionThe revision ID of the ZImplementation
string$testerZIDThe ZID of the ZTester
int$testerRevisionThe revision ID of the ZTester
bool$testerResultWhether the test run passed (true) or failed (false)
string$testerResponseThe test run response JSON object
Returns
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 | null$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$zidThe ZID of the page to create/update, e.g. 'Z12345'
string$dataThe ZObject's JSON to store, in string form, i.e. "{ Z1K1: "Z2", Z2K1: … }"
string$summaryAn edit summary to display in the page's history, Recent Changes, watchlists, etc.
User$userThe user making the edit.
int$flagsEither EDIT_UPDATE (default) if editing or EDIT_NEW if creating a page
Returns
ZObjectPage
+ Here is the call graph for this function:

◆ updateZObjectAsSystemUser()

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

Create or update a ZObject it in the Database as a System User.

Parameters
string$zid
string$data
string$summary
int$flags
Returns
ZObjectPage

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