Aude has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/345186 )
Change subject: Require an entity type to be specified when searching for entitites without label or description. ...................................................................... Require an entity type to be specified when searching for entitites without label or description. Bug: T161631 Change-Id: I9949cc3fa511886c38059f8f8c5959538ac7d487 --- M repo/i18n/en.json M repo/i18n/qqq.json M repo/includes/Specials/SpecialEntitiesWithoutPage.php M repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php 4 files changed, 33 insertions(+), 17 deletions(-) Approvals: Aude: Verified; Looks good to me, approved Thiemo Mättig (WMDE): Looks good to me, approved diff --git a/repo/i18n/en.json b/repo/i18n/en.json index 4cb4e3a..eb628bc 100644 --- a/repo/i18n/en.json +++ b/repo/i18n/en.json @@ -288,7 +288,6 @@ "wikibase-entitieswithoutlabel-legend": "Get list of entities without label", "wikibase-entitieswithoutlabel-label-language": "Language code:", "wikibase-entitieswithoutlabel-label-type": "Type:", - "wikibase-entitieswithoutlabel-label-alltypes": "all", "wikibase-entitieswithoutlabel-submit": "Find", "wikibase-entitieswithoutlabel-invalid-language": "\"$1\" is not a valid language code.", "wikibase-entitieswithoutlabel-invalid-type": "\"$1\" is not a valid entity type.", diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json index 1e4d5f2..6605b39 100644 --- a/repo/i18n/qqq.json +++ b/repo/i18n/qqq.json @@ -320,7 +320,6 @@ "wikibase-entitieswithoutlabel-legend": "Legend of the form that allow to change the language.", "wikibase-entitieswithoutlabel-label-language": "Label for the input field to change the language code.\n{{Identical|Language code}}", "wikibase-entitieswithoutlabel-label-type": "Label of the entity type selector that allows to restrict the request to one type.\n{{Identical|Type}}", - "wikibase-entitieswithoutlabel-label-alltypes": "Label of the entity type selector entry that allows to output missing labels for all entity types.\n{{Identical|All}}", "wikibase-entitieswithoutlabel-submit": "Label for the button that activate the action.\n{{Identical|Find}}", "wikibase-entitieswithoutlabel-invalid-language": "Error message shown when the language code passed in parameter is invalid.\n\nParameters:\n* $1 - language code\nSee also:\n* {{msg-mw|Wikibase-unconnectedpages-invalid-language}}", "wikibase-entitieswithoutlabel-invalid-type": "Parameters:\n* $1 - an invalid entity type. Valid entity types are: item, property and query.", diff --git a/repo/includes/Specials/SpecialEntitiesWithoutPage.php b/repo/includes/Specials/SpecialEntitiesWithoutPage.php index 472fdfc..b261005 100644 --- a/repo/includes/Specials/SpecialEntitiesWithoutPage.php +++ b/repo/includes/Specials/SpecialEntitiesWithoutPage.php @@ -100,7 +100,7 @@ $this->prepareArguments( $subPage ); $this->setForm(); - if ( $this->language !== '' ) { + if ( $this->language !== '' && $this->type !== '' ) { $this->showQuery(); } } @@ -133,15 +133,12 @@ } $this->type = $request->getText( 'type', $this->type ); - if ( $this->type === '' ) { - $this->type = null; - } - if ( $this->type !== null && !in_array( $this->type, $this->entityTypes ) ) { + if ( $this->type !== '' && !in_array( $this->type, $this->entityTypes ) ) { $this->showErrorHTML( $this->msg( 'wikibase-entitieswithoutlabel-invalid-type', wfEscapeWikiText( $this->type ) )->parse() ); - $this->type = null; + $this->type = ''; } } @@ -163,13 +160,17 @@ * Build the HTML form */ private function setForm() { - $options = array( - $this->msg( 'wikibase-entitieswithoutlabel-label-alltypes' )->text() => '' - ); + $options = array(); foreach ( $this->entityTypes as $type ) { - // Messages: wikibase-entity-item, wikibase-entity-property, wikibase-entity-query + // Messages: wikibase-entity-item, wikibase-entity-property $options[$this->msg( 'wikibase-entity-' . $type )->text()] = $type; + } + + if ( $this->type !== null && $this->type !== '' ) { + $defaultType = $this->type; + } else { + $defaultType = reset( $this->entityTypes ); } $formDescriptor = array( @@ -185,7 +186,7 @@ 'type' => array( 'name' => 'type', 'options' => $options, - 'default' => $this->type, + 'default' => $defaultType, 'type' => 'select', 'id' => 'wb-entitieswithoutpage-type', 'label-message' => 'wikibase-entitieswithoutlabel-label-type' @@ -219,7 +220,7 @@ return $this->entitiesWithoutTerm->getEntitiesWithoutTerm( $this->termType, $this->language, - $this->type === null ? null : [ $this->type ], + [ $this->type ], $limit, $offset ); diff --git a/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php b/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php index bb08dee..1de337a 100644 --- a/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php +++ b/repo/tests/phpunit/includes/Specials/SpecialEntitiesWithoutPageTest.php @@ -54,7 +54,7 @@ $this->assertContains( '(wikibase-entitieswithoutlabel-label-type)', $html ); $this->assertContains( 'name=\'type\'', $html ); $this->assertContains( 'id=\'wb-entitieswithoutpage-type\'', $html ); - $this->assertContains( '(wikibase-entitieswithoutlabel-label-alltypes)', $html ); + $this->assertContains( '(wikibase-entity-item)', $html ); $this->assertContains( '(wikibase-entitieswithoutlabel-submit)', $html ); $this->assertContains( 'id=\'wikibase-entitieswithoutpage-submit\'', $html ); @@ -81,10 +81,26 @@ $this->assertContains( '''TYPE''', $html ); } - public function testNoLanguage() { + public function testNoParams() { list( $html, ) = $this->executeSpecialPage( '', null, 'qqx' ); $this->assertNotContains( 'class="mw-spcontent"', $html ); + $this->assertNotContains( '(htmlform-invalid-input)', $html ); + } + + public function testNoLanguage() { + $request = new FauxRequest( [ 'type' => 'item' ] ); + list( $html, ) = $this->executeSpecialPage( '', $request, 'qqx' ); + + $this->assertNotContains( 'class="mw-spcontent"', $html ); + $this->assertNotContains( '(htmlform-invalid-input)', $html ); + } + + public function testNoType() { + list( $html, ) = $this->executeSpecialPage( 'acceptedlanguage', null, 'qqx' ); + + $this->assertNotContains( 'class="mw-spcontent"', $html ); + $this->assertNotContains( '(htmlform-invalid-input)', $html ); } public function testInvalidLanguage() { @@ -97,7 +113,8 @@ } public function testValidLanguage() { - list( $html, ) = $this->executeSpecialPage( 'acceptedlanguage', null, 'qqx' ); + $request = new FauxRequest( [ 'type' => 'item' ] ); + list( $html, ) = $this->executeSpecialPage( 'acceptedlanguage', $request, 'qqx' ); $this->assertContains( 'value=\'acceptedlanguage\'', $html ); $this->assertContains( 'class="mw-spcontent"', $html ); -- To view, visit https://gerrit.wikimedia.org/r/345186 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9949cc3fa511886c38059f8f8c5959538ac7d487 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits