Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -789,31 +789,33 @@ |
790 | 790 | */ |
791 | 791 | protected function getPreloadedText( $preload ) { |
792 | 792 | global $wgUser, $wgParser; |
| 793 | + |
793 | 794 | if ( !empty( $this->mPreloadText ) ) { |
794 | 795 | return $this->mPreloadText; |
795 | | - } elseif ( $preload !== '' ) { |
796 | | - $title = Title::newFromText( $preload ); |
797 | | - # Check for existence to avoid getting MediaWiki:Noarticletext |
798 | | - if ( isset( $title ) && $title->exists() && $title->userCanRead() ) { |
799 | | - $article = new Article( $title ); |
| 796 | + } |
| 797 | + |
| 798 | + if ( $preload === '' ) { |
| 799 | + return ''; |
| 800 | + } |
800 | 801 | |
801 | | - if ( $article->isRedirect() ) { |
802 | | - $title = Title::newFromRedirectRecurse( $article->getContent() ); |
803 | | - # Redirects to missing titles are displayed, to hidden pages are followed |
804 | | - # Copying observed behaviour from ?action=view |
805 | | - if ( $title->exists() ) { |
806 | | - if ($title->userCanRead() ) { |
807 | | - $article = new Article( $title ); |
808 | | - } else { |
809 | | - return ""; |
810 | | - } |
811 | | - } |
812 | | - } |
813 | | - $parserOptions = ParserOptions::newFromUser( $wgUser ); |
814 | | - return $wgParser->getPreloadText( $article->getContent(), $title, $parserOptions ); |
| 802 | + $title = Title::newFromText( $preload ); |
| 803 | + # Check for existence to avoid getting MediaWiki:Noarticletext |
| 804 | + if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { |
| 805 | + return ''; |
| 806 | + } |
| 807 | + |
| 808 | + $page = WikiPage::factory( $title ); |
| 809 | + if ( $page->isRedirect() ) { |
| 810 | + $title = $page->getRedirectTarget(); |
| 811 | + # Same as before |
| 812 | + if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { |
| 813 | + return ''; |
815 | 814 | } |
| 815 | + $page = WikiPage::factory( $title ); |
816 | 816 | } |
817 | | - return ''; |
| 817 | + |
| 818 | + $parserOptions = ParserOptions::newFromUser( $wgUser ); |
| 819 | + return $wgParser->getPreloadText( $page->getRawText(), $title, $parserOptions ); |
818 | 820 | } |
819 | 821 | |
820 | 822 | /** |