*
* DerivedPageDataUpdater instances are designed to be cached inside a WikiPage instance,
* and re-used by callback code over the course of an update operation. It's a stepping stone
- * one the way to a more complete refactoring of WikiPage.
+ * on the way to a more complete refactoring of WikiPage.
*
* When using a DerivedPageDataUpdater, the following life cycle must be observed:
* grabCurrentRevision (optional), prepareContent (optional), prepareUpdate (required
}
}
- /**
- * @return bool|string
- */
- private function getWikiId() {
- // TODO: get from RevisionStore
- return false;
- }
-
/**
* Checks whether this DerivedPageDataUpdater can be re-used for running updates targeting
* the given revision.
*/
public function isContentDeleted() {
if ( $this->revision ) {
- // XXX: if that revision is the current revision, this should be skipped
return $this->revision->isDeleted( RevisionRecord::DELETED_TEXT );
} else {
// If the content has not been saved yet, it cannot have been deleted yet.
* See DataUpdate::getCauseAction(). (default 'unknown')
* - causeAgent: name of the user who caused the update. See DataUpdate::getCauseAgent().
* (string, default 'unknown')
+ * - known-revision-output: a combined canonical ParserOutput for the revision, perhaps
+ * from some cache. The caller is responsible for ensuring that the ParserOutput indeed
+ * matched the $rev and $options. This mechanism is intended as a temporary stop-gap,
+ * for the time until caches have been changed to store RenderedRevision states instead
+ * of ParserOutput objects. (default: null) (since 1.33)
*/
public function prepareUpdate( RevisionRecord $revision, array $options = [] ) {
Assert::parameter(
if ( $this->renderedRevision ) {
$this->renderedRevision->updateRevision( $revision );
} else {
-
// NOTE: we want a canonical rendering, so don't pass $this->user or ParserOptions
// NOTE: the revision is either new or current, so we can bypass audience checks.
$this->renderedRevision = $this->revisionRenderer->getRenderedRevision(
$this->revision,
null,
null,
- [ 'use-master' => $this->useMaster(), 'audience' => RevisionRecord::RAW ]
+ [
+ 'use-master' => $this->useMaster(),
+ 'audience' => RevisionRecord::RAW,
+ 'known-revision-output' => $options['known-revision-output'] ?? null
+ ]
);
// XXX: Since we presumably are dealing with the current revision,
// TODO: In the wiring, register a listener for this on the new PageEventEmitter
ResourceLoaderWikiModule::invalidateModuleCache(
- $title, $oldLegacyRevision, $legacyRevision, $this->getWikiId() ?: wfWikiID()
+ $title,
+ $oldLegacyRevision,
+ $legacyRevision,
+ $this->loadbalancerFactory->getLocalDomainID()
);
$this->doTransition( 'done' );
return;
} elseif ( count( $promotions ) !== 0 ) {
+ $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
$promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n";
if ( $exists ) {
- $this->output( wfWikiID() . ": Promoting $promoText" );
+ $this->output( "$dbDomain: Promoting $promoText" );
} else {
- $this->output( wfWikiID() . ": Creating and promoting $promoText" );
+ $this->output( "$dbDomain: Creating and promoting $promoText" );
}
}
if ( !$exists ) {
# Increment site_stats.ss_users
- $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
+ $ssu = SiteStatsUpdate::factory( [ 'users' => 1 ] );
$ssu->doUpdate();
}
require_once __DIR__ . '/Maintenance.php';
use Wikimedia\Rdbms\IMaintainableDatabase;
+ use Wikimedia\Rdbms\DatabaseSqlite;
/**
* Maintenance script to run database schema updates.
$this->fatalError( $text );
}
- $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
+ $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
+ $this->output( "Going to run database updates for $dbDomain\n" );
if ( $db->getType() === 'sqlite' ) {
/** @var IMaintainableDatabase|DatabaseSqlite $db */
$this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" );
];
}
+ /**
+ * @throws FatalError
+ * @throws MWException
+ * @suppress PhanPluginDuplicateConditionalNullCoalescing
+ */
public function validateParamsAndArgs() {
// Allow extensions to add additional params.
$params = [];
Hooks::run( 'MaintenanceUpdateAddParams', [ &$params ] );
+
+ // This executes before the PHP version check, so don't use null coalesce (??).
+ // Keeping this compatible with older PHP versions lets us reach the code that
+ // displays a more helpful error.
foreach ( $params as $name => $param ) {
$this->addOption(
$name,
$param['desc'],
- $param['require'] ?? false,
- $param['withArg'] ?? false,
- $param['shortName'] ?? false,
- $param['multiOccurrence'] ?? false
+ isset( $param['require'] ) ? $param['require'] : false,
+ isset( $param['withArg'] ) ? $param['withArg'] : false,
+ isset( $param['shortName'] ) ? $param['shortName'] : false,
+ isset( $param['multiOccurrence'] ) ? $param['multiOccurrence'] : false
);
}