Page MenuHomePhabricator

MediaWiki\Parser\Parsoid\Config\SiteConfig::namespaceId(): Argument #1 ($name) must be of type string
Open, Needs TriagePublicBUG 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;
	}