From: daniel Date: Thu, 30 Aug 2012 16:20:41 +0000 (+0200) Subject: handle bad content model in SpecialBooksources X-Git-Tag: 1.31.0-rc.0~22097^2^2~33 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=2aacb7fd6e597ea2b47ce5194800f973912cbf9c;p=lhc%2Fweb%2Fwiklou.git handle bad content model in SpecialBooksources Change-Id: Iae1b9e4620076bdd0b82e97797361c6f7561d2f9 --- 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