jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/355443 )
Change subject: Prevent saving of Properties with an empty datatype.
......................................................................
Prevent saving of Properties with an empty datatype.
This makes sure PropertiyContent objects with an empty datatype
are not conisdered "valid", and can thus not be saved.
Bug: T166227
Change-Id: Ie6b9b8756edd04225578336abf80f009e054ae4c
---
M repo/includes/Content/PropertyContent.php
M repo/tests/phpunit/includes/Api/SetAliasesTest.php
2 files changed, 19 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Thiemo Mättig (WMDE): Looks good to me, approved
diff --git a/repo/includes/Content/PropertyContent.php
b/repo/includes/Content/PropertyContent.php
index b9330d7..158d42b 100644
--- a/repo/includes/Content/PropertyContent.php
+++ b/repo/includes/Content/PropertyContent.php
@@ -112,7 +112,7 @@
*/
public function isValid() {
//TODO: provide a way to get the data type from the holder
directly!
- return parent::isValid() &&
$this->getProperty()->getDataTypeId() !== null;
+ return parent::isValid() &&
$this->getProperty()->getDataTypeId() !== '';
}
/**
diff --git a/repo/tests/phpunit/includes/Api/SetAliasesTest.php
b/repo/tests/phpunit/includes/Api/SetAliasesTest.php
index 7efae37..e439fe1 100644
--- a/repo/tests/phpunit/includes/Api/SetAliasesTest.php
+++ b/repo/tests/phpunit/includes/Api/SetAliasesTest.php
@@ -33,7 +33,7 @@
self::$hasSetup = true;
}
- public function testSetAliases_create() {
+ public function testSetAliases_cannotCreateProperty() {
$params = array(
'action' => self::$testAction,
'new' => 'property',
@@ -42,6 +42,23 @@
);
// -- do the request
--------------------------------------------------
+ try {
+ $this->doApiRequestWithToken( $params );
+ $this->fail( 'Implicit creation of Property should
fail.' );
+ } catch ( ApiUsageException $ex ) {
+ $this->assertEquals( 'failed-save',
$ex->getCodeString() );
+ }
+ }
+
+ public function testSetAliases_createItem() {
+ $params = array(
+ 'action' => self::$testAction,
+ 'new' => 'item',
+ 'language' => 'en',
+ 'set' => 'Foo',
+ );
+
+ // -- do the request
--------------------------------------------------
list( $result, , ) = $this->doApiRequestWithToken( $params );
// -- check the result
------------------------------------------------
--
To view, visit https://gerrit.wikimedia.org/r/355443
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6b9b8756edd04225578336abf80f009e054ae4c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits