WikiLambda
MediaWiki WikiLambda extension
|
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. | |
getRevisionById (int $id) | |
Load a page revision from a given revision ID number. | |
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. | |
pushZObject (string $zid, string $data, string $summary) | |
Push a given Object into the Database, without validation. | |
createNewZObject (MessageLocalizer $context, string $data, string $summary, User $user) | |
Create a new ZObject, with a newly assigned ZID, and store it in the Database. | |
updateZObject (MessageLocalizer $context, string $zid, string $data, string $summary, User $user, int $flags=EDIT_UPDATE) | |
Create or update a ZObject it in the Database. | |
updateZObjectAsSystemUser (MessageLocalizer $context, 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 BCP47 (or MediaWiki) language code to ZID (one zid can map to multiple BCP47 codes) | |
fetchAllZLanguageCodes () | |
Gets from the secondary database a list of all supported natural BCP47 (or MediaWiki) language codes. | |
findCodesFromZLanguage (string $zid) | |
Gets from the secondary database the matching BCP47 (or MediaWiki) language code(s) for a given ZID. | |
fetchAllZLanguagesWithLabels ( $userLang) | |
Fetch all ZLanguages stored in the language cache table, and for each one, return its zid, its language code, and its label in the user language or the closest available fallback. | |
fetchAllInstancedTypesWithLabels ( $userLang) | |
Fetch all ZTypes that have persisted instances, with their label in the user language or the closest available fallback. | |
fetchAllInstancedTypes () | |
Returns a list of distinct type Zids that have persisted instances. | |
getPreferredLabelsQuery ( $languageChain) | |
Generates a query that filters to the preferred label in the labels table, depending on the user's language fallback chain passed as parameter. | |
getTestStatusQuery () | |
Generates a query that returns a table with all the existing test objects, their function, and their status: | |
findZLanguageFromCode (string $code) | |
Gets from the secondary database the ZID of a given 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. | |
fetchAllImplementations () | |
Fetch all objects of type Z14/Implementation persisted in the database, including connected, disconnected, labeled and unlabeled implementations. | |
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. | |
findRelatedZObjectsByKeyAsList ( $mainZid, $key) | |
For the given main ZObject and key, return the related ZObjects. | |
findRelatedZObjectsByKey ( $mainZid, $key, $continue=null, $limit=10) | |
For the given main ZObject and key, return the related ZObjects. | |
insertRelatedZObjects ( $relatedZObjects) | |
Add a batch of rows to the database describing the relation between a main ZObject and a related one, given by the connecting key. | |
deleteRelatedZObjects (?string $mainZid, ?string $mainType=null, ?string $key=null, ?string $relatedZObject=null, ?string $relatedType=null) | |
Delete all rows matching all of the non-null input values. | |
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. | |
MediaWiki\Extension\WikiLambda\ZObjectStore::__construct | ( | IConnectionProvider | $dbProvider, |
TitleFactory | $titleFactory, | ||
WikiPageFactory | $wikiPageFactory, | ||
RevisionStore | $revisionStore, | ||
UserGroupManager | $userGroupManager, | ||
LoggerInterface | $logger ) |
IConnectionProvider | $dbProvider | |
TitleFactory | $titleFactory | |
WikiPageFactory | $wikiPageFactory | |
RevisionStore | $revisionStore | |
UserGroupManager | $userGroupManager | |
LoggerInterface | $logger |
MediaWiki\Extension\WikiLambda\ZObjectStore::createNewZObject | ( | MessageLocalizer | $context, |
string | $data, | ||
string | $summary, | ||
User | $user ) |
Create a new ZObject, with a newly assigned ZID, and store it in the Database.
MessageLocalizer | $context | The context of the action operation, for localisation of messages |
string | $data | |
string | $summary | |
User | $user |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteRelatedZObjects | ( | ?string | $mainZid, |
?string | $mainType = null, | ||
?string | $key = null, | ||
?string | $relatedZObject = null, | ||
?string | $relatedType = null ) |
Delete all rows matching all of the non-null input values.
?string | $mainZid | ZID of the main ZObject |
?string | $mainType | ZID of the type of the main ZObject |
?string | $key | ZID of a key indicating the relation between main and related ZObjects |
?string | $relatedZObject | The related ZObject |
?string | $relatedType | ZID of the type of the related ZObject |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZFunctionFromZTesterResultsCache | ( | string | $refId | ) |
Remove a given ZFunction's results from the secondary tester results table.
string | $refId | the ZID of the ZFunction whose results you wish to delete |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZFunctionReference | ( | $refId | ) |
Remove a given ZObject ref from the secondary database.
string | $refId | the ZObject ID |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZImplementationFromZTesterResultsCache | ( | string | $refId | ) |
Remove a given ZImplementation's results from the secondary tester results table.
string | $refId | the ZID of the ZImplementation whose results you wish to delete |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZLanguageFromLanguagesCache | ( | string | $zid | ) |
Remove a given ZNaturalLanguage's entry from the secondary languages table.
string | $zid | the ZID of the ZNaturalLanguage you wish to delete |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZObjectLabelConflictsByZid | ( | string | $zid | ) |
Delete the label conflicts from the wikilambda_zobject_label_conflicts database that correspond to the given ZID.
string | $zid |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZObjectLabelsByZid | ( | string | $zid | ) |
Delete the labels from the wikilambda_zobject_labels database that correspond to the given ZID.
string | $zid |
MediaWiki\Extension\WikiLambda\ZObjectStore::deleteZTesterFromZTesterResultsCache | ( | string | $refId | ) |
Remove a given ZTester's results from the secondary tester results table.
string | $refId | the ZID of the ZTester whose results you wish to delete |
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllImplementations | ( | ) |
Fetch all objects of type Z14/Implementation persisted in the database, including connected, disconnected, labeled and unlabeled implementations.
TODO (T287153): This method is only needed for the migrateZ16K1StringsToZ61s maintenance script, as using fetchZidsOfType(Z14) will not return those implementations that aren't labeled. Once we eliminate the maintenance script, we should remove this method, too.
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllInstancedTypes | ( | ) |
Returns a list of distinct type Zids that have persisted instances.
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllInstancedTypesWithLabels | ( | $userLang | ) |
Fetch all ZTypes that have persisted instances, with their label in the user language or the closest available fallback.
string | $userLang | - User language BCP47 code |
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllZids | ( | ) |
Get a list of all Zids persisted in the database.
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllZLanguageCodes | ( | ) |
Gets from the secondary database a list of all supported natural BCP47 (or MediaWiki) language codes.
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllZLanguageObjects | ( | ) |
Gets from the secondary database a list of all natural language ZIDs, mapping from BCP47 (or MediaWiki) language code to ZID (one zid can map to multiple BCP47 codes)
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchAllZLanguagesWithLabels | ( | $userLang | ) |
Fetch all ZLanguages stored in the language cache table, and for each one, return its zid, its language code, and its label in the user language or the closest available fallback.
string | $userLang | - User language BCP47 code |
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.
string[] | $zids |
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZFunctionReturnType | ( | $zid | ) |
Get the return type of a given Function Zid or null if not available.
string | $zid |
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZidsOfType | ( | $ztype | ) |
Gets from the secondary database a list of all Zids belonging to a given type.
string | $ztype |
MediaWiki\Extension\WikiLambda\ZObjectStore::fetchZObjectByTitle | ( | Title | $title, |
?int | $requestedRevision = null ) |
Fetch the ZObject given its title and return it wrapped in a ZObjectContent object.
Title | $title | The ZObject to fetch |
int | null | $requestedRevision | The revision ID of the page to fetch. If unset, the latest is returned. |
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.
string | $zid | Term to search in the label database |
string | $languageCode | Code of the language in which to fetch the label |
bool | $fallback | Whether to only match in the given language, or use the language fallback change (default behaviour). |
MediaWiki\Extension\WikiLambda\ZObjectStore::findCodesFromZLanguage | ( | string | $zid | ) |
Gets from the secondary database the matching BCP47 (or MediaWiki) language code(s) for a given ZID.
string | $zid | The ZID of the matching ZLanguage object for which to search. |
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.
MediaWiki\Extension\WikiLambda\ZObjectStore::findReferencedZObjectsByZFunctionId | ( | $zid, | |
$type, | |||
$continue = null, | |||
$limit = 10 ) |
Search implementations in the secondary database and return all matching a given ZID.
string | $zid | the ZID of the ZFunction |
string | $type | the type of the ZFunction reference |
string | null | $continue | Id to start. If null (the default), start from the first result. |
int | null | $limit | Maximum number of results to return. Defaults to 10 |
MediaWiki\Extension\WikiLambda\ZObjectStore::findReferencedZObjectsByZFunctionIdAsList | ( | $zid, | |
$type ) |
Converts findReferencedZObjectsByZFunctionId into a list of zids.
string | $zid | the ZID of the ZFunction |
string | $type | the type of the ZFunction reference |
MediaWiki\Extension\WikiLambda\ZObjectStore::findRelatedZObjectsByKey | ( | $mainZid, | |
$key, | |||
$continue = null, | |||
$limit = 10 ) |
For the given main ZObject and key, return the related ZObjects.
Related ZObjects may be ZIDs or string encodings of compound ZObjects, such as "Z881(Z6)" for typed list of strings.
string | $mainZid | ZID of the main ZObject |
string | $key | ZID of the key that indicates the relationship |
string | null | $continue | Id to start. If null (the default), start from the first result. |
int | null | $limit | Maximum number of results to return. Defaults to 10 |
MediaWiki\Extension\WikiLambda\ZObjectStore::findRelatedZObjectsByKeyAsList | ( | $mainZid, | |
$key ) |
For the given main ZObject and key, return the related ZObjects.
Related ZObjects may be ZIDs or string encodings of compound ZObjects, such as "Z881(Z6)" for typed list of strings.
string | $mainZid | ZID of the main ZObject |
string | $key | ZID of the key that indicates the relationship |
MediaWiki\Extension\WikiLambda\ZObjectStore::findZLanguageFromCode | ( | string | $code | ) |
Gets from the secondary database the ZID of a given BCP47 (or MediaWiki) language code.
string | $code | The BCP47 (or MediaWiki) language code for which to search |
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.
string | $zid | |
string | $ztype | |
array | $labels | Array of labels, where the key is the language code and the value is the string representation of the label in that language |
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.
?string | $functionZID | The ZID of the ZFunction |
?int | $functionRevision | The revision ID of the ZFunction |
?string | $implementationZID | The ZID of the ZImplementation |
?int | $implementationRevision | The revision ID of the ZImplementation |
?string | $testerZID | The ZID of the ZTester |
?int | $testerRevision | The revision ID of the ZTester |
MediaWiki\Extension\WikiLambda\ZObjectStore::getNextAvailableZid | ( | ) |
Find next available ZID in the database to create a new ZObject.
MediaWiki\Extension\WikiLambda\ZObjectStore::getPreferredLabelsQuery | ( | $languageChain | ) |
Generates a query that filters to the preferred label in the labels table, depending on the user's language fallback chain passed as parameter.
string[] | $languageChain | List of language zids in order of preference |
MediaWiki\Extension\WikiLambda\ZObjectStore::getRevisionById | ( | int | $id | ) |
Load a page revision from a given revision ID number.
Returns null if no such revision can be found.
int | $id | Revision ID of this revision |
MediaWiki\Extension\WikiLambda\ZObjectStore::getTestStatusQuery | ( | ) |
Generates a query that returns a table with all the existing test objects, their function, and their status:
MediaWiki\Extension\WikiLambda\ZObjectStore::insertRelatedZObjects | ( | $relatedZObjects | ) |
Add a batch of rows to the database describing the relation between a main ZObject and a related one, given by the connecting key.
Example: [ 'Z401', 'Z8', 'Z8K2', 'Z881(Z6)', 'Z4' ] Indicates that the main object (Z401) of type function (Z8) has an output type (Z8K2) with value typed list of strings (Z881(Z6)) and type type (Z4)
array | $relatedZObjects | Array of rows to insert into the table. Each row must be an object with the non-empty properties zid, type, key, related_zid and related_type |
MediaWiki\Extension\WikiLambda\ZObjectStore::insertZFunctionReference | ( | $refId, | |
$zFunctionId, | |||
$type ) |
Add a record to the database for a given ZObject ID and ZFunction ID.
string | $refId | the ZObject ref ID |
string | $zFunctionId | the ZFunction ID |
string | $type | the type of the ZFunction reference |
MediaWiki\Extension\WikiLambda\ZObjectStore::insertZLanguageToLanguagesCache | ( | string | $zid, |
string | $languageCode ) |
Insert language code into the wikilambda_zlanguages database for a given ZID.
string | $zid | |
string | $languageCode |
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.
string | $zid | |
string | $ztype | |
array | $aliases | Set of labels, where the key is the language code and the value is an array of strings |
string | null | $returnType |
MediaWiki\Extension\WikiLambda\ZObjectStore::insertZObjectLabelConflicts | ( | $zid, | |
$conflicts ) |
Insert label conflicts into the wikilambda_zobject_label_conflicts database for a given ZID.
string | $zid | |
array | $conflicts | Array of labels, where the key is the language code and the value is the other ZID for which this label is repeated |
MediaWiki\Extension\WikiLambda\ZObjectStore::insertZObjectLabels | ( | $zid, | |
$ztype, | |||
$labels, | |||
$returnType = null ) |
Insert labels into the wikilambda_zobject_labels database for a given ZID and Type.
string | $zid | |
string | $ztype | |
array | $labels | Array 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 |
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.
string | $functionZID | The ZID of the ZFunction |
int | $functionRevision | The revision ID of the ZFunction |
string | $implementationZID | The ZID of the ZImplementation |
int | $implementationRevision | The revision ID of the ZImplementation |
string | $testerZID | The ZID of the ZTester |
int | $testerRevision | The revision ID of the ZTester |
bool | $testerResult | Whether the test run passed (true) or failed (false) |
string | $testerResponse | The test run response JSON object |
MediaWiki\Extension\WikiLambda\ZObjectStore::pushZObject | ( | string | $zid, |
string | $data, | ||
string | $summary ) |
Push a given Object into the Database, without validation.
string | $zid | |
string | $data | |
string | $summary |
Exception |
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.
string | $label | Term to search in the label database |
bool | $exact | Whether to search by exact match |
string[] | $languages | List of language Zids to filter by |
string | null | $type | Zid of the type to filter by. If null, don't filter by type. |
string | null | $returnType | Zid of the return type to filter by. If null, don't filter by return type. |
bool | $strictReturnType | Whether to exclude Z1s as return type. |
string | null | $continue | Id to start. If null, start from the first result. |
int | null | $limit | Maximum number of results to return. |
MediaWiki\Extension\WikiLambda\ZObjectStore::updateZObject | ( | MessageLocalizer | $context, |
string | $zid, | ||
string | $data, | ||
string | $summary, | ||
User | $user, | ||
int | $flags = EDIT_UPDATE ) |
Create or update a ZObject it in the Database.
MessageLocalizer | $context | The context of the action operation, for localisation of messages |
string | $zid | The ZID of the page to create/update, e.g. 'Z12345' |
string | $data | The ZObject's JSON to store, in string form, i.e. "{ Z1K1: "Z2", Z2K1: … }" |
string | $summary | An edit summary to display in the page's history, Recent Changes, watchlists, etc. |
User | $user | The user making the edit. |
int | $flags | Either EDIT_UPDATE (default) if editing or EDIT_NEW if creating a page |
MediaWiki\Extension\WikiLambda\ZObjectStore::updateZObjectAsSystemUser | ( | MessageLocalizer | $context, |
string | $zid, | ||
string | $data, | ||
string | $summary, | ||
int | $flags = EDIT_UPDATE ) |
Create or update a ZObject it in the Database as a System User.
MessageLocalizer | $context | The context of the action operation, for localisation of messages |
string | $zid | |
string | $data | |
string | $summary | |
int | $flags |