Change tags to apply to an edit can now be passed directly to the
WikiPage::doEditContent function. They are then passed to the
RecentChange::notifyNew/Edit functions where tagging is made
after the recent change is saved. This ensures that other callers
of doEditContent will not run into the same issue as T100248.
ApiRollback is fixed in this way.
In addition, we'll have to pass tags in this way for core tagging
of edits (I2e48bd458fc8d7c289f04dc276f9287516e0b987), and this makes
it possible to merge the arrays of tags and call ChangeTags::addTags
only once.
Change-Id: I829960c7a33b70464065839d7504d7529dfd0b72
public $contentFormat = null;
/** @var null|array */
public $contentFormat = null;
/** @var null|array */
- public $changeTags = null;
+ private $changeTags = null;
# Placeholders for text injection by hooks (must be HTML)
# extensions should take care to _append_ to the present value
# Placeholders for text injection by hooks (must be HTML)
# extensions should take care to _append_ to the present value
- $content->getDefaultFormat()
+ $content->getDefaultFormat(),
+ $this->changeTags
);
if ( !$doEditStatus->isOK() ) {
);
if ( !$doEditStatus->isOK() ) {
$this->updateWatchlist();
$this->updateWatchlist();
- if ( $this->changeTags && isset( $doEditStatus->value['revision'] ) ) {
- // If a revision was created, apply any change tags that were requested
- $addTags = $this->changeTags;
- $revId = $doEditStatus->value['revision']->getId();
- // Defer this both for performance and so that addTags() sees the rc_id
- // since the recentchange entry addition is deferred first (bug T100248)
- DeferredUpdates::addCallableUpdate( function() use ( $addTags, $revId ) {
- ChangeTags::addTags( $addTags, null, $revId );
- } );
- }
-
// If the content model changed, add a log entry
if ( $changingContentModel ) {
$this->addContentModelChangeLogEntry(
// If the content model changed, add a log entry
if ( $changingContentModel ) {
$this->addContentModelChangeLogEntry(
$token,
$params['markbot'],
$details,
$token,
$params['markbot'],
$details,
+ $user,
+ $params['tags']
// Watch pages
$this->setWatch( $watch, $titleObj, 'watchrollback' );
// Watch pages
$this->setWatch( $watch, $titleObj, 'watchrollback' );
- if ( count( $params['tags'] ) ) {
- ChangeTags::addTags( $params['tags'], null, intval( $details['newid'] ), null, null );
- }
-
$info = array(
'title' => $titleObj->getPrefixedText(),
'pageid' => intval( $details['current']->getPage() ),
$info = array(
'title' => $titleObj->getPrefixedText(),
'pageid' => intval( $details['current']->getPage() ),
* @param int $newSize
* @param int $newId
* @param int $patrol
* @param int $newSize
* @param int $newId
* @param int $patrol
* @return RecentChange
*/
public static function notifyEdit(
$timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
* @return RecentChange
*/
public static function notifyEdit(
$timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
- $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0
+ $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
+ $tags = array()
) {
$rc = new RecentChange;
$rc->mTitle = $title;
) {
$rc = new RecentChange;
$rc->mTitle = $title;
'pageStatus' => 'changed'
);
'pageStatus' => 'changed'
);
- DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+ DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
+ if ( count( $tags ) ) {
+ ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
+ $rc->mAttribs['rc_this_oldid'], null, null );
+ }
* @param int $size
* @param int $newId
* @param int $patrol
* @param int $size
* @param int $newId
* @param int $patrol
* @return RecentChange
*/
public static function notifyNew(
$timestamp, &$title, $minor, &$user, $comment, $bot,
* @return RecentChange
*/
public static function notifyNew(
$timestamp, &$title, $minor, &$user, $comment, $bot,
- $ip = '', $size = 0, $newId = 0, $patrol = 0
+ $ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = array()
) {
$rc = new RecentChange;
$rc->mTitle = $title;
) {
$rc = new RecentChange;
$rc->mTitle = $title;
'pageStatus' => 'created'
);
'pageStatus' => 'created'
);
- DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+ DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
+ if ( count( $tags ) ) {
+ ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
+ $rc->mAttribs['rc_this_oldid'], null, null );
+ }
* @param User $user The user doing the edit
* @param string $serialFormat Format for storing the content in the
* database.
* @param User $user The user doing the edit
* @param string $serialFormat Format for storing the content in the
* database.
+ * @param array|null $tags Change tags to apply to this edit
+ * Callers are responsible for permission checks
+ * (with ChangeTags::canAddTagsAccompanyingChange)
*
* @throws MWException
* @return Status Possible errors:
*
* @throws MWException
* @return Status Possible errors:
*/
public function doEditContent(
Content $content, $summary, $flags = 0, $baseRevId = false,
*/
public function doEditContent(
Content $content, $summary, $flags = 0, $baseRevId = false,
- User $user = null, $serialFormat = null
+ User $user = null, $serialFormat = null, $tags = null
) {
global $wgUser, $wgUseAutomaticEditSummaries;
) {
global $wgUser, $wgUseAutomaticEditSummaries;
'oldContent' => $old_content,
'oldId' => $this->getLatest(),
'oldIsRedirect' => $this->isRedirect(),
'oldContent' => $old_content,
'oldId' => $this->getLatest(),
'oldIsRedirect' => $this->isRedirect(),
- 'oldCountable' => $this->isCountable()
+ 'oldCountable' => $this->isCountable(),
+ 'tags' => ( $tags !== null ) ? (array)$tags : array()
);
// Actually create the revision and create/update the page
);
// Actually create the revision and create/update the page
$oldContent ? $oldContent->getSize() : 0,
$newsize,
$revisionId,
$oldContent ? $oldContent->getSize() : 0,
$newsize,
$revisionId,
+ $patrolled,
+ $meta['tags']
'',
$newsize,
$revisionId,
'',
$newsize,
$revisionId,
+ $patrolled,
+ $meta['tags']
* success : 'summary' (str), 'current' (rev), 'target' (rev)
*
* @param User $user The user performing the rollback
* success : 'summary' (str), 'current' (rev), 'target' (rev)
*
* @param User $user The user performing the rollback
+ * @param array|null $tags Change tags to apply to the rollback
+ * Callers are responsible for permission checks
+ * (with ChangeTags::canAddTagsAccompanyingChange)
+ *
* @return array Array of errors, each error formatted as
* array(messagekey, param1, param2, ...).
* On success, the array is empty. This array can also be passed to
* OutputPage::showPermissionsErrorPage().
*/
public function doRollback(
* @return array Array of errors, each error formatted as
* array(messagekey, param1, param2, ...).
* On success, the array is empty. This array can also be passed to
* OutputPage::showPermissionsErrorPage().
*/
public function doRollback(
- $fromP, $summary, $token, $bot, &$resultDetails, User $user
+ $fromP, $summary, $token, $bot, &$resultDetails, User $user, $tags = null
) {
$resultDetails = null;
) {
$resultDetails = null;
- return $this->commitRollback( $fromP, $summary, $bot, $resultDetails, $user );
+ return $this->commitRollback( $fromP, $summary, $bot, $resultDetails, $user, $tags );
*
* @param array $resultDetails Contains result-specific array of additional values
* @param User $guser The user performing the rollback
*
* @param array $resultDetails Contains result-specific array of additional values
* @param User $guser The user performing the rollback
+ * @param array|null $tags Change tags to apply to the rollback
+ * Callers are responsible for permission checks
+ * (with ChangeTags::canAddTagsAccompanyingChange)
+ *
- public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser ) {
+ public function commitRollback( $fromP, $summary, $bot,
+ &$resultDetails, User $guser, $tags = null
+ ) {
global $wgUseRCPatrol, $wgContLang;
$dbw = wfGetDB( DB_MASTER );
global $wgUseRCPatrol, $wgContLang;
$dbw = wfGetDB( DB_MASTER );
$summary,
$flags,
$target->getId(),
$summary,
$flags,
$target->getId(),
+ $guser,
+ null,
+ $tags
);
// Set patrolling and bot flag on the edits, which gets rollbacked.
);
// Set patrolling and bot flag on the edits, which gets rollbacked.