$errors[] = [ 'confirmedittext' ];
}
- $useSlave = ( $rigor !== 'secure' );
- if ( ( $action == 'edit' || $action == 'create' )
- && !$user->isBlockedFrom( $this, $useSlave )
- ) {
- // Don't block the user from editing their own talk page unless they've been
- // explicitly blocked from that too.
- } elseif ( $user->isBlocked() && $user->getBlock()->prevents( $action ) !== false ) {
+ $useReplica = ( $rigor !== 'secure' );
+ $block = $user->getBlock( $useReplica );
+
+ // The block may explicitly allow an action (like "read" or "upload").
+ if ( $block && $block->prevents( $action ) === false ) {
+ return $errors;
+ }
+
+ // Determine if the user is blocked from this action on this page.
+ try {
// @todo FIXME: Pass the relevant context into this function.
- $errors[] = $user->getBlock()->getPermissionsError( RequestContext::getMain() );
+ $action = Action::factory( $action, WikiPage::factory( $this ), RequestContext::getMain() );
+ } catch ( Exception $e ) {
+ $action = null;
+ }
+
+ // If no action object is returned, assume that the action requires unblock
+ // which is the default.
+ if ( !$action || $action->requiresUnblock() ) {
+ if ( $user->isBlockedFrom( $this, $useReplica ) ) {
+ // @todo FIXME: Pass the relevant context into this function.
+ $errors[] = $block
+ ? $block->getPermissionsError( RequestContext::getMain() )
+ : [ 'badaccess-group0' ];
+ }
}
return $errors;
* Get the oldest revision timestamp of this page
*
* @param int $flags Title::GAID_FOR_UPDATE
- * @return string MW timestamp
+ * @return string|null MW timestamp
*/
public function getEarliestRevTime( $flags = 0 ) {
$rev = $this->getFirstRevision( $flags );
$dbw = wfGetDB( DB_MASTER );
$dbw->onTransactionPreCommitOrIdle(
- function () {
- ResourceLoaderWikiModule::invalidateModuleCache( $this, null, null, wfWikiID() );
+ function () use ( $dbw ) {
+ ResourceLoaderWikiModule::invalidateModuleCache(
+ $this, null, null, $dbw->getDomainId() );
},
__METHOD__
);