X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserOptions.php;h=0e8d76d3d8abe3f503a521791558796f516376a9;hb=35c38ce319563889ccd61f998223e61316a35f6a;hp=1073aed81773b655bcd35c8ee847ba499387e11e;hpb=6382ba2d5a487def06bde3fa1749de2944535954;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 1073aed817..0e8d76d3d8 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -599,6 +599,15 @@ class ParserOptions { $this->initialiseFromUser( $user, $lang ); } + /** + * Get a ParserOptions object for an anonymous user + * @return ParserOptions + */ + public static function newFromAnon() { + global $wgContLang; + return new ParserOptions( new User, $wgContLang ); + } + /** * Get a ParserOptions object from a given user. * Language will be taken from $wgLang. @@ -831,8 +840,8 @@ class ParserOptions { } /** - * Sets a hook to force that a page exists, and sets a current revision callback to return a - * revision with custom content when the current revision of the page is requested. + * Sets a hook to force that a page exists, and sets a current revision callback to return + * a revision with custom content when the current revision of the page is requested. * * @since 1.25 * @param Title $title @@ -841,20 +850,25 @@ class ParserOptions { * @return ScopedCallback to unset the hook */ public function setupFakeRevision( $title, $content, $user ) { - $oldCallback = $this->setCurrentRevisionCallback( function ( $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback ) { - if ( $titleToCheck->equals( $title ) ) { - return new Revision( array( - 'page' => $title->getArticleID(), - 'user_text' => $user->getName(), - 'user' => $user->getId(), - 'parent_id' => $title->getLatestRevId(), - 'title' => $title, - 'content' => $content - ) ); - } else { - return call_user_func( $oldCallback, $titleToCheck, $parser ); + $oldCallback = $this->setCurrentRevisionCallback( + function ( + $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback + ) { + if ( $titleToCheck->equals( $title ) ) { + return new Revision( array( + 'page' => $title->getArticleID(), + 'user_text' => $user->getName(), + 'user' => $user->getId(), + 'parent_id' => $title->getLatestRevId(), + 'title' => $title, + 'content' => $content + ) ); + } else { + return call_user_func( $oldCallback, $titleToCheck, $parser ); + } } - } ); + ); + global $wgHooks; $wgHooks['TitleExists'][] = function ( $titleToCheck, &$exists ) use ( $title ) {