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

GeoJson page after update 1.39.3 broken #734

Closed
RogueVortex opened this issue Apr 1, 2023 · 16 comments
Closed

GeoJson page after update 1.39.3 broken #734

RogueVortex opened this issue Apr 1, 2023 · 16 comments
Labels

Comments

@RogueVortex
Copy link

Hello.
After updating the wiki to 1.39.3 and extension maps 10.0.0, I encountered the fact that these pages of this type give an error of the following nature:

[{reqId}] {exception_url} LogicException: This ParserOutput contains no text!

Backtrace:

from /public_html/w/includes/parser/ParserOutput.php(363)
#0 /public_html/w/extensions/Maps/src/Presentation/OutputFacade.php(33): ParserOutput->getRawText()
#1 /public_html/w/extensions/Maps/src/GeoJsonPages/GeoJsonMapPageUi.php(23): Maps\Presentation\OutputFacade->addHtml()
#2 /public_html/w/extensions/Maps/src/GeoJsonPages/GeoJsonContent.php(62): Maps\GeoJsonPages\GeoJsonMapPageUi->addToOutput()
#3 /public_html/w/extensions/Maps/src/GeoJsonPages/GeoJsonContent.php(56): Maps\GeoJsonPages\GeoJsonContent->addMapHtmlToOutput()
#4 /public_html/w/includes/content/AbstractContent.php(590): Maps\GeoJsonPages\GeoJsonContent->fillParserOutput()
#5 /public_html/w/includes/content/ContentHandler.php(1883): AbstractContent->getParserOutput()
#6 /public_html/w/includes/content/ContentHandler.php(1698): ContentHandler->callDeprecatedContentGPO()
#7 /public_html/w/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput()
#8 /public_html/w/includes/Revision/RenderedRevision.php(266): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#9 /public_html/w/includes/Revision/RenderedRevision.php(237): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached()
#10 /public_html/w/includes/Revision/RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput()
#11 /public_html/w/includes/Revision/RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput()
#12 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}()
#13 /public_html/w/includes/Revision/RenderedRevision.php(199): call_user_func()
#14 /public_html/w/includes/poolcounter/PoolWorkArticleView.php(91): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#15 /public_html/w/includes/poolcounter/PoolWorkArticleView.php(72): PoolWorkArticleView->renderRevision()
#16 /public_html/w/includes/poolcounter/PoolCounterWork.php(162): PoolWorkArticleView->doWork()
#17 /public_html/w/includes/page/ParserOutputAccess.php(299): PoolCounterWork->execute()
#18 /public_html/w/includes/page/Article.php(714): MediaWiki\Page\ParserOutputAccess->getParserOutput()
#19 /public_html/w/includes/page/Article.php(528): Article->generateContentOutput()
#20 /public_html/w/includes/actions/ViewAction.php(78): Article->view()
#21 /public_html/w/includes/MediaWiki.php(542): ViewAction->show()
#22 /public_html/w/includes/MediaWiki.php(322): MediaWiki->performAction()
#23 /public_html/w/includes/MediaWiki.php(904): MediaWiki->performRequest()
#24 /public_html/w/includes/MediaWiki.php(562): MediaWiki->main()
#25 /public_html/w/index.php(50): MediaWiki->run()
#26 /public_html/w/index.php(46): wfIndexMain()
#27 {main}

In an attempt to solve the problem, I turned to the ParserOutput.php file and commented out the error throw, as a result, the pages started working.

public function getRawText() {
		//if ( $this->mText === null ) {
		//	throw new LogicException( 'This ParserOutput contains no text!' );
		//}

		return $this->mText;
	}

But I don't think it's a good solution, do you have any idea how to deal with it?
Thank you.

@RogueVortex
Copy link
Author

RogueVortex commented Apr 3, 2023

@JeroenDeDauw Any thoughts on how to fix this better?

@JeroenDeDauw
Copy link
Member

I do not have the capacity to look into this issue at the moment

@RogueVortex
Copy link
Author

I do not have the capacity to look into this issue at the moment

Okay, but I'll look forward to solving this problem)
Good luck.

@RogueVortex
Copy link
Author

@JeroenDeDauw sorry for my persistence and for the fact that I tag you again.

I analyzed the changes in the current version of the wiki and found out that the default value was changed here:

/**
	 * @param string|null $text HTML. Use null to indicate that this ParserOutput contains only
	 *        meta-data, and the HTML output is undetermined, as opposed to empty. Passing null
	 *        here causes hasText() to return false. In 1.39 the default value changed from ''
	 *        to null.
	 * @param array $languageLinks
	 * @param array $categoryLinks
	 * @param bool $unused
	 * @param string $titletext
	 */
	public function __construct( $text = null, $languageLinks = [], $categoryLinks = [],
		$unused = false, $titletext = ''
	) {
		$this->mText = $text;
		$this->mLanguageLinks = $languageLinks;
		$this->mCategories = $categoryLinks;
		$this->mTitleText = $titletext;
	}

hence the called function from parseroutput returns null in this maps extension function

$this->parserOutput->getRawText()

	public function addHtml( string $html ) {
		if ( $this->outputPage !== null ) {
			$this->outputPage->addHTML( $html );
		}

		if ( $this->parserOutput !== null ) {
			$this->parserOutput->setText( $this->parserOutput->getRawText() . $html );
		}
	}

when I converted the function by removing the above call, everything worked, is it possible to fix the error like this?

	public function addHtml( string $html ) {
		if ( $this->outputPage !== null ) {
			$this->outputPage->addHTML( $html );
		}

		if ( $this->parserOutput !== null ) {
			$this->parserOutput->setText( $html );
		}
	}

Thank you

@D-Groenewegen
Copy link
Contributor

I'm having the same issue (MW 1.39.2) so thanks for reporting and coming up with a solution. I don't know if there are real scenarios when $this->mText is available (maybe from caching). If so, a minor variant could be this:

	/*
	 * @param string $html
	 * @return string
	 */
	public function addHtml( string $html ) {
		if ( $this->outputPage !== null ) {
			$this->outputPage->addHTML( $html );
		}

		if ( $this->parserOutput !== null ) {
			$rawText = ( isset( $this->mText ) && $this->mText !== null ) ? $this->parserOutput->getRawText() : '';
			$this->parserOutput->setText( $rawText . $html );
		}
	}

@krabina
Copy link
Contributor

krabina commented Sep 25, 2023

@RogueVortex and @D-Groenewegen do you have plans to come up with a PR for this? I am having the same issue and a PR wold be easier to test.

@RogueVortex
Copy link
Author

@RogueVortex and @D-Groenewegen do you have plans to come up with a PR for this? I am having the same issue and a PR wold be easier to test.

I'm not competent enough in this matter

@redheadkelly
Copy link

Having the same issue with MediaWiki 1.39.4 and Maps 10.

@D-Groenewegen
Copy link
Contributor

Sorry, I have not been in the loop on what's happening on Github lately, but I will look into it.

@D-Groenewegen
Copy link
Contributor

D-Groenewegen commented Oct 15, 2023

P.S. Okay so the issue was already fixed in master in February this year. We just haven't seen a new release of Maps since Oct. 2022. What would it take to release a new version, even a minor fixes-only one, maybe in time for the next SMWCon?

If you can't wait for this, just head to Maps/src/Presentation/OutputFacade.php > addHtml

and replace

$this->parserOutput->setText( $this->parserOutput->getRawText() . $html );

with

$existingText = $this->parserOutput->hasText() ? $this->parserOutput->getRawText() : '';
$this->parserOutput->setText( $existingText . $html );

@JeroenDeDauw
Copy link
Member

You can help me make the release by adding the user-relevant changes to the release notes at https://github.com/ProfessionalWiki/Maps/blob/master/RELEASE-NOTES.md

@redheadkelly
Copy link

redheadkelly commented Oct 15, 2023 via email

@krabina
Copy link
Contributor

krabina commented Oct 17, 2023

I upgraded to "dev-master" in composer. Maps shows as version 10.1.0, but the problem still persists. The GeoJson: namespace results in errors.

[2058836af5ee24e2f81e0c87] /GeoJson:Wasserleitungen GeoJson\Exception\UnserializationException: GeoJson expected value of type array or object, null given

Backtrace:

from /vendor/jmikola/geojson/src/Exception/UnserializationException.php(24)
#0 /vendor/jmikola/geojson/src/GeoJson.php(77): GeoJson\Exception\UnserializationException::invalidValue()
#1 /extensions/Maps/src/GeoJsonPages/Semantic/SubObjectBuilder.php(21): GeoJson\GeoJson::jsonUnserialize()
#2 /extensions/Maps/src/GeoJsonPages/Semantic/SemanticGeoJsonStore.php(29): Maps\GeoJsonPages\Semantic\SubObjectBuilder->getSubObjectsFromGeoJson()
#3 /extensions/Maps/src/GeoJsonPages/GeoJsonContentHandler.php(49): Maps\GeoJsonPages\Semantic\SemanticGeoJsonStore->storeGeoJson()
#4 /includes/content/ContentHandler.php(1721): Maps\GeoJsonPages\GeoJsonContentHandler->fillParserOutput()
#5 /includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput()
#6 /includes/Revision/RenderedRevision.php(266): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#7 /includes/Revision/RenderedRevision.php(237): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached()
#8 /includes/Revision/RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput()
#9 /includes/Revision/RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput()
#10 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}()
#11 /includes/Revision/RenderedRevision.php(199): call_user_func()
#12 /includes/poolcounter/PoolWorkArticleView.php(91): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#13 /includes/poolcounter/PoolWorkArticleView.php(72): PoolWorkArticleView->renderRevision()
#14 /includes/poolcounter/PoolCounterWork.php(162): PoolWorkArticleView->doWork()
#15 /includes/page/ParserOutputAccess.php(299): PoolCounterWork->execute()
#16 /includes/page/Article.php(714): MediaWiki\Page\ParserOutputAccess->getParserOutput()
#17 /includes/page/Article.php(528): Article->generateContentOutput()
#18 /includes/actions/ViewAction.php(78): Article->view()
#19 /includes/MediaWiki.php(542): ViewAction->show()
#20 /includes/MediaWiki.php(322): MediaWiki->performAction()
#21 /includes/MediaWiki.php(904): MediaWiki->performRequest()
#22 /includes/MediaWiki.php(562): MediaWiki->main()
#23 /index.php(50): MediaWiki->run()
#24 /index.php(46): wfIndexMain()
#25 {main}

@D-Groenewegen
Copy link
Contributor

It looks like a new issue though. When the JSON string is decoded in GeoJson::jsonUnserialize(), it doesn't appear to produce a valid output. Maybe it has something to do with the update to GeoJsonContentHandler.php in the latest version but I would need to install it somewhere to test for myself.

@thomas-topway-it
Copy link
Contributor

thomas-topway-it commented Oct 27, 2023

see #756
and
#757 (pull request)

@krabina
Copy link
Contributor

krabina commented Jan 31, 2024

Can be closed IMO, since it is working now:
https://maps.extension.wiki/wiki/GeoJson:Berlin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants