} elseif ( $this->section == 'new' ) {
// Nothing *to* preview for new sections
return false;
- } elseif ( ( $request->getVal( 'preload' ) !== null || $this->mTitle->exists() )
+ } elseif ( ( $request->getCheck( 'preload' ) || $this->mTitle->exists() )
&& $this->context->getUser()->getOption( 'previewonfirst' )
) {
// Standard preference behavior
$this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
- if ( $this->textbox1 === '' && $request->getVal( 'wpTextbox1' ) === null ) {
+ if ( $this->textbox1 === '' && !$request->getCheck( 'wpTextbox1' ) ) {
// wpTextbox1 field is missing, possibly due to being "too big"
// according to some filter rules such as Suhosin's setting for
// suhosin.request.max_value_length (d'oh)
if ( $request->getVal( 'action', 'view' ) != 'view'
|| $request->wasPosted()
- || ( $request->getVal( 'title' ) !== null
+ || ( $request->getCheck( 'title' )
&& $title->getPrefixedDBkey() == $request->getVal( 'title' ) )
|| count( $request->getValueNames( [ 'action', 'title' ] ) )
|| !Hooks::run( 'TestCanonicalRedirect', [ $request, $title, $output ] )
private $tableCache = null;
/** @var bool|string */
- private $wikiId = false;
+ private $domain = false;
/** @var int */
private $cacheTTL;
* @param string $nameField
* @param callable|null $normalizationCallback Normalization to be applied to names before being
* saved or queried. This should be a callback that accepts and returns a single string.
- * @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki.
+ * @param bool|string $dbDomain Database domain ID. Use false for the local database domain.
* @param callable|null $insertCallback Callback to change insert fields accordingly.
* This parameter was introduced in 1.32
*/
$idField,
$nameField,
callable $normalizationCallback = null,
- $wikiId = false,
+ $dbDomain = false,
callable $insertCallback = null
) {
$this->loadBalancer = $dbLoadBalancer;
$this->idField = $idField;
$this->nameField = $nameField;
$this->normalizationCallback = $normalizationCallback;
- $this->wikiId = $wikiId;
+ $this->domain = $dbDomain;
$this->cacheTTL = IExpiringStore::TTL_MONTH;
$this->insertCallback = $insertCallback;
}
* @return IDatabase
*/
private function getDBConnection( $index, $flags = 0 ) {
- return $this->loadBalancer->getConnection( $index, [], $this->wikiId, $flags );
+ return $this->loadBalancer->getConnection( $index, [], $this->domain, $flags );
}
/**
return $this->cache->makeGlobalKey(
'NameTableSqlStore',
$this->table,
- $this->loadBalancer->resolveDomainID( $this->wikiId )
+ $this->loadBalancer->resolveDomainID( $this->domain )
);
}
$request = $this->getRequest();
// JSONP mode
- if ( $request->getVal( 'callback' ) !== null ) {
+ if ( $request->getCheck( 'callback' ) ) {
$this->lacksSameOriginSecurity = true;
return true;
}
$params = $this->extractRequestParams();
$user = $this->getUser();
- if ( $user->isBlocked() ) {
+ $block = $user->getBlock();
+ if ( $block && $block->isSitewide() ) {
$this->dieBlocked( $user->getBlock() );
}
// Fetch the value in either one of the two following case:
// - we have a valid submit attempt (form was just submitted)
// - we have a value (an URL manually built by the user, or GET form with no wpFormIdentifier)
- if ( $this->isSubmitAttempt( $request ) || $request->getVal( $this->mName ) !== null ) {
+ if ( $this->isSubmitAttempt( $request ) || $request->getCheck( $this->mName ) ) {
return $invert
? !$request->getBool( $this->mName )
: $request->getBool( $this->mName );
protected $title;
/** @var bool Expensive jobs may set this to true */
- protected $removeDuplicates;
+ protected $removeDuplicates = false;
/** @var string Text for error that occurred last */
protected $error;
* Create the appropriate object to handle a specific job
*
* @param string $command Job command
- * @param Title $title Associated title
* @param array $params Job parameters
* @throws InvalidArgumentException
* @return Job
*/
- public static function factory( $command, Title $title, $params = [] ) {
+ public static function factory( $command, $params = [] ) {
global $wgJobClasses;
+ if ( $params instanceof Title ) {
+ // Backwards compatibility for old signature ($command, $title, $params)
+ $title = $params;
+ $params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
+ } else {
+ // Subclasses can override getTitle() to return something more meaningful
+ $title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
+ }
+
if ( isset( $wgJobClasses[$command] ) ) {
$handler = $wgJobClasses[$command];
if ( $job instanceof Job ) {
$job->command = $command;
+
return $job;
} else {
- throw new InvalidArgumentException( "Cannot instantiate job '$command': bad spec!" );
+ throw new InvalidArgumentException( "Could instantiate job '$command': bad spec!" );
}
}
/**
* @param string $command
- * @param Title $title
- * @param array|bool $params Can not be === true
+ * @param array $params
*/
- public function __construct( $command, $title, $params = false ) {
+ public function __construct( $command, $params = [] ) {
+ if ( $params instanceof Title ) {
+ // Backwards compatibility for old signature ($command, $title, $params)
+ $title = $params;
+ $params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
+ } else {
+ // Subclasses can override getTitle() to return something more meaningful
+ $title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
+ }
+
$this->command = $command;
$this->title = $title;
$this->params = is_array( $params ) ? $params : []; // sanity
-
- // expensive jobs may set this to true
- $this->removeDuplicates = false;
-
if ( !isset( $this->params['requestId'] ) ) {
$this->params['requestId'] = WebRequest::getRequestId();
}
* @since 1.31
*/
public function hasExecutionFlag( $flag ) {
- return ( $this->executionFlags && $flag ) === $flag;
+ return ( $this->executionFlags & $flag ) === $flag;
}
/**
$this->type = $type;
$this->params = $params;
- $this->title = $title ?: Title::makeTitle( NS_SPECIAL, 'Badtitle/' . static::class );
+ $this->title = $title ?: Title::makeTitle( NS_SPECIAL, 'Blankpage' );
$this->opts = $opts;
}
!( isset( $params['pages'] ) && count( $params['pages'] ) != 1 )
);
$this->params += [ 'causeAction' => 'unknown', 'causeAgent' => 'unknown' ];
+ // This will control transaction rounds in order to run DataUpdates
+ $this->executionFlags |= self::JOB_NO_EXPLICIT_TRX_ROUND;
}
/**
$renderer = $services->getRevisionRenderer();
$ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
+ $lbFactory->beginMasterChanges( __METHOD__ );
+
$page = WikiPage::factory( $title );
$page->loadPageData( WikiPage::READ_LATEST );
$options['triggeringUser'] = User::newFromName( $userInfo['userName'], false );
}
}
+
+ $lbFactory->commitMasterChanges( __METHOD__ );
+
$page->doSecondaryDataUpdates( $options );
InfoAction::invalidateCache( $title );
$this->load();
// TODO: This performs database actions on GET request, which is going to
// be a problem for our multi-datacenter work.
- if ( !is_null( $request->getVal( 'nsRemember' ) ) ) {
+ if ( $request->getCheck( 'nsRemember' ) ) {
$this->saveNamespaces();
// Remove the token from the URL to prevent the user from inadvertently
// exposing it (e.g. by pasting it into a public wiki page) or undoing
}
$this->searchEngineType = $request->getVal( 'srbackend' );
- if (
- !$request->getVal( 'fulltext' ) &&
- $request->getVal( 'offset' ) === null
- ) {
+ if ( !$request->getVal( 'fulltext' ) && !$request->getCheck( 'offset' ) ) {
$url = $this->goResult( $term );
if ( $url !== null ) {
// successful 'go'
$this->mUnsuppress = $request->getVal( 'wpUnsuppress' ) && $user->isAllowed( 'suppressrevision' );
$this->mToken = $request->getVal( 'token' );
- if ( $this->isAllowed( 'undelete' ) && !$user->isBlocked() ) {
+ $block = $user->getBlock();
+ if ( $this->isAllowed( 'undelete' ) && !( $block && $block->isSitewide() ) ) {
$this->mAllowed = true; // user can restore
$this->mCanView = true; // user can view content
} elseif ( $this->isAllowed( 'deletedtext' ) ) {
$session = array();
}
- if ( $request->getVal( 'uselang' ) !== null ) {
+ if ( $request->getCheck( 'uselang' ) ) {
$langCode = $request->getVal( 'uselang' );
} elseif ( isset( $session['settings']['_UserLang'] ) ) {
$langCode = $session['settings']['_UserLang'];
[
'page',
'revision',
+ 'comment',
'ip_changes',
'text',
'archive',
$this->setService( 'MainWANObjectCache', $cache );
$db = wfGetDB( DB_MASTER );
+ $now = 1553893742;
+ $cache->setMockTime( $now );
+
// Get a fresh revision to use during testing
$this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
$rev = $this->testPage->getRevision();
$cache->delete( $key, WANObjectCache::HOLDOFF_NONE );
$this->assertFalse( $cache->get( $key ) );
+ ++$now;
+
// Get the new revision and make sure it is in the cache and correct
$newRev = Revision::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
$this->assertRevEquals( $rev, $newRev );