Skip to content

Commit

Permalink
fixing problems with parser
Browse files Browse the repository at this point in the history
  • Loading branch information
thaider committed Mar 7, 2021
1 parent be702f6 commit 7db5174
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/Hooks.php
Expand Up @@ -523,7 +523,7 @@ static function parseButtonLink( $line, $parser, $frame ) {
$extraAttribs = [];
$href_implicit = false;
$active = false;
$current_title = $parser->getTitle();
$current_title = $parser instanceof Parser ? $parser->getTitle() : null;

// semantic queries
if ( strpos( $line, '{{#ask:' ) === 0 ) {
Expand Down Expand Up @@ -616,7 +616,7 @@ static function parseButtonLink( $line, $parser, $frame ) {
} else {
$title = Title::newFromText( $href );
if ( $title ) {
if( $title->equals( $current_title ) ) {
if( !is_null( $current_title ) && $current_title instanceof Title && $title->equals( $current_title ) ) {
$active = true;
}
$title = $title->fixSpecialName();
Expand Down
3 changes: 3 additions & 0 deletions includes/TweekiTemplate.php
Expand Up @@ -1163,6 +1163,9 @@ private function renderCustomNavigation( &$buttons, &$customItems ) {

if( version_compare( MW_VERSION, '1.35', '>=' ) ) {
$parser = MediaWikiServices::getInstance()->getParser();
$parser->setOptions( ParserOptions::newFromContext( $this->getSkin()->getContext() ) );
$parser->setTitle( $this->getSkin()->getTitle() );
$parser->clearState();
} else {
$options = new ParserOptions();
$parser = new Parser();
Expand Down

0 comments on commit 7db5174

Please sign in to comment.