Foxtrott has submitted this change and it was merged. Change subject: Replace deprecated functions ......................................................................
Replace deprecated functions Change-Id: I0388ad67b34a38525247944db7eb6d943f1887f4 --- M src/BasicBackend.php M src/Element.php M src/LingoParser.php 3 files changed, 29 insertions(+), 20 deletions(-) Approvals: Foxtrott: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/src/BasicBackend.php b/src/BasicBackend.php index 87c2589..d7fa827 100644 --- a/src/BasicBackend.php +++ b/src/BasicBackend.php @@ -28,6 +28,7 @@ namespace Lingo; use ApprovedRevs; +use ContentHandler; use Page; use Parser; use ParserOptions; @@ -50,9 +51,9 @@ */ public function __construct( MessageLog &$messages = null ) { - global $wgexLingoPage, $wgRequest; + global $wgRequest; - $page = $wgexLingoPage ? $wgexLingoPage : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text(); + $page = self::getLingoPage(); parent::__construct( $messages ); @@ -63,9 +64,9 @@ return; } - // FIXME: This is a hack special-casing the submitting of the terminology + // This is a hack special-casing the submitting of the terminology // page itself. In this case the Revision is not up to date when we get - // here, i.e. $rev->getText() would return outdated Test. + // here, i.e. $rev->getText() would return outdated Text. // This hack takes the text directly out of the data from the web request. if ( $wgRequest->getVal( 'action', 'view' ) === 'submit' && Title::newFromText( $wgRequest->getVal( 'title' ) )->getArticleID() === $title->getArticleID() @@ -77,19 +78,30 @@ $rev = $this->getRevision( $title ); if ( !$rev ) { $this->getMessageLog()->addWarning( wfMessage( 'lingo-noterminologypage', $page )->inContentLanguage()->text() ); - return false; + return; } - $content = $rev->getText(); + $content = ContentHandler::getContentText( $rev->getContent() ); } $parser = new Parser; - // expand templates and variables in the text, producing valid, static wikitext - // have to use a new anonymous user to avoid any leakage as Lingo is caching only one user-independant glossary + // expand templates and variables in the text, producing valid, static + // wikitext have to use a new anonymous user to avoid any leakage as + // Lingo is caching only one user-independent glossary $content = $parser->preprocess( $content, $title, new ParserOptions( new User() ) ); $this->mArticleLines = array_reverse( explode( "\n", $content ) ); + } + + /** + * @param $wgexLingoPage + * @return string + */ + private static function getLingoPage() { + global $wgexLingoPage; + + return $wgexLingoPage ? $wgexLingoPage : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text(); } /** @@ -101,8 +113,6 @@ * @return Array | null */ public function next() { - - wfProfileIn( __METHOD__ ); static $term = null; static $definitions = array(); @@ -146,8 +156,6 @@ } } - wfProfileOut( __METHOD__ ); - return array_pop( $ret ); } @@ -181,8 +189,7 @@ */ public static function purgeCache( &$wikipage ) { - global $wgexLingoPage; - $page = $wgexLingoPage ? $wgexLingoPage : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text(); + $page = self::getLingoPage(); if ( !is_null( $wikipage ) && ( $wikipage->getTitle()->getText() === $page ) ) { diff --git a/src/Element.php b/src/Element.php index 397d1ca..ba22f5a 100644 --- a/src/Element.php +++ b/src/Element.php @@ -203,10 +203,10 @@ $span->setAttribute( 'class', 'mw-lingo-tooltip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); // Wrap term in <span> tag, hidden - wfSuppressWarnings(); + \MediaWiki\suppressWarnings(); $spanTerm = $doc->createElement( 'span', htmlentities( $this->mTerm, ENT_COMPAT, 'UTF-8' ) ); + \MediaWiki\restoreWarnings(); - wfRestoreWarnings(); $spanTerm->setAttribute( 'class', 'mw-lingo-tooltip-abbr' ); // Wrap definition in a <span> tag @@ -214,10 +214,12 @@ $spanDefinition->setAttribute( 'class', 'mw-lingo-tooltip-tip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); foreach ( $this->mDefinitions as $definition ) { - wfSuppressWarnings(); + + \MediaWiki\suppressWarnings(); $element = $doc->createElement( 'span', htmlentities( $definition[ self::ELEMENT_DEFINITION ], ENT_COMPAT, 'UTF-8' ) ); $element->setAttribute( 'class', 'mw-lingo-tooltip-definition ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); - wfRestoreWarnings(); + \MediaWiki\restoreWarnings(); + if ( $definition[ self::ELEMENT_LINK ] ) { $linkedTitle = Title::newFromText( $definition[ self::ELEMENT_LINK ] ); if ( $linkedTitle ) { diff --git a/src/LingoParser.php b/src/LingoParser.php index c2cbf94..684ed34 100644 --- a/src/LingoParser.php +++ b/src/LingoParser.php @@ -197,12 +197,12 @@ } // Parse HTML from page - wfSuppressWarnings(); + \MediaWiki\suppressWarnings(); $doc = new DOMDocument( '1.0', 'utf-8' ); $doc->loadHTML( '<html><head><meta http-equiv="content-type" content="charset=utf-8"/></head><body>' . $text . '</body></html>' ); - wfRestoreWarnings(); + \MediaWiki\restoreWarnings(); // Find all text in HTML. $xpath = new DOMXpath( $doc ); -- To view, visit https://gerrit.wikimedia.org/r/275357 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0388ad67b34a38525247944db7eb6d943f1887f4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Lingo Gerrit-Branch: master Gerrit-Owner: Foxtrott <s7ep...@gmail.com> Gerrit-Reviewer: Foxtrott <s7ep...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits