Merge "Add tags support to patrol, protect, unblock, and undelete"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 27412ed..d81efa6 100644 (file)
@@ -2404,10 +2404,13 @@ class WikiPage implements Page, IDBAccessObject {
         * @param int &$cascade Set to false if cascading protection isn't allowed.
         * @param string $reason
         * @param User $user The user updating the restrictions
-        * @return Status
+        * @param string|string[] $tags Change tags to add to the pages and protection log entries
+        *   ($user should be able to add the specified tags before this is called)
+        * @return Status Status object; if action is taken, $status->value is the log_id of the
+        *   protection log entry.
         */
        public function doUpdateRestrictions( array $limit, array $expiry,
-               &$cascade, $reason, User $user
+               &$cascade, $reason, User $user, $tags = null
        ) {
                global $wgCascadingRestrictionLevels, $wgContLang;
 
@@ -2489,6 +2492,9 @@ class WikiPage implements Page, IDBAccessObject {
                $logRelationsField = null;
                $logParamsDetails = [];
 
+               // Null revision (used for change tag insertion)
+               $nullRevision = null;
+
                if ( $id ) { // Protection of existing page
                        if ( !Hooks::run( 'ArticleProtect', [ &$this, &$user, $limit, $reason ] ) ) {
                                return Status::newGood();
@@ -2632,13 +2638,17 @@ class WikiPage implements Page, IDBAccessObject {
                $logEntry->setComment( $reason );
                $logEntry->setPerformer( $user );
                $logEntry->setParameters( $params );
+               if ( !is_null( $nullRevision ) ) {
+                       $logEntry->setAssociatedRevId( $nullRevision->getId() );
+               }
+               $logEntry->setTags( $tags );
                if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
                        $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
                }
                $logId = $logEntry->insert();
                $logEntry->publish( $logId );
 
-               return Status::newGood();
+               return Status::newGood( $logId );
        }
 
        /**