Page MenuHomePhabricator

url parameters id and fields[] seem to conflict
Closed, ResolvedPublic

Description

Tried to pass 3 different user parameter to the UW via url parameters. Several combinations of url parameters fail to work

  • id=…&id2=…&fields[]=… (escaped as id=…&id2=…&fields%5B%5D=…)
  • id=…&fields[]=…&fields[]=…
  • id=…&id2=…&id3=…

what finally worked was

  • &fields[]=…&fields[]=…&fields[]=…

so you cannot use both id and fields[].
id2 is not documented at all

see https://www.mediawiki.org/wiki/Extension:UploadWizard#URL_arguments for the description which does not work as expected. Please check the implementation and correct the documentation.

Event Timeline

Restricted Application added a project: Multimedia. · View Herald TranscriptFeb 14 2017, 11:31 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The implementation (SpecialUploadWizard::execute) is as follows:

		$fields = $req->getArray( 'fields' );
		$fieldDefaults = [];

		# Support id and id2 for field0 and field1
		# Legacy support for old URL structure. They override fields[]
		if ( $req->getText( 'id' ) ) {
			$fields[0] = $req->getText( 'id' );
		}

		if ( $req->getText( 'id2' ) ) {
			$fields[1] = $req->getText( 'id2' );
		}

		if ( $fields ) {
			foreach ( $fields as $index => $value ) {
				$fieldDefaults[$index]['initialValue'] = $value;
			}
		}

		UploadWizardConfig::setUrlSetting( 'fields', $fieldDefaults );

So:

  • Using fields[] is preferred to using id and id2, which are said to be "legacy"
  • fields[] is checked first
  • If id is given, it is used instead of the first fields[] value
  • If id2 is given, it is used instead of the second fields[] value
  • There is no id3 and so on; there is no field[] (you used that in your second example)
Herzi.Pinki updated the task description. (Show Details)Feb 15 2017, 10:09 AM