* (bug 34313) MediaWiki API intro message about "HTML format" should mention
the format parameter.
* (bug 32384) Allow descending order for list=watchlistraw
+* (bug 31883) Limit of bkusers of list=blocks and titles of action=query is not documented in API help
=== Languages updated in 1.20 ===
// It'll also vary slightly across different machines
$state = serialize( $_SERVER );
- // To try and vary the system information of the state a bit more
+ // To try vary the system information of the state a bit more
// by including the system's hostname into the state
$state .= wfHostname();
$files[] = dirname( dirname( __FILE__ ) );
// The config file is likely the most often edited file we know should be around
- // so if the constant with it's location is defined include it's stat info into the state
+ // so include its stat info into the state.
+ // The constant with its location will almost always be defined, as WebStart.php defines
+ // MW_CONFIG_FILE to $IP/LocalSettings.php unless being configured with MW_CONFIG_CALLBACK (eg. the installer)
if ( defined( 'MW_CONFIG_FILE' ) ) {
$files[] = MW_CONFIG_FILE;
}
+
foreach ( $files as $file ) {
wfSuppressWarnings();
$stat = stat( $file );
if ( strlen( $buffer ) < $bytes ) {
// If available make use of mcrypt_create_iv URANDOM source to generate randomness
// On unix-like systems this reads from /dev/urandom but does it without any buffering
- // and bypasses openbasdir restrictions so it's preferable to reading directly
+ // and bypasses openbasedir restrictions, so it's preferable to reading directly
// On Windows starting in PHP 5.3.0 Windows' native CryptGenRandom is used to generate
// entropy so this is also preferable to just trying to read urandom because it may work
// on Windows systems as well.
}
if ( strlen( $buffer ) < $bytes ) {
- // If available make use of openssl's random_pesudo_bytes method to attempt to generate randomness.
+ // If available make use of openssl's random_pseudo_bytes method to attempt to generate randomness.
// However don't do this on Windows with PHP < 5.3.4 due to a bug:
// http://stackoverflow.com/questions/1940168/openssl-random-pseudo-bytes-is-slow-php
+ // http://git.php.net/?p=php-src.git;a=commitdiff;h=cd62a70863c261b07f6dadedad9464f7e213cad5
if ( function_exists( 'openssl_random_pseudo_bytes' )
&& ( !wfIsWindows() || version_compare( PHP_VERSION, '5.3.4', '>=' ) )
) {
* Try to set a user's email address.
* This does *not* try to validate the address.
* Caller is responsible for checking $wgAuth.
+ *
+ * @deprecated in 1.20; use User::setEmailWithConfirmation() instead.
* @param $user User
* @param $newaddr string New email address
* @return Array (true on success or Status on failure, info string)
*/
public static function trySetUserEmail( User $user, $newaddr ) {
- global $wgEnableEmail, $wgEmailAuthentication;
- $info = ''; // none
+ wfDeprecated( __METHOD__, '1.20' );
- if ( $wgEnableEmail ) {
- $oldaddr = $user->getEmail();
- if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) {
- # The user has supplied a new email address on the login page
- # new behaviour: set this new emailaddr from login-page into user database record
- $user->setEmail( $newaddr );
- if ( $wgEmailAuthentication ) {
- # Mail a temporary password to the dirty address.
- # User can come back through the confirmation URL to re-enable email.
- $type = $oldaddr != '' ? 'changed' : 'set';
- $result = $user->sendConfirmationMail( $type );
- if ( !$result->isGood() ) {
- return array( $result, 'mailerror' );
- }
- $info = 'eauth';
- }
- } elseif ( $newaddr != $oldaddr ) { // if the address is the same, don't change it
- $user->setEmail( $newaddr );
- }
- if ( $oldaddr != $newaddr ) {
- wfRunHooks( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) );
- }
+ $result = $user->setEmailWithConfirmation( $newaddr );
+ if ( $result->isGood() ) {
+ return array( true, $result->value );
+ } else {
+ return array( $result, 'mailerror' );
}
-
- return array( true, $info );
}
/**
wfRunHooks( 'UserSetEmail', array( $this, &$this->mEmail ) );
}
+ /**
+ * Set the user's e-mail address and a confirmation mail if needed.
+ *
+ * @since 1.20
+ * @param $str String New e-mail address
+ * @return Status
+ */
+ public function setEmailWithConfirmation( $str ) {
+ global $wgEnableEmail, $wgEmailAuthentication;
+
+ if ( !$wgEnableEmail ) {
+ return Status::newFatal( 'emaildisabled' );
+ }
+
+ $oldaddr = $this->getEmail();
+ if ( $str === $oldaddr ) {
+ return Status::newGood( true );
+ }
+
+ $this->setEmail( $str );
+
+ if ( $str !== '' && $wgEmailAuthentication ) {
+ # Send a confirmation request to the new address if needed
+ $type = $oldaddr != '' ? 'changed' : 'set';
+ $result = $this->sendConfirmationMail( $type );
+ if ( $result->isGood() ) {
+ # Say the the caller that a confirmation mail has been sent
+ $status->value = 'eauth';
+ }
+ } else {
+ $result = Status::newGood( true );
+ }
+
+ return $result;
+ }
+
/**
* Get the user's real name
* @return String User's real name
$desc = implode( $paramPrefix, $desc );
}
+ //handle shorthand
if ( !is_array( $paramSettings ) ) {
$paramSettings = array(
self::PARAM_DFLT => $paramSettings,
);
}
- $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ?
- $paramSettings[self::PARAM_DEPRECATED] : false;
- if ( $deprecated ) {
+ //handle missing type
+ if ( !isset( $paramSettings[ApiBase::PARAM_TYPE] ) ) {
+ $dflt = isset( $paramSettings[ApiBase::PARAM_DFLT] ) ? $paramSettings[ApiBase::PARAM_DFLT] : null;
+ if ( is_bool( $dflt ) ) {
+ $paramSettings[ApiBase::PARAM_TYPE] = 'boolean';
+ } elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
+ $paramSettings[ApiBase::PARAM_TYPE] = 'string';
+ } elseif ( is_int( $dflt ) ) {
+ $paramSettings[ApiBase::PARAM_TYPE] = 'integer';
+ }
+ }
+
+ if ( isset( $paramSettings[self::PARAM_DEPRECATED] ) && $paramSettings[self::PARAM_DEPRECATED] ) {
$desc = "DEPRECATED! $desc";
}
- $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ?
- $paramSettings[self::PARAM_REQUIRED] : false;
- if ( $required ) {
+ if ( isset( $paramSettings[self::PARAM_REQUIRED] ) && $paramSettings[self::PARAM_REQUIRED] ) {
$desc .= $paramPrefix . "This parameter is required";
}
}
break;
}
+ }
- if ( isset( $paramSettings[self::PARAM_ISMULTI] ) ) {
- $isArray = is_array( $paramSettings[self::PARAM_TYPE] );
+ if ( isset( $paramSettings[self::PARAM_ISMULTI] ) && $paramSettings[self::PARAM_ISMULTI] ) {
+ $isArray = is_array( $type );
- if ( !$isArray
- || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
- $desc .= $paramPrefix . "Maximum number of values " .
- self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
- }
+ if ( !$isArray
+ || $isArray && count( $type ) > self::LIMIT_SML1 ) {
+ $desc .= $paramPrefix . "Maximum number of values " .
+ self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
}
}
- $default = is_array( $paramSettings )
- ? ( isset( $paramSettings[self::PARAM_DFLT] ) ? $paramSettings[self::PARAM_DFLT] : null )
- : $paramSettings;
+ $default = isset( $paramSettings[self::PARAM_DFLT] ) ? $paramSettings[self::PARAM_DFLT] : null;
if ( !is_null( $default ) && $default !== false ) {
$desc .= $paramPrefix . "Default: $default";
}
$text = htmlspecialchars( $text );
// encode all comments or tags as safe blue strings
- $text = preg_replace( '/\<(!--.*?--|.*?)\>/', '<span style="color:blue;"><\1></span>', $text );
+ $text = str_replace( '<', '<span style="color:blue;"><', $text );
+ $text = str_replace( '>', '></span>', $text );
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (" included in the URL)
LoginForm::clearLoginThrottle( $user->getName() );
}
- list( $status, $info ) = Preferences::trySetUserEmail( $user, $newaddr );
- if ( $status !== true ) {
- if ( $status instanceof Status ) {
- $this->getOutput()->addHTML(
- '<p class="error">' .
- $this->getOutput()->parseInline( $status->getWikiText( $info ) ) .
- '</p>' );
- }
+ $oldaddr = $user->getEmail();
+ $status = $user->setEmailWithConfirmation( $newaddr );
+ if ( !$status->isGood() ) {
+ $this->getOutput()->addHTML(
+ '<p class="error">' .
+ $this->getOutput()->parseInline( $status->getWikiText( $info ) ) .
+ '</p>' );
return false;
}
+ wfRunHooks( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) );
+
$user->saveSettings();
- return $info ? $info : true;
+
+ return $status->value;
}
}
$out->addHTML( "<ul>\n" );
foreach ( $result as $row ) {
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
- $link = Linker::linkKnown(
- $undelete,
- htmlspecialchars( $title->getPrefixedText() ),
- array(),
- array( 'target' => $title->getPrefixedText() )
- );
+ if ( $title !== null ) {
+ $item = Linker::linkKnown(
+ $undelete,
+ htmlspecialchars( $title->getPrefixedText() ),
+ array(),
+ array( 'target' => $title->getPrefixedText() )
+ );
+ } else {
+ // The title is no longer valid, show as text
+ $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+ $item = htmlspecialchars( $title->getPrefixedText() );
+ }
$revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse();
- $out->addHTML( "<li>{$link} ({$revs})</li>\n" );
+ $out->addHTML( "<li>{$item} ({$revs})</li>\n" );
}
$result->free();
$out->addHTML( "</ul>\n" );
'invalidemailaddress' => 'The e-mail address cannot be accepted as it appears to have an invalid format.
Please enter a well-formatted address or empty that field.',
'cannotchangeemail' => 'Account e-mail addresses cannot be changed on this wiki.',
+'emaildisabled' => 'This site cannot send e-mails.',
'accountcreated' => 'Account created',
'accountcreatedtext' => 'The user account for $1 has been created.',
'createaccount-title' => 'Account creation for {{SITENAME}}',
'emailconfirmlink' => 'Link to [[Special:ConfirmEmail]]. Appears in [[Special:Preferences]] > {{int:prefs-personal}} > {{int:email}} after saving your e-mail address but before it has been authenticated.',
'invalidemailaddress' => 'Shown as a warning when written an invalid e-mail adress in [[Special:Preferences]] and {{fullurl:Special:UserLogin|type=signup}} page',
'cannotchangeemail' => 'Error message shown when user goes to [[Special:ChangeEmail]] but email addresses cannot be changed on the site.',
+'emaildisabled' => 'Error message shown when user tries to set an e-mail address but e-mail features are disabled.',
'createaccount-title' => 'This is the subject of an e-mail sent to the e-mail address entered at [[Special:CreateAccount]] if the button "by e-mail" is clicked.',
'createaccount-text' => 'This text is sent as an e-mail to the e-mail address entered at [[Special:CreateAccount]] if the button "by e-mail" is clicked.
'emailconfirmlink',
'invalidemailaddress',
'cannotchangeemail',
+ 'emaildisabled',
'accountcreated',
'accountcreatedtext',
'createaccount-title',
}
}
+ /**
+ * This test has probably always been broken and use an invalid token
+ * Bug tracking brokenness is https://bugzilla.wikimedia.org/35646
+ *
+ * Root cause is https://gerrit.wikimedia.org/r/3434
+ * Which made the Block/Unblock API to actually verify the token
+ * previously always considered valid (bug 34212).
+ *
+ * @group Broken
+ */
function testMakeNormalBlock() {
$data = $this->getTokens();