Steps to replicate the issue (include links if applicable):
- Install MediaWiki and the timeline/EasyTimeline extension
- Write the wikitext <timeline></timeline> on some page and preview
What happens?:
MediaWiki issues an exception Shellbox\ShellboxError: Unable to write file and does not display the preview (full backtrace below).
What should have happened instead?:
MediaWiki should display the preview (with a generation error displayed at the location of the empty <timeline> tag).
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
- MediaWiki 1.47.0-alpha d260740a0463
- EasyTimeline 85f14da
- Shellbox 4.4.0 c0605da2
Other information (browser name/version, screenshots, etc.):
There is no issue when you write the wikitext <timeline> </timeline> (NB: one space inside the tags): the preview is correctly displayed with a generation error at the location of the almost-empty <timeline> tag.
Why this behaviour?
In Shellbox\FileUtils::putContents( $path, $contents ) (code on GitHub), the function file_put_contents returns the number of bytes written, so when you write an empty file the returned number is zero, and the condition if ( !file_put_contents( $path, $contents ) ) is wrongly triggered, and it is said the file is not written (although it is written but empty).
Exception
[907057ef454ce2b80d29243f] /w/index.php?title=Accueil&action=submit Shellbox\ShellboxError: Unable to write file
Backtrace:
from /opt/mediawiki/vendor/wikimedia/shellbox/src/FileUtils.php(57)
#0 /opt/mediawiki/vendor/wikimedia/shellbox/src/Command/InputFileFromString.php(23): Shellbox\FileUtils::putContents()
#1 /opt/mediawiki/vendor/wikimedia/shellbox/src/Command/LocalBoxedExecutor.php(127): Shellbox\Command\InputFileFromString->copyTo()
#2 /opt/mediawiki/vendor/wikimedia/shellbox/src/Command/LocalBoxedExecutor.php(60): Shellbox\Command\LocalBoxedExecutor->createInputFiles()
#3 /opt/mediawiki/vendor/wikimedia/shellbox/src/Command/BoxedExecutor.php(20): Shellbox\Command\LocalBoxedExecutor->executeValid()
#4 /opt/mediawiki/vendor/wikimedia/shellbox/src/Command/BoxedCommand.php(406): Shellbox\Command\BoxedExecutor->execute()
#5 /opt/mediawiki/extensions/timeline/includes/Timeline.php(188): Shellbox\Command\BoxedCommand->execute()
#6 /opt/mediawiki/extensions/timeline/includes/Timeline.php(86): MediaWiki\Extension\Timeline\Timeline::renderTimeline()
#7 /opt/mediawiki/includes/Parser/Parser.php(3989): MediaWiki\Extension\Timeline\Timeline::onTagHook()
#8 /opt/mediawiki/includes/Parser/PPFrame_Hash.php(345): MediaWiki\Parser\Parser->extensionSubstitution()
#9 /opt/mediawiki/includes/Parser/Parser.php(2879): MediaWiki\Parser\PPFrame_Hash->expand()
#10 /opt/mediawiki/includes/Parser/Parser.php(1500): MediaWiki\Parser\Parser->replaceVariables()
#11 /opt/mediawiki/includes/Parser/Parser.php(621): MediaWiki\Parser\Parser->internalParse()
#12 /opt/mediawiki/includes/Content/WikitextContentHandler.php(360): MediaWiki\Parser\Parser->parse()
#13 /opt/mediawiki/includes/Content/ContentHandler.php(1574): MediaWiki\Content\WikitextContentHandler->fillParserOutput()
#14 /opt/mediawiki/includes/Content/Renderer/ContentRenderer.php(62): MediaWiki\Content\ContentHandler->getParserOutput()
#15 /opt/mediawiki/includes/EditPage/EditPage.php(3427): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#16 /opt/mediawiki/includes/EditPage/EditPage.php(3320): MediaWiki\EditPage\EditPage->doPreviewParse()
#17 /opt/mediawiki/includes/EditPage/EditPage.php(2292): MediaWiki\EditPage\EditPage->getPreviewText()
#18 /opt/mediawiki/includes/EditPage/EditPage.php(690): MediaWiki\EditPage\EditPage->showEditForm()
#19 /opt/mediawiki/includes/Actions/EditAction.php(55): MediaWiki\EditPage\EditPage->edit()
#20 /opt/mediawiki/includes/Actions/SubmitAction.php(29): MediaWiki\Actions\EditAction->show()
#21 /opt/mediawiki/includes/Actions/ActionEntryPoint.php(755): MediaWiki\Actions\SubmitAction->show()
#22 /opt/mediawiki/includes/Actions/ActionEntryPoint.php(513): MediaWiki\Actions\ActionEntryPoint->performAction()
#23 /opt/mediawiki/includes/Actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#24 /opt/mediawiki/includes/MediaWikiEntryPoint.php(180): MediaWiki\Actions\ActionEntryPoint->execute()
#25 /opt/mediawiki/index.php(59): MediaWiki\MediaWikiEntryPoint->run()
#26 {main}