Migrate protect log to new log system
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index d1cec60..8b88986 100644 (file)
@@ -2409,6 +2409,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                $logRelationsValues = array();
                $logRelationsField = null;
+               $logParamsDetails = array();
 
                if ( $id ) { // Protection of existing page
                        if ( !Hooks::run( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
@@ -2467,6 +2468,7 @@ class WikiPage implements Page, IDBAccessObject {
                                        __METHOD__
                                );
                                if ( $restrictions != '' ) {
+                                       $cascadeValue = ( $cascade && $action == 'edit' ) ? 1 : 0;
                                        $dbw->insert(
                                                'page_restrictions',
                                                array(
@@ -2474,12 +2476,18 @@ class WikiPage implements Page, IDBAccessObject {
                                                        'pr_page' => $id,
                                                        'pr_type' => $action,
                                                        'pr_level' => $restrictions,
-                                                       'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
+                                                       'pr_cascade' => $cascadeValue,
                                                        'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] )
                                                ),
                                                __METHOD__
                                        );
                                        $logRelationsValues[] = $dbw->insertId();
+                                       $logParamsDetails[] = array(
+                                               'type' => $action,
+                                               'level' => $restrictions,
+                                               'expiry' => $expiry[$action],
+                                               'cascade' => (bool)$cascadeValue,
+                                       );
                                }
                        }
 
@@ -2510,6 +2518,11 @@ class WikiPage implements Page, IDBAccessObject {
                                                'pt_reason' => $reason,
                                        ), __METHOD__
                                );
+                               $logParamsDetails[] = array(
+                                       'type' => 'create',
+                                       'level' => $limit['create'],
+                                       'expiry' => $expiry['create'],
+                               );
                        } else {
                                $dbw->delete( 'protected_titles',
                                        array(
@@ -2527,15 +2540,24 @@ class WikiPage implements Page, IDBAccessObject {
                        $params = array();
                } else {
                        $protectDescriptionLog = $this->protectDescriptionLog( $limit, $expiry );
-                       $params = array( $protectDescriptionLog, $cascade ? 'cascade' : '' );
+                       $params = array(
+                               '4::description' => $protectDescriptionLog, // parameter for IRC
+                               '5:bool:cascade' => $cascade,
+                               'details' => $logParamsDetails, // parameter for localize and api
+                       );
                }
 
                // Update the protection log
-               $log = new LogPage( 'protect' );
-               $logId = $log->addEntry( $logAction, $this->mTitle, $reason, $params, $user );
+               $logEntry = new ManualLogEntry( 'protect', $logAction );
+               $logEntry->setTarget( $this->mTitle );
+               $logEntry->setComment( $reason );
+               $logEntry->setPerformer( $user );
+               $logEntry->setParameters( $params );
                if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
-                       $log->addRelations( $logRelationsField, $logRelationsValues, $logId );
+                       $logEntry->setRelations( array( $logRelationsField => $logRelationsValues ) );
                }
+               $logId = $logEntry->insert();
+               $logEntry->publish( $logId );
 
                return Status::newGood();
        }
@@ -2916,7 +2938,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                // remove secondary indexes, etc
                $updates = $this->getDeletionUpdates( $content );
-               DataUpdate::runUpdates( $updates );
+               DataUpdate::runUpdates( $updates, 'enqueue' );
 
                // Reparse any pages transcluding this page
                LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );