Topic on Extension talk:PubmedParser

PHP notice: Constants already defined

11
Summary by Kghbln

v4.0.2 was release to mitigate the issue

Kghbln (talkcontribs)

Setup

  • MediaWiki 1.27.1 (36b636d) 20:26, 11. Jan. 2017
  • PHP 5.6.29-0+deb8u1 (apache2handler)
  • MariaDB 10.0.29-MariaDB-0+deb8u1
  • PubmedParser 4.0.1 (f63e6b3) 22:58, 9. Nov. 2016

Issue

When running maintenance script for other extensions such as e.g. Semantic MediaWiki or BlueSpice I get heaps of these warnings:

PHP Notice:  Constant PUBMEDPARSER_OK already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 41
PHP Notice:  Constant PUBMEDPARSER_INVALIDPMID already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 42
PHP Notice:  Constant PUBMEDPARSER_NODATA already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 43
PHP Notice:  Constant PUBMEDPARSER_CANNOTDOWNLOAD already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 44
PHP Notice:  Constant PUBMEDPARSER_DBERROR already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 45
PHP Notice:  Constant PUBMEDPARSER_INVALIDXML already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 46
PHP Notice:  Constant PUBMEDPARSER_TEMPLATECHAR already defined in /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php on line 47

Stack trace

This an exemplary stack trace:

2017-02-06 14:16:58 hoffmeyer 0222020151125-49275_: [c6a3062643734072ad7941d8] [no req]   ErrorException from line 47 of /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php: PHP Notice: Constant PUBMEDPARSER_TEMPLATECHAR already defined
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /.../w/extensions/PubmedParser/includes/PubmedParser_Extension.php(47): define(string, string)
#2 [internal function]: PubmedParser\Extension::setup(Parser)
#3 /.../w/includes/Hooks.php(195): call_user_func_array(string, array)
#4 /.../w/includes/parser/Parser.php(335): Hooks::run(string, array)
#5 /.../w/includes/parser/Parser.php(345): Parser->firstCallInit()
#6 /.../w/includes/parser/Parser.php(5075): Parser->clearState()
#7 /.../w/includes/parser/Parser.php(649): Parser->startParse(Title, ParserOptions, integer, boolean)
#8 /.../w/extensions/BlueSpiceFoundation/includes/utility/PageContentProvider.class.php(144): Parser->preprocess(string, Title, ParserOptions)
#9 /.../w/extensions/BlueSpiceFoundation/includes/utility/PageContentProvider.class.php(109): BsPageContentProvider->getContentFromRevision(Revision, integer, NULL, boolean)
#10 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/includes/BuildIndex/BuildIndexMainControl.class.php(718): BsPageContentProvider->getContentFromTitle(Title)
#11 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/includes/BuildIndex/BuildIndexMwArticles.class.php(127): BuildIndexMainControl->extractEditSections(Title)
#12 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/includes/BuildIndex/BuildIndexMainControl.class.php(263): BuildIndexMwArticles->indexCrawledDocuments()
#13 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/includes/BuildIndex/BuildIndexMainControl.class.php(398): BuildIndexMainControl->buildIndexWiki(string)
#14 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/maintenance/searchUpdate.php(27): BuildIndexMainControl->buildIndex()
#15 /.../w/maintenance/doMaintenance.php(103): SearchUpdate->execute()
#16 /.../w/extensions/BlueSpiceExtensions/ExtendedSearch/maintenance/searchUpdate.php(38): require_once(string)
#17 {main}
Bovender (talkcontribs)

It seems that files are being 'required' more than once?

Kghbln (talkcontribs)

No, I just have wfLoadExtension( 'PubmedParser' ); once in "LocalSettings.php". Probably I should try to use the classic "require_once ..." to rule out an issue with wfLoadExtension.

Kghbln (talkcontribs)

Nope, switching to require_once "$IP/extensions/PubmedParser/PubmedParser.php"; does not change a thing.

Since I get an error log of 100 MB each time I run some script it will be nice to have a fix for it.

Apart form that. People on the wiki are very happy with the extension. So thank you for creating it!

Kghbln (talkcontribs)

This happens only on pages which use the parser function. I cannot imagine that ExtendedSearch and Semantic MediaWiki are trying to invoke the namespaces a second time. Semantic MediaWiki is parsing the page again to update the data added to it. Perhaps this helps.

Bovender (talkcontribs)

I'll need to investigate, please bear with me!

Kghbln (talkcontribs)

I have an error log of about 10 to 20 MB due to this every day. So if there is a fix it will be cool to get it.

Bovender (talkcontribs)

Do you have the opportunity to test the `develop` branch? I just pushed a hack that prevents defining the constants twice.

I have two Wikis and neither produce these warnings, so I have a suspicion that it's not the PubmedParser extension that is the root of the problem. But maybe this fix solves it for you!

Kghbln (talkcontribs)

Many thanks for this. This indeed seems to have tackled the issue! Great!

Bovender (talkcontribs)

OK, 4.0.2 is out.

Kghbln (talkcontribs)

Thanks a lot!