Page MenuHomePhabricator

MediaWiki\Parser\Parsoid\Config\SiteConfig::namespaceId(): Argument #1 ($name) must be of type string
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Presently running MW 1.41.1

What happens?:

Unable to use VisualEditor as I keep on getting this error:

MediaWiki\Parser\Parsoid\Config\SiteConfig::namespaceId(): Argument #1 ($name) must be of type string, int given, called in /w/vendor/wikimedia/parsoid/src/Config/SiteConfig.php on line 505

This relates to this bit of code:

	/**
	 * Interwiki link data, after removing items that conflict with namespace names.
	 * (In case of such conflict, namespace wins, interwiki is ignored.)
	 * @return array[] See interwikiMap()
	 */
	public function interwikiMapNoNamespaces(): array {
		if ( $this->interwikiMapNoNamespaces === null ) {
			$map = $this->interwikiMap();
			foreach ( array_keys( $map ) as $key ) {
				if ( $this->namespaceId( $key ) !== null ) {
					unset( $map[$key] );
			}
			}
			$this->interwikiMapNoNamespaces = $map;
		}
		return $this->interwikiMapNoNamespaces;
	}

What should have happened instead?:

Should be allowed to edit.

I could edit on some pages if I comment out this bit of code:

/*			foreach ( array_keys( $map ) as $key ) {
				if ( $this->namespaceId( $key ) !== null ) {
					unset( $map[$key] );
			}
			}*/

I did this before upgrading from 1.40.1 as well, and that worked fine. But I figure there have been code changes since then.

Event Timeline

So, I discovered that this works again, but I had to disable Lingo extension in order to do so per this:

https://phabricator.wikimedia.org/T357686

With that handled, I was able to force the whole Argument no.1 issue to resolve itself by declaring that $key is a string, thus:

if ( $this->namespaceId( (string)$key ) !== null ) {

In this public function segment:

	public function interwikiMapNoNamespaces(): array { 
		if ( $this->interwikiMapNoNamespaces === null ) {
			$map = $this->interwikiMap();
			foreach ( array_keys( $map ) as $key ) {
				if ( $this->namespaceId( (string)$key ) !== null ) {
					unset( $map[$key] );
			}
			}
			$this->interwikiMapNoNamespaces = $map;
		}
		return $this->interwikiMapNoNamespaces;
	}

Change #1052809 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Handle numerical interwiki prefix key cast

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

Arlolra triaged this task as Medium priority.Jul 8 2024, 8:18 PM
Arlolra moved this task from Backlog to Code Review on the Content-Transform-Team-WIP board.

Change #1052809 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Handle numerical interwiki prefix key cast

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

Change #1055878 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.20.0-a14

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

Change #1055878 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.20.0-a14

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