From a2974f51f1a42d9d4356779b3446aaed3d243f90 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 2 Feb 2009 16:38:40 +0000 Subject: [PATCH] API: (bug 17317) Added watch parameter to action=protect --- RELEASE-NOTES | 1 + includes/api/ApiProtect.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c2dc802de2..46bb25fbc0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -151,6 +151,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN autolinked correctly * (bug 17224) Added siprop=rightsinfo to meta=siteinfo * (bug 17239) Added prop=displaytitle to action=parse +* (bug 17317) Added watch parameter to action=protect === Languages updated in 1.15 === diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 0163e5ab6a..6bae2fcb0b 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -106,10 +106,12 @@ class ApiProtect extends ApiBase { } $cascade = $params['cascade']; - if($titleObj->exists()) { - $articleObj = new Article($titleObj); + $articleObj = new Article($titleObj); + if($params['watch']) + $articleObj->doWatch(); + if($titleObj->exists()) $ok = $articleObj->updateRestrictions($protections, $params['reason'], $cascade, $expiryarray); - } else + else $ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiryarray['create']); if(!$ok) // This is very weird. Maybe the article was deleted or the user was blocked/desysopped in the meantime? @@ -138,7 +140,8 @@ class ApiProtect extends ApiBase { ApiBase :: PARAM_DFLT => 'infinite', ), 'reason' => '', - 'cascade' => false + 'cascade' => false, + 'watch' => false, ); } @@ -152,6 +155,7 @@ class ApiProtect extends ApiBase { 'reason' => 'Reason for (un)protecting (optional)', 'cascade' => array('Enable cascading protection (i.e. protect pages included in this page)', 'Ignored if not all protection levels are \'sysop\' or \'protect\''), + 'watch' => 'If set, add the page being (un)protected to your watchlist', ); } -- 2.20.1