}
if ( !$data ) {
- wfDebug( "Cache miss for user {$this->mId}\n" );
+ wfDebug( "User: cache miss for user {$this->mId}\n" );
# Load from DB
if ( !$this->loadFromDatabase() ) {
# Can't load from ID, user is anonymous
}
$this->saveToCache();
} else {
- wfDebug( "Got user {$this->mId} from cache\n" );
+ wfDebug( "User: got user {$this->mId} from cache\n" );
# Restore from cache
foreach ( self::$mCacheVars as $name ) {
$this->$name = $data[$name];
* @return mixed: true on success, string of error message on failure
*/
function getPasswordValidity( $password ) {
- global $wgMinimalPasswordLength, $wgContLang;
+ global $wgMinimalPasswordLength, $wgWeakPasswords, $wgContLang;
$result = false; //init $result to false for the internal checks
if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) )
return $result;
+ $lcPassword = $wgContLang->lc( $password );
+
if ( $result === false ) {
if( strlen( $password ) < $wgMinimalPasswordLength ) {
return 'passwordtooshort';
- } elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
+ } elseif ( $lcPassword == $wgContLang->lc( $this->mName ) ) {
return 'password-name-match';
+ } elseif ( in_array( $lcPassword, $wgWeakPasswords ) ) {
+ return 'password-too-weak';
} else {
//it seems weird returning true here, but this is because of the
//initialization of $result to false above. If the hook is never run or it
if( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
return $result;
}
+ $rfc5322_atext = "a-z0-9!#$%&'*+-\/=?^_`{|}—~" ;
+ $rfc1034_ldh_str = "a-z0-9-" ;
+
+ $HTML5_email_regexp = "/
+ ^ # start of string
+ [$rfc5322_atext\\.]+ # user part which is liberal :p
+ @ # 'apostrophe'
+ [$rfc1034_ldh_str]+ # First domain part
+ (\\.[$rfc1034_ldh_str]+)+ # Following part prefixed with a dot
+ $ # End of string
+ /ix" ; // case Insensitive, eXtended
- return strpos( $addr, '@' ) !== false;
+ return (bool) preg_match( $HTML5_email_regexp, $addr );
}
/**
}
# Reject various classes of invalid names
- $name = $t->getText();
global $wgAuth;
$name = $wgAuth->getCanonicalName( $t->getText() );
if ( ( $sName == $this->mName ) && $passwordCorrect ) {
$_SESSION['wsToken'] = $this->mToken;
- wfDebug( "Logged in from $from\n" );
+ wfDebug( "User: logged in from $from\n" );
return true;
} else {
# Invalid credentials
- wfDebug( "Can't log in from $from, invalid credentials\n" );
+ wfDebug( "User: can't log in from $from, invalid credentials\n" );
$this->loadDefaults();
return false;
}
/**
* default language setting
*/
- $variant = $wgContLang->getPreferredVariant( false );
+ $variant = $wgContLang->getDefaultVariant();
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
$skin->setTitle( $t );
return $skin;
} else {
- if ( ! $this->mSkin ) {
+ if ( !$this->mSkin ) {
$this->mSkin = $this->createSkinObject();
}
-
- if ( ! $this->mSkin->getTitle() ) {
+
+ if ( !$this->mSkin->getTitle() ) {
global $wgOut;
$t = $wgOut->getTitle();
$this->mSkin->setTitle($t);
}
-
+
return $this->mSkin;
}
}
global $wgHiddenPrefs;
if( !in_array( 'skin', $wgHiddenPrefs ) ) {
- # get the user skin
global $wgRequest;
+ # get the user skin
$userSkin = $this->getOption( 'skin' );
$userSkin = $wgRequest->getVal( 'useskin', $userSkin );
} else {
* which will give them a chance to modify this key based on their own
* settings.
*
+ * @deprecated use the ParserOptions object to get the relevant options
* @return \string Page rendering hash
*/
function getPageRenderingHash() {
if( $this->mHash ){
return $this->mHash;
}
+ wfDeprecated( __METHOD__ );
// stubthreshold is only included below for completeness,
// since it disables the parser cache, its value will always
*/
function sendMail( $subject, $body, $from = null, $replyto = null ) {
if( is_null( $from ) ) {
- global $wgPasswordSender;
- $from = $wgPasswordSender;
+ global $wgPasswordSender, $wgPasswordSenderName;
+ $sender = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
+ } else {
+ $sender = new MailAddress( $from );
}
$to = new MailAddress( $this );
- $sender = new MailAddress( $from );
return UserMailer::send( $to, $sender, $subject, $body, $replyto );
}
// Maybe load from the object
if ( !is_null( $this->mOptionOverrides ) ) {
- wfDebug( "Loading options for user " . $this->getId() . " from override cache.\n" );
+ wfDebug( "User: loading options for user " . $this->getId() . " from override cache.\n" );
foreach( $this->mOptionOverrides as $key => $value ) {
$this->mOptions[$key] = $value;
}
} else {
- wfDebug( "Loading options for user " . $this->getId() . " from database.\n" );
+ wfDebug( "User: loading options for user " . $this->getId() . " from database.\n" );
// Load from database
$dbr = wfGetDB( DB_SLAVE );