Topic on Project:Support desk

Semako96 (talkcontribs)

Sometimes when I try to upload multiple files with Extension:Multiupload, I get the following error:

[0d8ea9145562260a12e68c68] /wiki/Spezial:MultiUpload   Wikimedia\Assert\ParameterTypeException from line 89 of .../vendor/wikimedia/assert/src/Assert.php: Bad value for parameter $dbkey: must be a string

Backtrace:

 #0 .../includes/title/TitleValue.php(80): Wikimedia\Assert\Assert::parameterType(string, NULL, string)
 #1 .../includes/specialpage/SpecialPage.php(100): TitleValue->__construct(integer, NULL, string)
 #2 .../includes/specialpage/SpecialPage.php(84): SpecialPage::getTitleValueFor(NULL, boolean, string)
 #3 .../includes/specialpage/SpecialPage.php(630): SpecialPage::getTitleFor(NULL, boolean)
 #4 .../includes/specials/SpecialUpload.php(255): SpecialPage->getPageTitle()
 #5 .../extensions/MultiUpload/SpecialMultiUpload.php(476): SpecialUpload->getUploadForm(string, string, boolean)
 #6 .../includes/specials/SpecialUpload.php(524): UploadRow->showUploadWarning(array)
 #7 .../extensions/MultiUpload/SpecialMultiUpload.php(339): SpecialUpload->processUpload()
 #8 .../extensions/MultiUpload/SpecialMultiUpload.php(98): UploadRow->handleRequestData()
 #9 .../extensions/MultiUpload/SpecialMultiUpload.php(78): SpecialMultiUpload->handleRequestData()
 #10 .../includes/specialpage/SpecialPage.php(522): SpecialMultiUpload->execute(NULL)
 #11 .../includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
 #12 .../includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
 #13 .../includes/MediaWiki.php(861): MediaWiki->performRequest()
 #14 .../includes/MediaWiki.php(524): MediaWiki->main()
 #15 .../index.php(42): MediaWiki->run()
 #16 {main}

Wiki runs with MediaWiki 1.31 on php 7.2 with MySQL 5.5 InnoDB.

What's the problem there, how to fix it?

MarkAHershberger (talkcontribs)

The error (Bad value for parameter $dbkey: must be a string) and the backtrace (especially TitleValue->__construct(integer, NULL, string)), look clear enough.

The constructor for TitleValue expects string and NULL is passed.

Now, why is it passed null? Looking at the code for Special::getPageTitle, it looks like the mName property is never set. Which is odd.

It looks like the UploadRow constructor should be setting the mName property, but isn't.

Try adding $this-mName = $page; to the constructor and let us know if it helps.

Semako96 (talkcontribs)

For me, the titleValue.php script is a bit different, that is the constructor method:

/**
	 * Constructs a TitleValue.
	 *
	 * @note TitleValue expects a valid DB key; typically, a TitleValue is constructed either
	 * from a database entry, or by a TitleParser. We could apply "some" normalization here,
	 * such as substituting spaces by underscores, but that would encourage the use of
	 * un-normalized text when constructing TitleValues. For constructing a TitleValue from
	 * user input or external sources, use a TitleParser.
	 *
	 * @param int $namespace The namespace ID. This is not validated.
	 * @param string $dbkey The page title in valid DBkey form. No normalization is applied.
	 * @param string $fragment The fragment title. Use '' to represent the whole page.
	 *   No validation or normalization is applied.
	 * @param string $interwiki The interwiki component
	 *
	 * @throws InvalidArgumentException
	 */
	public function __construct( $namespace, $dbkey, $fragment = '', $interwiki = '' ) {
		Assert::parameterType( 'integer', $namespace, '$namespace' );
		Assert::parameterType( 'string', $dbkey, '$dbkey' );
		Assert::parameterType( 'string', $fragment, '$fragment' );
		Assert::parameterType( 'string', $interwiki, '$interwiki' );

		// Sanity check, no full validation or normalization applied here!
		Assert::parameter( !preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ), '$dbkey',
			"invalid DB key '$dbkey'" );
		Assert::parameter( $dbkey !== '', '$dbkey', 'should not be empty' );

		$this->namespace = $namespace;
		$this->dbkey = $dbkey;
		$this->fragment = $fragment;
		$this->interwiki = $interwiki;
        $this-mName = $page;
    
	}

In that code snipped I already added the &this-mName=$page; line, as you can see. And with that addition, it throws an error:

Fatal error: Exception thrown without a stack frame in Unknown on line 0

.

MarkAHershberger (talkcontribs)
Semako96 (talkcontribs)

After adding that line to the constructor method like this

/**
	 * Different constructor, let it know which row it is and
	 * the upload object it belongs to
	 */
	public function __construct( $page, $number ) {
		$this->mPage = $page;
		$this->setContext( $page->getContext() );
		$this->mRowNumber = $number;
		$this->mRequest = null;
		$this->mFormMessage = '';
		$this->mSessionKey = '';
		$this->mHideIgnoreWarning = '';
		$this->mExtraButtons = array();
        $this-mName = $page;
	}

	/**

I get the following error when trying to open Special:Multiupload:

[3cd5790bf61b9da1b34a015c] /wiki/Spezial:MultiUpload   ParseError from line 280 of /home/.sites/327/site4525714/web/wiki/w/extensions/MultiUpload/SpecialMultiUpload.php: syntax error, unexpected '='

Backtrace:

#0 [internal function]: AutoLoader::autoload(string)

 #1 /home/.sites/327/site4525714/web/wiki/w/includes/specialpage/SpecialPageFactory.php(382): spl_autoload_call(string)

 #2 /home/.sites/327/site4525714/web/wiki/w/includes/MediaWiki.php(255): SpecialPageFactory::getPage(string)

 #3 /home/.sites/327/site4525714/web/wiki/w/includes/MediaWiki.php(861): MediaWiki->performRequest()

 #4 /home/.sites/327/site4525714/web/wiki/w/includes/MediaWiki.php(524): MediaWiki->main()

 #5 /home/.sites/327/site4525714/web/wiki/w/index.php(42): MediaWiki->run()

 #6 {main}
Semako96 (talkcontribs)

Just noticed that in the line you gave me, there was a ">" missing. With

/**
	 * Different constructor, let it know which row it is and
	 * the upload object it belongs to
	 */
	public function __construct( $page, $number ) {
		$this->mPage = $page;
		$this->setContext( $page->getContext() );
		$this->mRowNumber = $number;
		$this->mRequest = null;
		$this->mFormMessage = '';
		$this->mSessionKey = '';
		$this->mHideIgnoreWarning = '';
		$this->mExtraButtons = array();
        $this->mName = $page;
	}

	/**

I can open Special:Multiupload now.

Semako96 (talkcontribs)

Just uploaded 11 files with Special:Multiupload successfully after implementing the fix. As the error didn't occur everytimes I multiuploaded before I can't be sure that the problem is fixed now, but it might be :-D If I get any new error message, I'll share it here of course.

Reply to "Multiupload error"