samwilson / diagrams-extension

A MediaWiki extension that displays GraphViz, Mscgen, PlantUML, and Mermaid diagrams in wiki pages.
https://www.mediawiki.org/wiki/Extension:Diagrams
GNU General Public License v2.0
8 stars 11 forks source link

Fixing issue where isPreview would be false, even when previewing the edit #68

Closed YOUR1 closed 1 year ago

YOUR1 commented 1 year ago

Tested and its working as it should now. GraphViz is now working without any bugs.

YOUR1 commented 1 year ago

Pinging @samwilson so we can tag a new version with this fix (and I could actually use it in production :) )

YOUR1 commented 1 year ago

Thanks for working on this. Could you please explain a bit more about the bug you're experiencing? i.e. what is happening, and how do you replicate it. Your other PR (#62) seems to have been about the same issue.

The commit message should explain why there's a difference between calling this on the Parser object passed to the ParserFirstCallInit hook and calling it on the main Parser service.

No problem. The issue is fairly easy to reproduce:

A error will occur now and then, saying that the file already exists, thus isn't showed.

The underlying problem for this issue is that the isPreview-bool is always false. This is because the parserCallFirstInit hook is called BEFORE the isPreview boolean is set correctly. To workaround this issue, I used MediaWikiServers::getInstance()->getParser(), since it has the 'correct' object.

YOUR1 commented 1 year ago

Pinging @samwilson to review the updated version.