From 2aacb7fd6e597ea2b47ce5194800f973912cbf9c Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Aug 2012 18:20:41 +0200 Subject: [PATCH] handle bad content model in SpecialBooksources Change-Id: Iae1b9e4620076bdd0b82e97797361c6f7561d2f9 --- includes/specials/SpecialBooksources.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index d271a620d0..fb6532665a 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -144,9 +144,17 @@ class SpecialBookSources extends SpecialPage { $title = Title::makeTitleSafe( NS_PROJECT, $page ); # Show list in content language if( is_object( $title ) && $title->exists() ) { $rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL ); - #FIXME: need a way to do this via ContentHandler (or enforce flat text-based content) - $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); - return true; + $content = $rev->getContent(); + + if ( $content instanceof TextContent ) { + //XXX: in the future, this could be stored as structured data, defining a list of book sources + + $text = $content->getNativeData(); + $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $text ) ); + return true; + } else { + throw new MWException( "Unexpected content type for book sources: " . $content->getModel() ); + } } # Fall back to the defaults given in the language file -- 2.20.1