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

Error from line 306 in "RecurringEvents.php": Call to undefined method SMWDIError::getJD() #3598

Closed
kghbln opened this issue Jan 12, 2019 · 6 comments
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Milestone

Comments

@kghbln
Copy link
Member

kghbln commented Jan 12, 2019

Setup and configuration

  • MediaWiki | 1.32.0 (0fbb878)23:05, 10. Jan. 2019
  • PHP | 7.0.33-0+deb9u1 (apache2handler)
  • MariaDB | 10.1.37-MariaDB-0+deb9u1
  • Semantic MediaWiki | 3.1.0-alpha (9c19d87) 10:17, 7. Jan. 2019

Issue

[6585d43e04160c2a723783e7] /w/index.php?title=Issue/3541/2&action=submit Error from line 306 of /.../w/extensions/SemanticMediaWiki/includes/RecurringEvents.php: Call to undefined method SMWDIError::getJD()

Stack trace

#0 /.../w/extensions/SemanticMediaWiki/includes/RecurringEvents.php(61): SMW\RecurringEvents->parse(array)
#1 /.../w/extensions/SemanticMediaWiki/src/ParserFunctions/RecurringEventsParserFunction.php(122): SMW\RecurringEvents->__construct(array)
#2 /.../w/extensions/SemanticMediaWiki/src/ParserFunctions/RecurringEventsParserFunction.php(79): SMW\ParserFunctions\RecurringEventsParserFunction->initRecurringEvents(array)
#3 /.../w/extensions/SemanticMediaWiki/src/ParserFunctionFactory.php(452): SMW\ParserFunctions\RecurringEventsParserFunction->parse(SMW\ParserParameterProcessor)
#4 /.../w/includes/parser/Parser.php(3493): SMW\ParserFunctionFactory->SMW\{closure}(Parser, string, string, string, string)
#5 /.../w/includes/parser/Parser.php(3200): Parser->callParserFunction(PPFrame_DOM, string, array)
#6 /.../w/includes/parser/Preprocessor_DOM.php(1279): Parser->braceSubstitution(array, PPFrame_DOM)
#7 /.../w/includes/parser/Parser.php(3014): PPFrame_DOM->expand(DOMElement, integer)
#8 /.../w/includes/parser/Parser.php(1350): Parser->replaceVariables(string)
#9 /.../w/includes/parser/Parser.php(476): Parser->internalParse(string)
#10 /.../w/includes/content/WikitextContent.php(341): Parser->parse(string, Title, ParserOptions, boolean, boolean, NULL)
#11 /.../w/includes/content/AbstractContent.php(517): WikitextContent->fillParserOutput(Title, NULL, ParserOptions, boolean, ParserOutput)
#12 /.../w/includes/Revision/RenderedRevision.php(242): AbstractContent->getParserOutput(Title, NULL, ParserOptions, boolean)
#13 /.../w/includes/Revision/RenderedRevision.php(211): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean)
#14 /.../w/includes/Revision/RevisionRenderer.php(175): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string)
#15 /.../w/includes/Revision/RevisionRenderer.php(128): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)
#16 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#17 /.../w/includes/Revision/RenderedRevision.php(175): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)
#18 /.../w/includes/Storage/DerivedPageDataUpdater.php(1265): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#19 /.../w/includes/Storage/DerivedPageDataUpdater.php(1235): MediaWiki\Storage\DerivedPageDataUpdater->getCanonicalParserOutput()
#20 /.../w/includes/page/WikiPage.php(1994): MediaWiki\Storage\DerivedPageDataUpdater->getPreparedEdit()
#21 /.../w/extensions/SpamBlacklist/includes/SpamBlacklistHooks.php(31): WikiPage->prepareContentForEdit(WikitextContent)
#22 /.../w/includes/Hooks.php(174): SpamBlacklistHooks::filterMergedContent(RequestContext, WikitextContent, Status, string, User, boolean)
#23 /.../w/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#24 /.../w/includes/EditPage.php(1747): Hooks::run(string, array)
#25 /.../w/includes/EditPage.php(2066): EditPage->runPostMergeFilters(WikitextContent, Status, User)
#26 /.../w/includes/EditPage.php(1574): EditPage->internalAttemptSave(NULL, boolean)
#27 /.../w/includes/EditPage.php(677): EditPage->attemptSave(NULL)
#28 /.../w/includes/actions/EditAction.php(60): EditPage->edit()
#29 /.../w/includes/actions/SubmitAction.php(38): EditAction->show()
#30 /.../w/includes/MediaWiki.php(501): SubmitAction->show()
#31 /.../w/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#32 /.../w/includes/MediaWiki.php(860): MediaWiki->performRequest()
#33 /.../w/includes/MediaWiki.php(517): MediaWiki->main()
#34 /.../w/index.php(42): MediaWiki->run()
#35 {main}

Steps to reproduce

Trying to add something like

{{#set_recurring_event: Is team meeting |property=Has date |start=30 janvier 2019 9:30 am |unit=month }}

or

{{#set_recurring_event: Is team meeting |property=Has date |start=31 janvier 2019 9:30 am |unit=month }}

will cause the issue.

@kghbln kghbln added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Jan 12, 2019
@kghbln
Copy link
Member Author

kghbln commented Jan 12, 2019

29 is working and falls back to 28 in February if it does not have a 29.

Strictly spoken 29, 30 and 31 should not be created in case the month does not have these days. However this would be a breaking change since 29.02. falls back to 28.02. Thus the fix should probably create a fall-back to the last day in the month for consistency reasons. Moreover one should probably not use the month option to the unit parameter in the first place if months should be skipped or alternatively use the exclude and include parameters. I am not absolutely sure what the most intuitive approach is here.

@JeroenDeDauw
Copy link
Member

As a user I'd expect a recurring date on the 31st to always happen at the last day of a month. If there is no such fallback then you also can't make a recurring event for just that: "last day of each month".

@mwjames
Copy link
Contributor

mwjames commented Jan 12, 2019

... from line 306 of /.../w/extensions/SemanticMediaWiki/includes/RecurringEvents.php: Call to undefined method SMWDIError::getJD()

Caused by $cur_date_jd = $cur_date->getDataItem()->getJD(); and the code in question is as old as the #set_recurring_event itself.

How to fix it?

Adding the following changes should be sufficient.

if ( $cur_date->isValid() ) {
	$cur_date_jd = $cur_date->getDataItem()->getJD();
}

This should ensure that you'll get something like:

image

Thus the fix should probably create a fall-back to the last day in the month for consistency reasons. Moreover one should probably not use the month option to the unit parameter in the first place if months should be skipped or alternatively use the exclude and include parameters. I am not absolutely sure what the most intuitive approach is here.

Haven't look at it, my main concern is to avoid a hard failure which excludes possible logic or application errors in the function itself.

@kghbln
Copy link
Member Author

kghbln commented Jan 12, 2019

Ok, let's assume that we all agree that a recurring event for the 29th, 30th and 31st needs to be on the last day of the month instead if the respective month does not have that date. This is in line with the current behaviour for the 29th and I will document accordingly.

@kghbln
Copy link
Member Author

kghbln commented Jan 12, 2019

Documented

@kghbln kghbln changed the title #set_recurring_event: fails for monthly events starting at 30 and 31 Error from line 306 in "RecurringEvents.php": Call to undefined method SMWDIError::getJD() Jan 12, 2019
@kghbln
Copy link
Member Author

kghbln commented Jan 12, 2019

The pull fails, so let's decouple the issue. First we prevent the wiki from going berserk and than let's see what actually happens and create an new issue rather than drawing conclusions as to what the cause may be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Projects
None yet
Development

No branches or pull requests

3 participants