Page MenuHomePhabricator

"Prefix could not be added to the interwiki table" error with SQLite
Closed, ResolvedPublic

Description

Problem
Message "Prefix could not be added to the interwiki table. Possibly it already exists in the interwiki table." is dispayed when adding or changing interwiki link via Special:Interwiki and the wiki is running on SQLite.

Cause
Interwiki update statement in Interwiki_body.php is missing columns.

Fix
Changes required to file Interwiki_body.php in the function doSubmit():

		case 'edit':
			$theurl = $request->getVal( 'wpInterwikiURL' );
			$local = $request->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
			$trans = $request->getCheck( 'wpInterwikiTrans' ) ? 1 : 0;
			$data = array(
				'iw_prefix' => $prefix,
				'iw_url' => $theurl,
				'iw_local' => $local,
				'iw_trans' => $trans
			);
...to...
		case 'edit':
			$theurl = $request->getVal( 'wpInterwikiURL' );
			$local = $request->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
			$trans = $request->getCheck( 'wpInterwikiTrans' ) ? 1 : 0;
			$data = array(
				'iw_prefix' => $prefix,
				'iw_url' => $theurl,
				'iw_local' => $local,
				'iw_trans' => $trans,
				'iw_api' => '',
				'iw_wikiid' => ''
			);

Event Timeline

I can reproduce the same issue on the current master branch (1.39) with the local docker setup documented in DEVELOPER.md, which is also using SQLite as database.

Changing the following lines in SpecialInterwiki.php as OP suggested did resolve the issue.

Since the task had been opened a while, I modified the solution below to match the latest version:

case 'edit':
	$theurl = $data['url'];
	$api = $data['api'] ?? '';
	$local = $data['local'] ? 1 : 0;
	$trans = $data['trans'] ? 1 : 0;
	$wikiid = WikiMap::getCurrentWikiId() ?? '';
	$rows = [
		'iw_prefix' => $prefix,
		'iw_url' => $theurl,
		'iw_api' => $api,
		'iw_local' => $local,
		'iw_trans' => $trans,
		'iw_wikiid' => $wikiid
	];

Change 791818 had a related patch set uploaded (by Alistair3149; author: Alistair3149):

[mediawiki/extensions/Interwiki@master] Edit iw_wikiid entry when adding or editing interwiki link via Special:Interwiki

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

Change 791818 abandoned by Alistair3149:

[mediawiki/extensions/Interwiki@master] Edit iw_wikiid entry when adding or editing interwiki link via Special:Interwiki

Reason:

Fixed by https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Interwiki/+/830695/

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

@alistair3149 thx for the work. If you can confirm this is fixed, you may close the ticket, or I'll close it later on.