Page MenuHomePhabricator

Error: Class 'MWNamespace' not found
Closed, InvalidPublic

Description

MediaWiki 1.39.1

PHP 7.4.3-4ubuntu2.19 (apache2handler)

MySQL 8.0.34-0ubuntu0.20.04.1

ICU 66.1

HitCounters-REL1_39-e759c39.tar.gz

I did the composer install and ran the update script. I get

[35f31966c348bbdee9c42ea7] /Special:PopularPages Error: Class 'MWNamespace' not found

Backtrace:

from /var/www/html/wiki/underfoot/extensions/HitCounters/includes/HitCounters.body.php(134)
#0 /var/www/html/wiki/underfoot/extensions/HitCounters/includes/SpecialPopularPages.php(52): HitCounters\HitCounters::getQueryInfo()

and

Fatal error: Declaration of MWCallbackStream::write($string) must be compatible with Psr\Http\Message\StreamInterface::write(string $string): int in /var/www/html/wiki/underfoot/includes/http/MWCallbackStream.php on line 46

I see https://www.mediawiki.org/wiki/Manual:MWNamespace.php/en says

This feature was removed from MediaWiki core in version 1.39 (phab:rMWea1c106ea9a3) (after being deprecated in 1.34). Please see NamespaceInfo.php for an alternative way to use this feature.

Event Timeline

rEHTCd0f37b82b533: Avoid using MWNamespace fixed this, which should be in REL1_38+.

You suggest you're using e759c39, if we look at that file, at that commit...

https://github.com/wikimedia/mediawiki-extensions-HitCounters/blob/e759c390d38d83bd0923b36ba33b4972717ad327/includes/HitCounters.body.php#L126-L131

The code you are running doesn't seem to match what is in the repo.

Regarding the second issue, that's unrelated, and would look like you've got an incorrect version of psr/message installed somewhere (in an extension).

The version in the MW vendor repo is correct; psr/http-message pinned at 1.0.1 - https://github.com/wikimedia/mediawiki-vendor/blob/REL1_39/psr/http-message/src/StreamInterface.php#L108-L115

https://github.com/php-fig/http-message/blob/1.0.1/src/StreamInterface.php#L108-L115

It would seem you have 2.0 - https://github.com/php-fig/http-message/blob/1.0.1/src/StreamInterface.php#L108-L115

Possibly incorrectly included by a loose dependancy in an extension or similar where you have run composer update?

Thanks for helping out. I can confirm it was e759c39, I chose the autodownload option from wikimedia, and chose 1.39, and got HitCounters-REL1_39-e759c39.tar.gz with a filesize of 96858 and md5sum of fd407935fa0aa25401b831faa3060314

vi HitCounters/includes/HitCounters.body.php and that patch is not present, it has

'conds' => [
        'page_is_redirect' => 0,
        'page_namespace' => MWNamespace::getContentNamespaces(),
],

. I think its the composer lines are making it unstable, afterwards enabling/disabling extensions like ExternalData or PageForms means the second error comes and goes rather randomly. Unfortunately they are key to my application. Its a complicated wiki, perhaps this extension is the last straw.

Thanks for helping out. I can confirm it was e759c39, I chose the autodownload option from wikimedia, and chose 1.39, and got HitCounters-REL1_39-e759c39.tar.gz with a filesize of 96858 and md5sum of fd407935fa0aa25401b831faa3060314

vi HitCounters/includes/HitCounters.body.php and that patch is not present, it has

'conds' => [
        'page_is_redirect' => 0,
        'page_namespace' => MWNamespace::getContentNamespaces(),
],

https://extdist.wmflabs.org/dist/extensions/HitCounters-REL1_39-e759c39.tar.gz also with the hash fd407935fa0aa25401b831faa3060314

			'conds' => [
				'p.page_is_redirect' => 0,
				'p.page_namespace' => MediaWikiServices::getInstance()
					-> ()
					->getContentNamespaces(),
			],

Which matches the git repo.

Have you extracted/updated it properly?

. I think its the composer lines are making it unstable, afterwards enabling/disabling extensions like ExternalData or PageForms means the second error comes and goes rather randomly. Unfortunately they are key to my application. Its a complicated wiki, perhaps this extension is the last straw.

https://www.mediawiki.org/wiki/Composer#Using_composer-merge-plugin is another option.

But the problem is rooted in these extensions having their own (complex) dependancy trees, and also including version of libraries that MW core includes, specifically at different versions...

https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=HitCounters&extdistversion=REL1_39 and this time the patch is applied. No idea why it didn't 20 minutes ago when I did the same thing. And the Popular page now works, its just that running the composer lines must have triggered a problem elsewhere. I don't understand or like composer, perhaps I'll try installing this extension first and layer the other stuff using composer on to it.

Anyway, the problem with this package seems to be resolved. Thanks for your help.