Fix fatal error in Special:Export -- invalid title when using Template inclusion
[lhc/web/wiklou.git] / includes / ProtectionForm.php
index 96fc080..a5ff4f3 100644 (file)
@@ -59,7 +59,7 @@ class ProtectionForm {
                }
 
                // The form will be available in read-only to show levels.
-               $this->disabled = ($this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect',$wgUser)) != array();
+               $this->disabled = wfReadOnly() || ($this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect',$wgUser)) != array();
                $this->disabledAttrib = $this->disabled
                        ? array( 'disabled' => 'disabled' )
                        : array();
@@ -116,9 +116,7 @@ class ProtectionForm {
                                $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
                        }
 
-                       $notice = wfMsgExt( 'protect-cascadeon', array('parsemag'), count($cascadeSources) ) . "\r\n$titles";
-
-                       $wgOut->addWikiText( $notice );
+                       $wgOut->wrapWikiMsg( "$1\n$titles", array( 'protect-cascadeon', count($cascadeSources) ) );
                }
 
                $wgOut->setPageTitle( wfMsg( 'confirmprotect' ) );
@@ -127,11 +125,14 @@ class ProtectionForm {
                # Show an appropriate message if the user isn't allowed or able to change
                # the protection settings at this time
                if( $this->disabled ) {
-                       $message = $wgOut->formatPermissionsErrorMessage( $this->mPermErrors );
+                       if( wfReadOnly() ) {
+                               $wgOut->readOnlyPage();
+                       } elseif( $this->mPermErrors ) {
+                               $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $this->mPermErrors ) );
+                       }
                } else {
-                       $message = wfMsg( 'protect-text', wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
+                       $wgOut->addWikiMsg( 'protect-text', $this->mTitle->getPrefixedText() );
                }
-               $wgOut->addWikiText( $message );
 
                $wgOut->addHTML( $this->buildForm() );