Page MenuHomePhabricator

Error from line 99 of "PF_CreateProperty.php": Call to a member function getDatatypeLabels() on null
Closed, ResolvedPublic

Description

Setup

  • MediaWiki 1.34.1 (d29905e)
  • PHP 7.2.24-0ubuntu0.18.04.3 (apache2handler)
  • MariaDB 10.1.44-MariaDB-0ubuntu0.18.04.1
  • Semantic MediaWiki 3.2.0-alpha (7f7e38c) 17:44, 29 March 2020
  • PageForms 4.8 (c20df12) 15:14, 27 March 2020

Issue

[cf783eb6b53258f16edd6fa7] /wiki/Sp%C3%A9cial:CreateProperty Error from line 99 of /../w/extensions/PageForms/specials/PF_CreateProperty.php: Call to a member function getDatatypeLabels() on null

Backtrace

#0 /../w/extensions/PageForms/specials/PF_CreateProperty.php(22): PFCreateProperty->printCreatePropertyForm(NULL)
#1 /../w/includes/specialpage/SpecialPage.php(575): PFCreateProperty->execute(NULL)
#2 /../w/includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run(NULL)
#3 /../w/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#4 /../w/includes/MediaWiki.php(900): MediaWiki->performRequest()
#5 /../w/includes/MediaWiki.php(527): MediaWiki->main()
#6 /../w/index.php(44): MediaWiki->run()
#7 {main}

Event Timeline

Kghbln created this task.Apr 1 2020, 8:59 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 1 2020, 8:59 PM

Also seeing this issue

Nikerabbit added a subscriber: Nikerabbit.

This is now causing errors on translatewiki.net, since we updated to SMW 3.2.0.

I'm not sure I can fix this, since I don't have access to a development environment running a recent version of SMW. But if anyone submits a patch to fix this, I'll be glad to check it in.

You may fix the bug by editing the effected files that are named in the error msg (e.g. [...]/extensions/PageForms/specials/PF_CreateClass.php)

At the line, stated in the error message there should be a code like this:

$possibleTypes = $smwgContLang->getDatatypeLabels();

the variable $smwgContLang is no longer available (thats why the error msg tells that the function "getDatatypeLabels" is called on null). change the code as following:

$possibleTypes = smwfContLang()->getDatatypeLabels();

This should get PageForms special pages back to work. (see https://phabricator.wikimedia.org/T246579)

Change 627794 had a related patch set uploaded (by Yaron Koren; owner: Yaron Koren):
[mediawiki/extensions/PageForms@master] Use smwfContLang() for SMW 3.2+

https://gerrit.wikimedia.org/r/627794

Change 627794 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Use smwfContLang() for SMW 3.2+

https://gerrit.wikimedia.org/r/627794

@KBailly - thanks for the suggested fix! I just checked in a fix based on this, which should hopefully work across different SMW versions. I haven't tested it, but hopefully things are working better now.

I tried applying the gerrit to the code on my machine and it doesn't work, it doesn't like the PF_Utils change.

[21-Sep-2020 13:58:09 UTC] PHP Warning:  method_exists() expects exactly 2 parameters, 1 given in /home/mediawiki/mediawiki-1.34.2/extensions/PageForms/includes/PF_Utils.php on line 29
[21-Sep-2020 13:58:09 UTC] PHP Stack trace:
[21-Sep-2020 13:58:09 UTC] PHP   1. {main}() /home/mediawiki/mediawiki-1.34.2/index.php:0
[21-Sep-2020 13:58:09 UTC] PHP   2. MediaWiki->run() /home/mediawiki/mediawiki-1.34.2/index.php:44
[21-Sep-2020 13:58:09 UTC] PHP   3. MediaWiki->main() /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php:527
[21-Sep-2020 13:58:09 UTC] PHP   4. MediaWiki->performRequest() /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php:900
[21-Sep-2020 13:58:09 UTC] PHP   5. MediaWiki\Special\SpecialPageFactory->executePath() /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php:296
[21-Sep-2020 13:58:09 UTC] PHP   6. PFCreateClass->run() /home/mediawiki/mediawiki-1.34.2/includes/specialpage/SpecialPageFactory.php:611
[21-Sep-2020 13:58:09 UTC] PHP   7. PFCreateClass->execute() /home/mediawiki/mediawiki-1.34.2/includes/specialpage/SpecialPage.php:575
[21-Sep-2020 13:58:09 UTC] PHP   8. PFUtils::getSMWContLang() /home/mediawiki/mediawiki-1.34.2/extensions/PageForms/specials/PF_CreateClass.php:218
[21-Sep-2020 13:58:09 UTC] PHP   9. method_exists() /home/mediawiki/mediawiki-1.34.2/extensions/PageForms/includes/PF_Utils.php:29

Which still gives the error now in browser

[X2ixcd7jem9@DQnya3pkGwAAAM8] /index.php?title=Special:CreateClass Error from line 218 of /home/mediawiki/mediawiki-1.34.2/extensions/PageForms/specials/PF_CreateClass.php: Call to a member function getDatatypeLabels() on null

Backtrace:

#0 /home/mediawiki/mediawiki-1.34.2/includes/specialpage/SpecialPage.php(575): PFCreateClass->execute()
#1 /home/mediawiki/mediawiki-1.34.2/includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run()
#2 /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath()
#3 /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php(900): MediaWiki->performRequest()
#4 /home/mediawiki/mediawiki-1.34.2/includes/MediaWiki.php(527): MediaWiki->main()
#5 /home/mediawiki/mediawiki-1.34.2/index.php(44): MediaWiki->run()
#6 {main}

I don't have gerrit setup at the moment - but its a 1 liner

[mediawiki@aardvark PageForms]$ git diff
diff --git a/includes/PF_Utils.php b/includes/PF_Utils.php
index 015d3b3c..517ea8a1 100644
--- a/includes/PF_Utils.php
+++ b/includes/PF_Utils.php
@@ -26,7 +26,7 @@ class PFUtils {
        }

        public static function getSMWContLang() {
-               if ( method_exists( 'smwfContLang' ) ) {
+               if ( function_exists( 'smwfContLang' ) ) {
                        // SMW 3.2+
                        return smwfContLang();
                } else {

Change 628837 had a related patch set uploaded (by Bluedreamer1; owner: Bluedreamer1):
[mediawiki/extensions/PageForms@master] Additional code for T249172

https://gerrit.wikimedia.org/r/628837

Change 628837 had a related patch set uploaded (by Nikerabbit; owner: Bluedreamer1):
[mediawiki/extensions/PageForms@master] Use correct function to check availability of smwfContLang

https://gerrit.wikimedia.org/r/628837

Change 628837 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Use correct function to check availability of smwfContLang

https://gerrit.wikimedia.org/r/628837

Sorry about that, and thanks for the fix! And welcome to the world of MediaWiki development!

Thanks for the welcome :-)

Just glad it was simple enough for me to fix and that I can contribute a tiny bit back to the community

Kghbln closed this task as Resolved.Sep 26 2020, 6:37 PM
Kghbln assigned this task to Bluedreamer1.

I guess this one was resolved. Thanks a bunch.