Fix outdated comment in DefaultSettings
[lhc/web/wiklou.git] / includes / WikiPage.php
index d3743b5..0d987aa 100644 (file)
@@ -245,7 +245,8 @@ class WikiPage implements Page, IDBAccessObject {
                $this->mIsRedirect = false;
                $this->mLatest = false;
                // Bug 57026: do not clear mPreparedEdit since prepareTextForEdit() already checks
-               // the requested rev ID and immutable content against the cached one.
+               // the requested rev ID and content against the cached one for equality. For most
+               // content types, the output should not change during the lifetime of this cache.
                // Clearing it can cause extra parses on edit for no reason.
        }
 
@@ -1659,7 +1660,8 @@ class WikiPage implements Page, IDBAccessObject {
         * @since 1.21
         */
        public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,
-                                                                  User $user = null, $serialisation_format = null ) {
+               User $user = null, $serialisation_format = null
+       ) {
                global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol;
 
                // Low-level sanity check
@@ -2015,6 +2017,11 @@ class WikiPage implements Page, IDBAccessObject {
                $user = is_null( $user ) ? $wgUser : $user;
                //XXX: check $user->getId() here???
 
+               // Use a sane default for $serialization_format, see bug 57026
+               if ( $serialization_format === null ) {
+                       $serialization_format = $content->getContentHandler()->getDefaultFormat();
+               }
+
                if ( $this->mPreparedEdit
                        && $this->mPreparedEdit->newContent
                        && $this->mPreparedEdit->newContent->equals( $content )
@@ -2246,14 +2253,14 @@ class WikiPage implements Page, IDBAccessObject {
         * @return Status
         */
        public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
-               global $wgCascadingRestrictionLevels;
+               global $wgCascadingRestrictionLevels, $wgContLang;
 
                if ( wfReadOnly() ) {
                        return Status::newFatal( 'readonlytext', wfReadOnlyReason() );
                }
 
+               $this->loadPageData( 'fromdbmaster' );
                $restrictionTypes = $this->mTitle->getRestrictionTypes();
-
                $id = $this->getId();
 
                if ( !$cascade ) {
@@ -2319,6 +2326,9 @@ class WikiPage implements Page, IDBAccessObject {
                        $logAction = 'protect';
                }
 
+               // Truncate for whole multibyte characters
+               $reason = $wgContLang->truncate( $reason, 255 );
+
                if ( $id ) { // Protection of existing page
                        if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
                                return Status::newGood();
@@ -2392,7 +2402,7 @@ class WikiPage implements Page, IDBAccessObject {
                                                'pt_namespace' => $this->mTitle->getNamespace(),
                                                'pt_title' => $this->mTitle->getDBkey(),
                                                'pt_create_perm' => $limit['create'],
-                                               'pt_timestamp' => $dbw->encodeExpiry( wfTimestampNow() ),
+                                               'pt_timestamp' => $dbw->timestamp(),
                                                'pt_expiry' => $dbw->encodeExpiry( $expiry['create'] ),
                                                'pt_user' => $user->getId(),
                                                'pt_reason' => $reason,
@@ -2420,7 +2430,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Update the protection log
                $log = new LogPage( 'protect' );
-               $log->addEntry( $logAction, $this->mTitle, trim( $reason ), $params, $user );
+               $log->addEntry( $logAction, $this->mTitle, $reason, $params, $user );
 
                return Status::newGood();
        }