// Update the links tables and other secondary data
if ( $content ) {
- $updates = $content->getSecondaryDataUpdates( $this->getTitle(), null, true, $editInfo->output );
+ $recursive = $options['changed']; // bug 50785
+ $updates = $content->getSecondaryDataUpdates(
+ $this->getTitle(), null, $recursive, $editInfo->output );
DataUpdate::runUpdates( $updates );
}
}
DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
- DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) );
- // @todo let the search engine decide what to do with the content object
+ DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
// If this is another user's talk page, update newtalk.
// Don't do this if $options['changed'] = false (null-edits) nor if
return Status::newGood();
}
- // Only certain restrictions can cascade... Otherwise, users who cannot normally protect pages
- // could "protect" them by transcluding them on protected pages they are allowed to edit.
+ // Only certain restrictions can cascade...
$editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
+ foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
+ $editrestriction[$key] = 'editprotected'; // backwards compatibility
+ }
+ foreach ( array_keys( $editrestriction, 'autoconfirmed' ) as $key ) {
+ $editrestriction[$key] = 'editsemiprotected'; // backwards compatibility
+ }
$cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
- if ( in_array( 'sysop', $cascadingRestrictionLevels ) ) {
- $cascadingRestrictionLevels[] = 'protect'; // backwards compatibility
+ foreach ( array_keys( $cascadingRestrictionLevels, 'sysop' ) as $key ) {
+ $cascadingRestrictionLevels[$key] = 'editprotected'; // backwards compatibility
+ }
+ foreach ( array_keys( $cascadingRestrictionLevels, 'autoconfirmed' ) as $key ) {
+ $cascadingRestrictionLevels[$key] = 'editsemiprotected'; // backwards compatibility
}
// The schema allows multiple restrictions
/**
* Do some database updates after deletion
*
- * @param int $id page_id value of the page being deleted (B/C, currently unused)
+ * @param int $id page_id value of the page being deleted
* @param $content Content: optional page content to be used when determining the required updates.
* This may be needed because $this->getContent() may already return null when the page proper was deleted.
*/
// Reset this object and the Title object
$this->loadFromRow( false, self::READ_LATEST );
+
+ // Search engine
+ DeferredUpdates::addUpdate( new SearchUpdate( $id, $this->mTitle ) );
}
/**
function() use ( $dbw, $that, $method, $added, $deleted ) {
$ns = $that->getTitle()->getNamespace();
- // First make sure the rows exist. If one of the "deleted" ones didn't
- // exist, we might legitimately not create it, but it's simpler to just
- // create it and then give it a negative value, since the value is bogus
- // anyway.
- //
- // Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE.
- $insertCats = array_merge( $added, $deleted );
- if ( !$insertCats ) {
- // Okay, nothing to do
- return;
- }
-
- $insertRows = array();
- foreach ( $insertCats as $cat ) {
- $insertRows[] = array(
- 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ),
- 'cat_title' => $cat
- );
- }
- $dbw->insert( 'category', $insertRows, $method, 'IGNORE' );
-
$addFields = array( 'cat_pages = cat_pages + 1' );
$removeFields = array( 'cat_pages = cat_pages - 1' );
-
if ( $ns == NS_CATEGORY ) {
$addFields[] = 'cat_subcats = cat_subcats + 1';
$removeFields[] = 'cat_subcats = cat_subcats - 1';
$removeFields[] = 'cat_files = cat_files - 1';
}
- if ( $added ) {
- $dbw->update(
+ if ( count( $added ) ) {
+ $insertRows = array();
+ foreach ( $added as $cat ) {
+ $insertRows[] = array(
+ 'cat_title' => $cat,
+ 'cat_pages' => 1,
+ 'cat_subcats' => ( $ns == NS_CATEGORY ) ? 1 : 0,
+ 'cat_files' => ( $ns == NS_FILE ) ? 1 : 0,
+ );
+ }
+ $dbw->upsert(
'category',
+ $insertRows,
+ array( 'cat_title' ),
$addFields,
- array( 'cat_title' => $added ),
$method
);
}
- if ( $deleted ) {
+ if ( count( $deleted ) ) {
$dbw->update(
'category',
$removeFields,
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageAdded', array( $cat, $that ) );
}
+
foreach ( $deleted as $catName ) {
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageRemoved', array( $cat, $that ) );