* able to set their password to this.
*
* @param string $password Desired password
+ * @param string $purpose one of 'login', 'create', 'reset'
* @return Status
* @since 1.23
*/
- public function checkPasswordValidity( $password ) {
+ public function checkPasswordValidity( $password, $purpose = 'login' ) {
global $wgPasswordPolicy;
$upp = new UserPasswordPolicy(
}
if ( $result === false ) {
- $status->merge( $upp->checkUserPassword( $this, $password ) );
+ $status->merge( $upp->checkUserPassword( $this, $password, $purpose ) );
return $status;
} elseif ( $result === true ) {
return $status;
return;
}
- $nextid = $oldid ? $title->getNextRevisionID( $oldid ) : null;
+ $that = $this;
+ // Try to update the DB post-send and only if needed...
+ DeferredUpdates::addCallableUpdate( function() use ( $that, $title, $oldid ) {
+ if ( !$that->getNewtalk() ) {
+ return; // no notifications to clear
+ }
- if ( !$oldid || !$nextid ) {
- // If we're looking at the latest revision, we should definitely clear it
- $this->setNewtalk( false );
- } else {
- // Otherwise we should update its revision, if it's present
- if ( $this->getNewtalk() ) {
- // Naturally the other one won't clear by itself
- $this->setNewtalk( false );
- $this->setNewtalk( true, Revision::newFromId( $nextid ) );
+ // Delete the last notifications (they stack up)
+ $that->setNewtalk( false );
+
+ // If there is a new, unseen, revision, use its timestamp
+ $nextid = $oldid
+ ? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE )
+ : null;
+ if ( $nextid ) {
+ $that->setNewtalk( true, Revision::newFromId( $nextid ) );
}
- }
+ } );
}
if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
$this->clearSharedCache();
// User was changed in the meantime or loaded with stale data
$from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'slave';
- MWExceptionHandler::logException( new MWException(
+ throw new MWException(
"CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
"the version of the user to be saved is older than the current version."
- ) );
-
- return;
+ );
}
$this->mTouched = $newTouched;
: wfGetDB( DB_SLAVE );
$options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
- ? array( 'FOR UPDATE' )
+ ? array( 'LOCK IN SHARE MODE' )
: array();
- $id = $db->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__, $options );
- if ( $id === false ) {
- $id = 0;
- }
+ $id = $db->selectField( 'user',
+ 'user_id', array( 'user_name' => $s ), __METHOD__, $options );
- return $id;
+ return (int)$id;
}
/**
return true;
} elseif ( $wgAuth->strict() ) {
// Auth plugin doesn't allow local authentication
- wfDebugLog( 'AuthPluginStrict', "Authentication denied for {$this->getName()}" );
return false;
} elseif ( $wgAuth->strictUserAuth( $this->getName() ) ) {
// Auth plugin doesn't allow local authentication for this user name