* @param string $interwiki The interwiki prefix
* @return Title The new object
*/
- public static function &makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) {
+ public static function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) {
$t = new Title();
$t->mInterwiki = $interwiki;
$t->mFragment = $fragment;
* @return array List of errors
*/
private function checkUserBlock( $action, $user, $errors, $rigor, $short ) {
+ global $wgEmailConfirmToEdit, $wgBlockDisablesLogin;
// Account creation blocks handled at userlogin.
// Unblocking handled in SpecialUnblock
if ( $rigor === 'quick' || in_array( $action, [ 'createaccount', 'unblock' ] ) ) {
return $errors;
}
- global $wgEmailConfirmToEdit;
+ // Optimize for a very common case
+ if ( $action === 'read' && !$wgBlockDisablesLogin ) {
+ return $errors;
+ }
if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() ) {
$errors[] = [ 'confirmedittext' ];
# If the user is allowed to read pages, he is allowed to read all pages
$whitelisted = true;
} elseif ( $this->isSpecial( 'Userlogin' )
- || $this->isSpecial( 'ChangePassword' )
|| $this->isSpecial( 'PasswordReset' )
+ || $this->isSpecial( 'Userlogout' )
) {
# Always grant access to the login page.
# Even anons need to be able to log in.
$checks = [
'checkPermissionHooks',
'checkReadPermissions',
+ 'checkUserBlock', // for wgBlockDisablesLogin
];
# Don't call checkSpecialsAndNSPermissions or checkCSSandJSPermissions
# here as it will lead to duplicate error messages. This is okay to do
return true; // avoid gap locking if we know it's not there
}
- $method = __METHOD__;
- $dbw = wfGetDB( DB_MASTER );
$conds = $this->pageCond();
- $dbw->onTransactionIdle( function () use ( $dbw, $conds, $method, $purgeTime ) {
- $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() );
- $dbw->update(
- 'page',
- [ 'page_touched' => $dbTimestamp ],
- $conds + [ 'page_touched < ' . $dbw->addQuotes( $dbTimestamp ) ],
- $method
- );
- } );
+ DeferredUpdates::addUpdate(
+ new AutoCommitUpdate(
+ wfGetDB( DB_MASTER ),
+ __METHOD__,
+ function ( IDatabase $dbw, $fname ) use ( $conds, $purgeTime ) {
+ $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() );
+ $dbw->update(
+ 'page',
+ [ 'page_touched' => $dbTimestamp ],
+ $conds + [ 'page_touched < ' . $dbw->addQuotes( $dbTimestamp ) ],
+ $fname
+ );
+ }
+ ),
+ DeferredUpdates::PRESEND
+ );
return true;
}