Permissions: Exit early from RestrictionStore::loadRestrictions if no rev id
When a new page is created, MW checks if the page is "protected" from autopatrolling in the middle of its creation (WikiPage::doUserEditContent). At this point, there is no latest rev, but $page->getId() still returns something. This causes a warning in php8, along with some caching behaviour that's almost certainly wrong. Exit early when this happens. Bug: T313663 Change-Id: Iebaa536b1281588bf3db12d724f3d17f3d3b20e1
This commit is contained in:
parent
56105077fb
commit
4f89380816
1 changed files with 21 additions and 14 deletions
|
|
@ -389,21 +389,28 @@ class RestrictionStore {
|
|||
} else {
|
||||
$this->linkCache->addLinkObj( $page );
|
||||
$latestRev = $this->linkCache->getGoodLinkFieldObj( $page, 'revision' );
|
||||
$rows = $this->wanCache->getWithSetCallback(
|
||||
// Page protections always leave a new null revision
|
||||
$this->wanCache->makeKey( 'page-restrictions', 'v1', $id, $latestRev ),
|
||||
$this->wanCache::TTL_DAY,
|
||||
function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) {
|
||||
$dbr = $this->loadBalancer->getConnectionRef( DB_REPLICA );
|
||||
$setOpts += Database::getCacheSetOptions( $dbr );
|
||||
if ( $this->loadBalancer->hasOrMadeRecentPrimaryChanges() ) {
|
||||
// TODO: cleanup Title cache and caller assumption mess in general
|
||||
$ttl = WANObjectCache::TTL_UNCACHEABLE;
|
||||
}
|
||||
if ( !$latestRev ) {
|
||||
// This method can get called in the middle of page creation
|
||||
// (WikiPage::doUserEditContent) where a page might have an
|
||||
// id but no revisions, while checking the "autopatrol" permission.
|
||||
$rows = [];
|
||||
} else {
|
||||
$rows = $this->wanCache->getWithSetCallback(
|
||||
// Page protections always leave a new null revision
|
||||
$this->wanCache->makeKey( 'page-restrictions', 'v1', $id, $latestRev ),
|
||||
$this->wanCache::TTL_DAY,
|
||||
function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) {
|
||||
$dbr = $this->loadBalancer->getConnectionRef( DB_REPLICA );
|
||||
$setOpts += Database::getCacheSetOptions( $dbr );
|
||||
if ( $this->loadBalancer->hasOrMadeRecentPrimaryChanges() ) {
|
||||
// TODO: cleanup Title cache and caller assumption mess in general
|
||||
$ttl = WANObjectCache::TTL_UNCACHEABLE;
|
||||
}
|
||||
|
||||
return $loadRestrictionsFromDb( $dbr );
|
||||
}
|
||||
);
|
||||
return $loadRestrictionsFromDb( $dbr );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->loadRestrictionsFromRows( $page, $rows );
|
||||
|
|
|
|||
Loading…
Reference in a new issue