* @return bool
*/
public function isRedirect() {
- $content = $this->getContent();
- if ( !$content ) {
- return false;
+ if ( !$this->mDataLoaded ) {
+ $this->loadPageData();
}
- return $content->isRedirect();
+ return (bool)$this->mIsRedirect;
}
/**
if ( $rt->isExternal() ) {
if ( $rt->isLocal() ) {
// Offsite wikis need an HTTP redirect.
- //
// This can be hard to reverse and may produce loops,
// so they may be disabled in the site configuration.
$source = $this->mTitle->getFullURL( 'redirect=no' );
if ( $rt->isSpecialPage() ) {
// Gotta handle redirects to special pages differently:
- // Fill the HTTP response "Location" header and ignore
- // the rest of the page we're on.
- //
- // Some pages are not valid targets
+ // Fill the HTTP response "Location" header and ignore the rest of the page we're on.
+ // Some pages are not valid targets.
if ( $rt->isValidRedirectTarget() ) {
return $rt->getFullURL();
} else {
) {
ContentHandler::deprecated( __METHOD__, '1.21' );
- //NOTE: keep condition in sync with condition in replaceSectionContent!
+ // NOTE: keep condition in sync with condition in replaceSectionContent!
if ( strval( $sectionId ) === '' ) {
// Whole-page edit; let the whole text through
return $text;
}
$revisionId = $revision->insertOn( $dbw );
- // Update page
- //
+ // Update page.
// We check for conflicts by comparing $oldid with the current latest revision ID.
$ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
}
$user = is_null( $user ) ? $wgUser : $user;
- //XXX: check $user->getId() here???
+ // XXX: check $user->getId() here???
// Use a sane default for $serialFormat, see bug 57026
if ( $serialFormat === null ) {
$logRelationsValues = array();
$logRelationsField = null;
+ $logParamsDetails = array();
if ( $id ) { // Protection of existing page
if ( !Hooks::run( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
__METHOD__
);
if ( $restrictions != '' ) {
+ $cascadeValue = ( $cascade && $action == 'edit' ) ? 1 : 0;
$dbw->insert(
'page_restrictions',
array(
'pr_page' => $id,
'pr_type' => $action,
'pr_level' => $restrictions,
- 'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
+ 'pr_cascade' => $cascadeValue,
'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] )
),
__METHOD__
);
$logRelationsValues[] = $dbw->insertId();
+ $logParamsDetails[] = array(
+ 'type' => $action,
+ 'level' => $restrictions,
+ 'expiry' => $expiry[$action],
+ 'cascade' => (bool)$cascadeValue,
+ );
}
}
'pt_reason' => $reason,
), __METHOD__
);
+ $logParamsDetails[] = array(
+ 'type' => 'create',
+ 'level' => $limit['create'],
+ 'expiry' => $expiry['create'],
+ );
} else {
$dbw->delete( 'protected_titles',
array(
$params = array();
} else {
$protectDescriptionLog = $this->protectDescriptionLog( $limit, $expiry );
- $params = array( $protectDescriptionLog, $cascade ? 'cascade' : '' );
+ $params = array(
+ '4::description' => $protectDescriptionLog, // parameter for IRC
+ '5:bool:cascade' => $cascade,
+ 'details' => $logParamsDetails, // parameter for localize and api
+ );
}
// Update the protection log
- $log = new LogPage( 'protect' );
- $logId = $log->addEntry( $logAction, $this->mTitle, $reason, $params, $user );
+ $logEntry = new ManualLogEntry( 'protect', $logAction );
+ $logEntry->setTarget( $this->mTitle );
+ $logEntry->setComment( $reason );
+ $logEntry->setPerformer( $user );
+ $logEntry->setParameters( $params );
if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
- $log->addRelations( $logRelationsField, $logRelationsValues, $logId );
+ $logEntry->setRelations( array( $logRelationsField => $logRelationsValues ) );
}
+ $logId = $logEntry->insert();
+ $logEntry->publish( $logId );
return Status::newGood();
}
$bitfield = 'rev_deleted';
}
- // For now, shunt the revision data into the archive table.
- // Text is *not* removed from the text table; bulk storage
- // is left intact to avoid breaking block-compression or
- // immutable storage schemes.
- //
- // For backwards compatibility, note that some older archive
- // table entries will have ar_text and ar_flags fields still.
- //
- // In the future, we may keep revisions and mark them with
- // the rev_deleted field, which is reserved for this purpose.
+ /**
+ * For now, shunt the revision data into the archive table.
+ * Text is *not* removed from the text table; bulk storage
+ * is left intact to avoid breaking block-compression or
+ * immutable storage schemes.
+ *
+ * For backwards compatibility, note that some older archive
+ * table entries will have ar_text and ar_flags fields still.
+ *
+ * In the future, we may keep revisions and mark them with
+ * the rev_deleted field, which is reserved for this purpose.
+ */
$row = array(
'ar_namespace' => 'page_namespace',
* may already return null when the page proper was deleted.
*/
public function doDeleteUpdates( $id, Content $content = null ) {
- // update site status
+ // Update site status
DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) );
- // remove secondary indexes, etc
+ // Delete pagelinks, update secondary indexes, etc
$updates = $this->getDeletionUpdates( $content );
- DataUpdate::runUpdates( $updates, 'enqueue' );
+ // Make sure an enqueued jobs run after commit so they see the deletion
+ wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $updates ) {
+ DataUpdate::runUpdates( $updates, 'enqueue' );
+ } );
// Reparse any pages transcluding this page
LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );