diff options
author | thiemowmde <thiemo.kreuz@wikimedia.de> | 2024-07-07 16:30:26 +0200 |
---|---|---|
committer | thiemowmde <thiemo.kreuz@wikimedia.de> | 2024-07-07 16:30:26 +0200 |
commit | ef7faa2b828d13a8aaec044a217d3d51c2caceb6 (patch) | |
tree | d09d4d2a920477e6d29417fcb32304da5909268f /includes/api/ApiPageSet.php | |
parent | 599c35f586a98b52a878b16db7b79d349fb1ecfb (diff) | |
download | mediawikicore-ef7faa2b828d13a8aaec044a217d3d51c2caceb6.tar.gz mediawikicore-ef7faa2b828d13a8aaec044a217d3d51c2caceb6.zip |
api: Fix incomplete docs for ApiPageSet::$mRequestedPageFields
Unfortunately Phan gets super confused here, which is why I had to
split this off from I454baef. While it might be possible to silence
Phan I think the better solution is to get rid of the problematic
null initialization. The null is never used for anything, anywhere.
The contrary. In ApiPageSet::processDbRow() the null values are
accessed with an array operator as if they are arrays, which
(currently) forces PHP to silently initialize it to actually be
an empty array. Instead I suggest to make this magic behavior
explicitely visible.
Change-Id: If7c4f49e46cc6050942611a7b2bca46ea550b31c
Diffstat (limited to 'includes/api/ApiPageSet.php')
-rw-r--r-- | includes/api/ApiPageSet.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index dc440527d00b..d4347ce47d91 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -154,7 +154,7 @@ class ApiPageSet extends ApiBase { /** @var string */ private $mCacheMode = 'public'; - /** @var array */ + /** @var array<string,array<int,mixed>> [fieldName][pageId] => value */ private $mRequestedPageFields = []; /** @var int */ @@ -386,17 +386,17 @@ class ApiPageSet extends ApiBase { /** * Request an additional field from the page table. * Must be called before execute() - * @param string $fieldName + * @param string $fieldName A page table field, e.g. "page_touched" */ public function requestField( $fieldName ) { - $this->mRequestedPageFields[$fieldName] = null; + $this->mRequestedPageFields[$fieldName] = []; } /** - * Get the value of a custom field previously requested through - * requestField() - * @param string $fieldName - * @return mixed Field value + * Get the values of one of the previously requested page table fields. Can only be used + * after execute() and only for fields previously requested through requestField(). + * @param string $fieldName A page table field, e.g. "page_touched" + * @return array<int,mixed> Field values per page id, initialized only after execute() */ public function getCustomField( $fieldName ) { return $this->mRequestedPageFields[$fieldName]; |