* Add row to the redirect table if this is a redirect, remove otherwise.
*
* @param IDatabase $dbw
- * @param Title $redirectTitle Title object pointing to the redirect target,
+ * @param Title|null $redirectTitle Title object pointing to the redirect target,
* or NULL if this is not a redirect
* @param null|bool $lastRevIsRedirect If given, will optimize adding and
* removing rows in redirect table.
$old_revision = $this->getRevision(); // current revision
$old_content = $this->getContent( Revision::RAW ); // current revision's content
- if ( $old_content && $old_content->getModel() !== $content->getModel() ) {
- $tags[] = 'mw-contentmodelchange';
+ $handler = $content->getContentHandler();
+ $tag = $handler->getChangeTag( $old_content, $content, $flags );
+ // If there is no applicable tag, null is returned, so we need to check
+ if ( $tag ) {
+ $tags[] = $tag;
}
- // Provide autosummaries if one is not provided and autosummaries are enabled
+ // Check for undo tag
+ if ( $undidRevId !== 0 && in_array( 'mw-undo', ChangeTags::getSoftwareTags() ) ) {
+ $tags[] = 'mw-undo';
+ }
+
+ // Provide autosummaries if summary is not provided and autosummaries are enabled
if ( $wgUseAutomaticEditSummaries && ( $flags & EDIT_AUTOSUMMARY ) && $summary == '' ) {
- $handler = $content->getContentHandler();
$summary = $handler->getAutosummary( $old_content, $content, $flags );
}
$targetContent = $target->getContent();
$changingContentModel = $targetContent->getModel() !== $current->getContentModel();
+ if ( in_array( 'mw-rollback', ChangeTags::getSoftwareTags() ) ) {
+ $tags[] = 'mw-rollback';
+ }
+
// Actually store the edit
$status = $this->doEditContent(
$targetContent,
'summary' => $summary,
'current' => $current,
'target' => $target,
- 'newid' => $revId
+ 'newid' => $revId,
+ 'tags' => $tags
];
return [];