X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontent%2FAbstractContent.php;h=e1b1f019268ca26222b14478501ab970d01d1935;hb=0bc431e7ecd810549eaccf340d8f4caaf85c3f17;hp=8c6e24a619c94a40395f0e8552ab2e155f6b1857;hpb=95bd54c8f9b3016f097c831fb47a376a15a9d934;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php index 8c6e24a619..e1b1f01926 100644 --- a/includes/content/AbstractContent.php +++ b/includes/content/AbstractContent.php @@ -32,7 +32,6 @@ * @ingroup Content */ abstract class AbstractContent implements Content { - /** * Name of the content model this Content object represents. * Use with CONTENT_MODEL_XXX constants @@ -264,7 +263,7 @@ abstract class AbstractContent implements Content { break; } // Redirects to some special pages are not permitted - if ( $newtitle instanceOf Title && $newtitle->isValidRedirectTarget() ) { + if ( $newtitle instanceof Title && $newtitle->isValidRedirectTarget() ) { // The new title passes the checks, so make that our current // title so that further recursion can be checked $title = $newtitle; @@ -273,6 +272,7 @@ abstract class AbstractContent implements Content { break; } } + return $titles; } @@ -293,6 +293,7 @@ abstract class AbstractContent implements Content { */ public function getUltimateRedirectTarget() { $titles = $this->getRedirectChain(); + return $titles ? array_pop( $titles ) : null; } @@ -394,15 +395,16 @@ abstract class AbstractContent implements Content { * database after deletion. */ public function getDeletionUpdates( WikiPage $page, - ParserOutput $parserOutput = null ) - { + ParserOutput $parserOutput = null + ) { return array( new LinksDeletionUpdate( $page ), ); } /** - * This default implementation always returns false. Subclasses may override this to supply matching logic. + * This default implementation always returns false. Subclasses may override + * this to supply matching logic. * * @see Content::matchMagicWord * @@ -422,8 +424,8 @@ abstract class AbstractContent implements Content { * This base implementation calls the hook ConvertContent to enable custom conversions. * Subclasses may override this to implement conversion for "their" content model. * - * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. - * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is + * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. + * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is * not allowed, full round-trip conversion is expected to work without losing information. * * @return Content|bool A content object with the content model $toModel, or false if @@ -439,59 +441,7 @@ abstract class AbstractContent implements Content { $result = false; wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) ); - return $result; - } - - /** - * Returns a ParserOutput object, filled by a call to fillParserOutput(). - * Subclasses that want to control the parser output may override this, or - * they can override fillParserOutput(). If they override getParserOutput(), - * itself, they should take care to call the ContentGetParserOutput hook. - * - * @param $title Title Context title for parsing - * @param $revId int|null Revision ID (for {{REVISIONID}}) - * @param $options ParserOptions|null Parser options - * @param $generateHtml bool Whether or not to generate HTML - * - * @return ParserOutput representing the HTML form of the text - */ - public function getParserOutput( Title $title, $revId = null, - ParserOptions $options = null, $generateHtml = true - ) { - # Generic implementation, relying on $this->getHtml() - - if ( $options === null ) { - $options = $this->getContentHandler()->makeParserOptions( 'canonical' ); - } - $po = new ParserOutput(); - - if ( wfRunHooks( 'ContentGetParserOutput', - array( $this, $title, $revId, $options, $generateHtml, &$po ) ) ) { - - $this->fillParserOutput( $title, $revId, $options, $generateHtml, $po ); - } - - return $po; - } - - /** - * Fills the provided ParserOutput object with the HTML returned by getHtml(). - * Subclasses should override this (or getParserOutput) appropriately. - * This placeholder implementation always throws an exception. - * - * @param $title Title Context title for parsing - * @param $revId int|null Revision ID (for {{REVISIONID}}) - * @param $options ParserOptions|null Parser options - * @param $generateHtml bool Whether or not to generate HTML - * @param &$output ParserOutput The output object to fill (reference). - * - * @throws MWException - */ - protected function fillParserOutput( Title $title, $revId, - ParserOptions $options, $generateHtml, ParserOutput &$output - ) { - // Don't make abstract, so subclasses that override getParserOutput() directly don't fail. - throw new MWException( 'Subclasses of AbstractContent must override fillParserOutput!' ); + return $result; } }