Page MenuHomePhabricator

Call to protected method Article::getContentObject() from context 'WidgetRenderer'
Closed, ResolvedPublic


Widgets fail to run after upgrade to MW 1.27:

Error from line 176 of /usr/share/mediawiki/extensions-extra/Widgets/WidgetRenderer.php: Call to protected method Article::getContentObject() from context 'WidgetRenderer'

Ubuntu 16.04
Git commit: * 184aa1b 2017-01-09

Specifically Widgets for Google Calendar, which worked on 1.19.x

#0 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_resource_registered.php(80): WidgetRenderer::wiki_get_template(string, NULL, Smarty)
#1 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_template_source.php(265): Smarty_Internal_Resource_Registered->getContent(Smarty_Template_Source)
#2 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(390): Smarty_Template_Source->getContent()
#3 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(328): Smarty_Internal_TemplateCompilerBase->compileTemplateSource(Smarty_Internal_Template, boolean, NULL)
#4 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_template_compiled.php(236): Smarty_Internal_TemplateCompilerBase->compileTemplate(Smarty_Internal_Template)
#5 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_template_compiled.php(123): Smarty_Template_Compiled->compileTemplateSource(Smarty_Internal_Template)
#6 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_template_compiled.php(193): Smarty_Template_Compiled->process(Smarty_Internal_Template)
#7 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_template.php(159): Smarty_Template_Compiled->render(Smarty_Internal_Template)
#8 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_templatebase.php(191): Smarty_Internal_Template->render(boolean, integer)
#9 /usr/share/mediawiki/extensions-extra/Widgets/smarty/libs/sysplugins/smarty_internal_templatebase.php(94): Smarty_Internal_TemplateBase->_execute(Smarty_Internal_Template, NULL, NULL, NULL, integer)
#10 /usr/share/mediawiki/extensions-extra/Widgets/WidgetRenderer.php(131): Smarty_Internal_TemplateBase->fetch(string)
#11 /usr/share/mediawiki/includes/parser/Parser.php(3817): WidgetRenderer::renderWidget(Parser, string, string, string, string, string, string)
#12 /usr/share/mediawiki/includes/parser/Parser.php(3552): Parser->callParserFunction(PPFrame_DOM, string, array)
#13 /usr/share/mediawiki/includes/parser/Preprocessor_DOM.php(1175): Parser->braceSubstitution(array, PPFrame_DOM)
#14 /usr/share/mediawiki/includes/parser/Parser.php(3366): PPFrame_DOM->expand(DOMElement, integer)
#15 /usr/share/mediawiki/includes/parser/Parser.php(1248): Parser->replaceVariables(string)
#16 /usr/share/mediawiki/includes/parser/Parser.php(446): Parser->internalParse(string)
#17 /usr/share/mediawiki/includes/content/WikitextContent.php(331): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#18 /usr/share/mediawiki/includes/content/AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#19 /usr/share/mediawiki/includes/poolcounter/PoolWorkArticleView.php(139): AbstractContent->getParserOutput(Title, integer, ParserOptions)
#20 /usr/share/mediawiki/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork()
#21 /usr/share/mediawiki/includes/page/Article.php(666): PoolCounterWork->execute()
#22 /usr/share/mediawiki/includes/actions/ViewAction.php(44): Article->view()
#23 /usr/share/mediawiki/includes/MediaWiki.php(503): ViewAction->show()
#24 /usr/share/mediawiki/includes/MediaWiki.php(288): MediaWiki->performAction(Article, Title)
#25 /usr/share/mediawiki/includes/MediaWiki.php(745): MediaWiki->performRequest()
#26 /usr/share/mediawiki/includes/MediaWiki.php(519): MediaWiki->main()
#27 /usr/share/mediawiki/index.php(43): MediaWiki->run()
#28 {main}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 11 2017, 12:18 PM
Kghbln renamed this task from Widges fail to run after upgrade to 1.1.27 to Widges fail to run after upgrade to 1.27.x.Jan 11 2017, 12:37 PM
Kghbln updated the task description. (Show Details)
Kghbln added a subscriber: Yaron_Koren.EditedJan 11 2017, 12:44 PM
Kghbln added a subscriber: Kghbln.

I cannot confirm this for the following setup:

  • MediaWiki 1.27.1 (8c593e7) 23:49, 26 October 2016
  • PHP 5.6.29-0+deb8u1 (apache2handler)
  • MariaDB 10.0.28-MariaDB-1~jessie
  • Widgets 1.2.1 (ad556d0) 18:44, 9 November 2015

Two things are different at your end. You run PHP 7 and you run master. Since you run master it could be that rEWID28b4ebd76df4e75cd045427a98a01c622ffc6130 is breaking for MW 1.27 and requires MW 1.28. What happens if you run REL1_27 (rEWIDd8a7814b5ed055b34c6d8ac4d568fb1b6872fa85) or even better use the 1.2.1 tag (rEWIDad556d04cc203393b2c3ddc44c39db8671442be7)?

Kghbln renamed this task from Widges fail to run after upgrade to 1.27.x to Call to protected method Article::getContentObject() from context 'WidgetRenderer'.Jan 11 2017, 12:48 PM
Kghbln updated the task description. (Show Details)
Kghbln updated the task description. (Show Details)
Kghbln triaged this task as Medium priority.Jan 11 2017, 12:52 PM

Now working after the following:

#  cd /usr/share/mediawiki/extensions-extra/Widgets/
#  git checkout tags/1.2.1
#  vi /etc/mediawiki/LocalSettings.php

Last line is to re-enable widgets.

Kghbln lowered the priority of this task from Medium to Low.Jan 11 2017, 8:32 PM

@Andrew.Pickin Thanks for reporting back. Great that you have a working setup now.

Still keeping this open until I tested how master reacts with MW 1.28. Probably for this release onwards a 1.3.0 tag has to be created.

Kghbln added a comment.EditedJan 11 2017, 10:50 PM

I just tested on a MW 1.28 install and current master is working. Indeed rEWID184aa1b0901e45887086689ffffa15242c31a93b (T151973) is breaking for <= MW 1.27. I presume that version 1.2.1 (rEWIDad556d04cc203393b2c3ddc44c39db8671442be7) will no longer work for MW 1.29 so in June 2017 a new version will have to be tagged to restore compatibility.

The same error occurs with the current Widgets master and the (1.29alpha) Mediawiki master. Since the deprecated getContent() has since been removed, for now it seems to be impossible to use the Widgets extension with MW1.29.

Kghbln added a comment.EditedFeb 2 2017, 2:37 PM

@janboehme Are you sure that you are running current Widgets master? getContent() was removed from the Widgets extension with rEWID28b4ebd76df4e75cd045427a98a01c622ffc6130 in December last year.

janboehme added a comment.EditedFeb 2 2017, 2:41 PM

@Kghbln Sure. Now we're calling getContentObject() and thus the error is /usr/share/mediawiki/extensions-extra/Widgets/WidgetRenderer.php: Call to protected method Article::getContentObject() from context 'WidgetRenderer'. But, since the deprecated method has been removed from the MW Code, we can't go back to using the older Widgets release.

Kghbln raised the priority of this task from Low to Medium.Feb 2 2017, 2:42 PM

@janboehme Ah, I see. Patch welcome. I am sure that @Yaron_Koren will have a look at it and merge.

Yes, definitely! Sorry about the problem - I'd be happy to have this fixed in whatever way possible.

Joshuaaaron added a subscriber: Joshuaaaron.EditedApr 3 2017, 3:00 PM

@Yaron_Koren @Kghbln I just ran into this today. It appears that the code using getContentObject() was essentially cribbed from the implementation of the (now removed) getContent(). The docs on Article::getContent() include the note to "use WikiPage::getContent() instead". I'm not familiar enough with MediaWiki code or the Widgets extension to be sure whether this is a correct fix, but this patch seems to be working for me:

diff --git a/WidgetRenderer.php b/WidgetRenderer.php
index b741d09..27db8ad 100644
--- a/WidgetRenderer.php
+++ b/WidgetRenderer.php
@@ -172,8 +172,8 @@ class WidgetRenderer {
                                        $widgetCode = '';
                        } else {
-                               $widgetArticle = new Article( $widgetTitle );
-                               $widgetContent = $widgetArticle->getContentObject();
+                               $widgetWikiPage = new WikiPage( $widgetTitle );
+                               $widgetContent = $widgetWikiPage->getContent();
                                $widgetCode = ContentHandler::getContentText( $widgetContent );

I did too...
Using WikiPage->getContent() is indeed the new recommended method (see docs/contenthandler.txt). I'll submit the above patch for review in a few moments.

Change 348220 had a related patch set uploaded (by FreedomFighterSparrow):
[mediawiki/extensions/Widgets@master] v1.2.2: restore compatibility with MW 1.27 after commit 28b4ebd

Change 348220 merged by jenkins-bot:
[mediawiki/extensions/Widgets@master] v1.2.2: restore compatibility with MW 1.27 after commit 28b4ebd

Kghbln closed this task as Resolved.Apr 14 2017, 9:50 PM
Kghbln assigned this task to FreedomFighterSparrow.

Cool, back in business for MW 1.28 I believe. :) @Yaron_Koren Just the tag is missing but this is not a holdup for closing.

@Yaron_Koren It will be nice if you could tag. Thanks!

Kghbln reopened this task as Open.May 31 2017, 8:57 PM

Untagged. So this is still open. Sorry for prematurely closing this.

Kghbln closed this task as Resolved.Aug 3 2017, 1:49 PM

Superseded by a new version. Still wondering why this was never tagged.

You probably need to send @Yaron_Koren an email directly. His email is on every one of his extensions' pages.