Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"DisplayTitleHooks.php": Call to a member function isTalkPage() on null #63

Closed
mwjames opened this issue Jul 21, 2019 · 17 comments
Closed
Labels
issue site - s-mw.org - sandbox sandbox.semantic-mediawiki.org (99071) upstream An issue caused by MediaWiki

Comments

@mwjames
Copy link

mwjames commented Jul 21, 2019

Setup

  • MediaWiki 1.33.0 (1c47e93) 15:49, 16. Jul. 2019
  • PHP 7.2.19-0ubuntu0.18.04.1 (apache2handle
  • MariaDB 10.1.40-MariaDB-0ubuntu0.18.04.1
  • DisplayTitle 2.0.0 (0705659) 14:51, 6. Feb. 2019

refs: https://sandbox.semantic-mediawiki.org/w/index.php?title=Sp%C3%A9cial:Requ%C3%AAter&#search

Issue

[ddc4653e9eff034859c5f6dc] /w/index.php?title=Sp%C3%A9cial:Requ%C3%AAter& Error from line 183 of /var/www/html/sbxsmw/w/extensions/DisplayTitle/includes/DisplayTitleHooks.php: Call to a member function isTalkPage() on null

Backtrace:

#0 /../w/includes/Hooks.php(174): DisplayTitleHooks::onParserBeforeStrip(Parser, string, NULL)
#1 /../w/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#2 /../w/includes/parser/Parser.php(695): Hooks::run(string, array)
#3 /../w/extensions/SemanticResultFormats/formats/graphviz/SRF_Graph.php(136): Parser->recursiveTagParse(string)
#4 /../w/extensions/SemanticMediaWiki/src/Query/ResultPrinters/ResultPrinter.php(342): SRFGraph->getResultText(SMW\Query\QueryResult, integer)
#5 /../w/extensions/SemanticMediaWiki/src/Query/ResultPrinters/ResultPrinter.php(307): SMW\Query\ResultPrinters\ResultPrinter->buildResult(SMW\Query\QueryResult)
#6 /../w/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialAsk.php(481): SMW\Query\ResultPrinters\ResultPrinter->getResult(SMW\Query\QueryResult, array, integer)
#7 /../w/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialAsk.php(316): SMW\MediaWiki\Specials\SpecialAsk->fetchResults(SRFGraph, SMWQuery, SMW\MediaWiki\Specials\Ask\UrlArgs)
#8 /../w/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialAsk.php(169): SMW\MediaWiki\Specials\SpecialAsk->makeHTMLResult()
#9 /../w/includes/specialpage/SpecialPage.php(569): SMW\MediaWiki\Specials\SpecialAsk->execute(NULL)
#10 /../w/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(NULL)
#11 /../w/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#12 /../w/includes/MediaWiki.php(865): MediaWiki->performRequest()
#13 /../w/includes/MediaWiki.php(515): MediaWiki->main()
#14 /../w/index.php(42): MediaWiki->run()
#15 {main}
@mwjames
Copy link
Author

mwjames commented Jul 21, 2019

@kghbln FYI

@kghbln kghbln added issue site - s-mw.org - sandbox sandbox.semantic-mediawiki.org (99071) upstream An issue caused by MediaWiki labels Jul 21, 2019
@kghbln kghbln changed the title sandbox: DisplayTitleHooks.php: Call to a member function isTalkPage() on null DisplayTitleHooks.php: Call to a member function isTalkPage() on null Jul 21, 2019
@kghbln kghbln changed the title DisplayTitleHooks.php: Call to a member function isTalkPage() on null "DisplayTitleHooks.php": Call to a member function isTalkPage() on null Jul 21, 2019
@kghbln
Copy link
Member

kghbln commented Jul 21, 2019

FYI

Thanks for the note. Reported with task T228595.

@kghbln
Copy link
Member

kghbln commented Jul 24, 2019

@mwjames I checked out the patch on sandbox. Could you please check if this fixes the issue? Admittedly I was not able to create the stacktrace form the link provided so I just trusted you on this one when reporting.

@mwjames
Copy link
Author

mwjames commented Jul 24, 2019 via email

@kghbln
Copy link
Member

kghbln commented Jul 24, 2019

@mwjames Thanks for your swift reply. I will report the issue as fixed for DisplayTitle and will report an now one for Translate. Eventually paradise will be regained.

  • Condition [[Has number::+]] - Printout: Has number - Format: graph

Ah, and I thought just calling the page would create the issue.

@kghbln
Copy link
Member

kghbln commented Jul 24, 2019

Reported with T228881.

@cicalese
Copy link

cicalese commented Jul 24, 2019

I ran the two issues by one of our engineers to try to get at the root cause. The response: "I'd look for a code path that is getting into those hooks without having triggered a call to Parser->startParse(). I see both bugs include a call from "extensions/SemanticResultFormats" to Parser->recursiveTagParse(string) downstream of SMW's "Special:Ask"; probably someone involved in one of those two components either forgot to call Parser->startExternalParse() or is incorrectly calling some code that is intended to be called only from parser hooks."

In each of the stack traces, I find a line of the form:
$result = $GLOBALS['wgParser']->recursiveTagParse( "<graphviz>$graphInput</graphviz>" );
in SemanticResultFormats (at SemanticResultFormats/formats/graphviz/SRF_Graph.php" (136) and "SemanticResultFormats/src/Graph/GraphPrinter.php" (152)). Perhaps adding a call to $GLOBALS['wgParser']->startExternalParse(...) before those lines would help?

@kghbln
Copy link
Member

kghbln commented Jul 25, 2019

@cicalese Thanks for digging into this and notifying us here. Lucky us the "graph" format is currently being refactored (SemanticMediaWiki/SemanticResultFormats#503), this I will notify folks of your findings to add this further improvement for the future.

@mwjames
Copy link
Author

mwjames commented Jul 25, 2019 via email

@cicalese
Copy link

Agreed that if there is a dependency upon Parser->startExternalParse(), it should be documented. It would be good to know if adding that does indeed help your situation or whether there is some other root cause. If it does help, we could propose a change to the documentation to indicate that. Otherwise, we would still need to look further for a root cause. I initially was wondering whether the fact that the code is invoked from a special page when the problem manifests itself is material, but perhaps that is not related.

@mwjames
Copy link
Author

mwjames commented Jul 26, 2019 via email

@SbstnS
Copy link

SbstnS commented Jul 26, 2019

@cicalese As I'm working on the graph format I've tried to add the $GLOBALS['wgParser']->startExternalParse(...) before calling the $GLOBALS['wgParser']->recursiveTagParse() [0] as you recommended but now it won't render the parser function anymore instead it prints out the raw syntax of graphViz.

//GraphPrinter.php [0]

$GLOBALS['wgParser']->startExternalParse(null, ParserOptions::newFromUser( $GLOBALS['wgUser'] ), Parser::OT_WIKI );

// Calls graphvizParserHook function from MediaWiki GraphViz extension
$result = $GLOBALS['wgParser']->recursiveTagParse( "<graphviz>$graphInput</graphviz>" );`

With this approach I also get an error when calling the graph format under the "Special:Ask" page.

@cicalese
Copy link

@RacoonDev I'm wondering if the reason it is not rendering the parser function is that you are passing in Parser::OT_WIKI rather than Parser::OT_HTML.

Is the error you are getting related to the title being null? Did you try passing in the Title object rather than null for the first parameter?

@cicalese
Copy link

@mwjames

From my quick inspection of [0], I think this assumption is hitting a mark given those embedded in a wiki page do display correctly without an exception meaning the use of Parser::recursiveTagParse is inconsistent when it comes to the context of its execution.

Agreed. Perhaps there is something different in the way the Parser object is constructed for special pages.

@kghbln
Copy link
Member

kghbln commented Oct 16, 2019

The fix probably caused SemanticMediaWiki/SemanticMediaWiki#4330

@mwjames
Copy link
Author

mwjames commented Oct 16, 2019 via email

@kghbln
Copy link
Member

kghbln commented Apr 13, 2020

Fixed last year with https://gerrit.wikimedia.org/r/525191

@kghbln kghbln closed this as completed Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue site - s-mw.org - sandbox sandbox.semantic-mediawiki.org (99071) upstream An issue caused by MediaWiki
Projects
None yet
Development

No branches or pull requests

4 participants