r31459 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31458‎ | r31459 | r31460 >
Date:19:00, 2 March 2008
Author:catrope
Status:old
Tags:
Comment:
API: Added watch and unwatch parameters to action=move and action=delete
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMove.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMove.php
@@ -86,7 +86,7 @@
8787 $this->dieUsageMsg(array($retval));
8888
8989 $r = array('from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason']);
90 - if(!$params['noredirect'])
 90+ if(!$params['noredirect'] || !$wgUser->isAllowed('suppressredirect'))
9191 $r['redirectcreated'] = '';
9292
9393 if($params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage())
@@ -106,6 +106,18 @@
107107 $r['talkmove-error-info'] = ApiBase::$messageMap[$retval]['info'];
108108 }
109109 }
 110+
 111+ # Watch pages
 112+ if($params['watch'] || $wgUser->getOption('watchmoves'))
 113+ {
 114+ $wgUser->addWatch($fromTitle);
 115+ $wgUser->addWatch($toTitle);
 116+ }
 117+ else if($params['unwatch'])
 118+ {
 119+ $wgUser->removeWatch($fromTitle);
 120+ $wgUser->removeWatch($toTitle);
 121+ }
110122 $dbw->commit(); // Make sure all changes are really written to the DB
111123 $this->getResult()->addValue(null, $this->getModuleName(), $r);
112124 }
@@ -119,7 +131,9 @@
120132 'token' => null,
121133 'reason' => null,
122134 'movetalk' => false,
123 - 'noredirect' => false
 135+ 'noredirect' => false,
 136+ 'watch' => false,
 137+ 'unwatch' => false
124138 );
125139 }
126140
@@ -130,7 +144,9 @@
131145 'token' => 'A move token previously retrieved through prop=info',
132146 'reason' => 'Reason for the move (optional).',
133147 'movetalk' => 'Move the talk page, if it exists.',
134 - 'noredirect' => 'Don\'t create a redirect'
 148+ 'noredirect' => 'Don\'t create a redirect',
 149+ 'watch' => 'Add the page and the redirect to your watchlist',
 150+ 'unwatch' => 'Remove the page and the redirect from your watchlist'
135151 );
136152 }
137153
Index: trunk/phase3/includes/api/ApiDelete.php
@@ -68,12 +68,16 @@
6969 $reason = (isset($params['reason']) ? $params['reason'] : NULL);
7070 $dbw = wfGetDb(DB_MASTER);
7171 $dbw->begin();
72 - $retval = self::delete($articleObj, $params['token'], $reason);
 72+ $retval = self::delete($articleObj, $params['token'], $reason);
7373
7474 if(!empty($retval))
7575 // We don't care about multiple errors, just report one of them
7676 $this->dieUsageMsg(current($retval));
77 -
 77+
 78+ if($params['watch'] || $wgUser->getOption('watchdeletion'))
 79+ $articleObj->doWatch();
 80+ else if($params['unwatch'])
 81+ $articleObj->doUnwatch();
7882 $dbw->commit();
7983 $r = array('title' => $titleObj->getPrefixedText(), 'reason' => $reason);
8084 $this->getResult()->addValue(null, $this->getModuleName(), $r);
@@ -125,6 +129,8 @@
126130 'title' => null,
127131 'token' => null,
128132 'reason' => null,
 133+ 'watch' => false,
 134+ 'unwatch' => false
129135 );
130136 }
131137
@@ -132,7 +138,9 @@
133139 return array (
134140 'title' => 'Title of the page you want to delete.',
135141 'token' => 'A delete token previously retrieved through prop=info',
136 - 'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.'
 142+ 'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.',
 143+ 'watch' => 'Add the page to your watchlist',
 144+ 'unwatch' => 'Remove the page from your watchlist'
137145 );
138146 }
139147
Index: trunk/phase3/RELEASE-NOTES
@@ -72,6 +72,7 @@
7373 * (bug 13157) Added ucuserprefix parameter to list=usercontibs
7474 * (bug 12394) Added rctitles parameter to list=recentchanges, making rcid retrieval easier
7575 * (bug 13218) Fix inclusion of " character in hyperlinks
 76+* Added watch and unwatch parameters to action=delete and action=move
7677
7778 === Languages updated in 1.13 ===
7879

Status & tagging log