Merge "Add new parserTests for table cell attributes coming from templates."
[lhc/web/wiklou.git] / includes / WikiPage.php
index 4aab674..9d61abc 100644 (file)
@@ -2071,7 +2071,9 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Update the links tables and other secondary data
                if ( $content ) {
-                       $updates = $content->getSecondaryDataUpdates( $this->getTitle(), null, true, $editInfo->output );
+                       $recursive = $options['changed']; // bug 50785
+                       $updates = $content->getSecondaryDataUpdates(
+                               $this->getTitle(), null, $recursive, $editInfo->output );
                        DataUpdate::runUpdates( $updates );
                }
 
@@ -2343,9 +2345,14 @@ class WikiPage implements Page, IDBAccessObject {
                                return Status::newGood();
                        }
 
-                       // Only certain restrictions can cascade... Otherwise, users who cannot normally protect pages
-                       // could "protect" them by transcluding them on protected pages they are allowed to edit.
+                       // Only certain restrictions can cascade...
                        $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
+                       foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
+                               $editrestriction[$key] = 'editprotected'; // backwards compatibility
+                       }
+                       foreach ( array_keys( $editrestriction, 'autoconfirmed' ) as $key ) {
+                               $editrestriction[$key] = 'editsemiprotected'; // backwards compatibility
+                       }
 
                        $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
                        foreach ( array_keys( $cascadingRestrictionLevels, 'sysop' ) as $key ) {
@@ -2360,24 +2367,6 @@ class WikiPage implements Page, IDBAccessObject {
                                $cascade = false;
                        }
 
-                       // Update restrictions table
-                       foreach ( $limit as $action => $restrictions ) {
-                               if ( $restrictions != '' ) {
-                                       $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ),
-                                               array( 'pr_page' => $id,
-                                                       'pr_type' => $action,
-                                                       'pr_level' => $restrictions,
-                                                       'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
-                                                       'pr_expiry' => $encodedExpiry[$action]
-                                               ),
-                                               __METHOD__
-                                       );
-                               } else {
-                                       $dbw->delete( 'page_restrictions', array( 'pr_page' => $id,
-                                               'pr_type' => $action ), __METHOD__ );
-                               }
-                       }
-
                        // Prepare a null revision to be added to the history
                        $editComment = $wgContLang->ucfirst(
                                wfMessage(
@@ -2399,8 +2388,30 @@ class WikiPage implements Page, IDBAccessObject {
                                )->inContentLanguage()->text();
                        }
 
-                       // Insert a null revision
                        $nullRevision = Revision::newNullRevision( $dbw, $id, $editComment, true );
+                       if ( $nullRevision === null ) {
+                               return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
+                       }
+
+                       // Update restrictions table
+                       foreach ( $limit as $action => $restrictions ) {
+                               if ( $restrictions != '' ) {
+                                       $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ),
+                                               array( 'pr_page' => $id,
+                                                       'pr_type' => $action,
+                                                       'pr_level' => $restrictions,
+                                                       'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
+                                                       'pr_expiry' => $encodedExpiry[$action]
+                                               ),
+                                               __METHOD__
+                                       );
+                               } else {
+                                       $dbw->delete( 'page_restrictions', array( 'pr_page' => $id,
+                                               'pr_type' => $action ), __METHOD__ );
+                               }
+                       }
+
+                       // Insert a null revision
                        $nullRevId = $nullRevision->insertOn( $dbw );
 
                        $latest = $this->getLatest();