jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/391195 )
Change subject: Updating wikibase/data-model (7.2.0 => 7.3.0) ...................................................................... Updating wikibase/data-model (7.2.0 => 7.3.0) Version was bumped in the Wikidata build @ https://gerrit.wikimedia.org/r/#/c/391172 Change-Id: I9c29f6259fa25526e8a659776f77ac18a75b0cea --- M composer.json M composer.lock M composer/autoload_psr4.php M composer/autoload_static.php M composer/installed.json M wikibase/data-model/RELEASE-NOTES.md M wikibase/data-model/WikibaseDataModel.php M wikibase/data-model/src/Entity/EntityId.php M wikibase/data-model/src/Entity/ItemId.php M wikibase/data-model/src/Entity/PropertyId.php 10 files changed, 142 insertions(+), 84 deletions(-) Approvals: WMDE-leszek: Looks good to me, but someone else must approve Ladsgroup: Looks good to me, approved jenkins-bot: Verified diff --git a/composer.json b/composer.json index 1a0aaf4..73eb7de 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,7 @@ "symfony/polyfill-mbstring": "1.4", "symfony/process": "3.2.6", "symfony/var-dumper": "3.3.4", - "wikibase/data-model": "7.2.0", + "wikibase/data-model": "7.3.0", "wikibase/data-model-serialization": "2.6.0", "wikibase/data-model-services": "3.8.0", "wikibase/internal-serialization": "2.7.0", diff --git a/composer.lock b/composer.lock index 87637a3..792ad76 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "47546374fd63a4783d14b8430f4a56ef", + "content-hash": "4eb14a435989049127b8e9597dfdf335", "packages": [ { "name": "composer/semver", @@ -2325,16 +2325,16 @@ }, { "name": "wikibase/data-model", - "version": "7.2.0", + "version": "7.3.0", "source": { "type": "git", "url": "https://github.com/wmde/WikibaseDataModel.git", - "reference": "b54117c9428a034bef9c28d8f1897a4e9781ff02" + "reference": "738cc82eb7c8a994ed06392ccb456abf00eb702d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wmde/WikibaseDataModel/zipball/b54117c9428a034bef9c28d8f1897a4e9781ff02", - "reference": "b54117c9428a034bef9c28d8f1897a4e9781ff02", + "url": "https://api.github.com/repos/wmde/WikibaseDataModel/zipball/738cc82eb7c8a994ed06392ccb456abf00eb702d", + "reference": "738cc82eb7c8a994ed06392ccb456abf00eb702d", "shasum": "" }, "require": { @@ -2351,7 +2351,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.2.x-dev" + "dev-master": "7.3.x-dev" } }, "autoload": { @@ -2383,7 +2383,7 @@ "wikibase", "wikidata" ], - "time": "2017-10-23T11:52:21+00:00" + "time": "2017-11-13T13:21:52+00:00" }, { "name": "wikibase/data-model-serialization", diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php index 91f8b9d..388308a 100644 --- a/composer/autoload_psr4.php +++ b/composer/autoload_psr4.php @@ -16,7 +16,7 @@ 'Wikimedia\\Assert\\' => array($vendorDir . '/wikimedia/assert/src'), 'Wikibase\\InternalSerialization\\' => array($vendorDir . '/wikibase/internal-serialization/src'), 'Wikibase\\DataModel\\Services\\' => array($vendorDir . '/wikibase/data-model-services/src'), - 'Wikibase\\DataModel\\' => array($vendorDir . '/wikibase/data-model/src', $vendorDir . '/wikibase/data-model-serialization/src'), + 'Wikibase\\DataModel\\' => array($vendorDir . '/wikibase/data-model-serialization/src', $vendorDir . '/wikibase/data-model/src'), 'ValueValidators\\' => array($vendorDir . '/data-values/interfaces/src/ValueValidators'), 'ValueParsers\\' => array($vendorDir . '/data-values/interfaces/src/ValueParsers', $vendorDir . '/data-values/common/src/ValueParsers'), 'ValueFormatters\\' => array($vendorDir . '/data-values/interfaces/src/ValueFormatters', $vendorDir . '/data-values/common/src/ValueFormatters'), diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 6a81bff..26a19a7 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -149,8 +149,8 @@ ), 'Wikibase\\DataModel\\' => array ( - 0 => __DIR__ . '/..' . '/wikibase/data-model/src', - 1 => __DIR__ . '/..' . '/wikibase/data-model-serialization/src', + 0 => __DIR__ . '/..' . '/wikibase/data-model-serialization/src', + 1 => __DIR__ . '/..' . '/wikibase/data-model/src', ), 'ValueValidators\\' => array ( diff --git a/composer/installed.json b/composer/installed.json index 838bea6..941d707 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -3441,70 +3441,6 @@ ] }, { - "name": "wikibase/data-model", - "version": "7.2.0", - "version_normalized": "7.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/wmde/WikibaseDataModel.git", - "reference": "b54117c9428a034bef9c28d8f1897a4e9781ff02" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wmde/WikibaseDataModel/zipball/b54117c9428a034bef9c28d8f1897a4e9781ff02", - "reference": "b54117c9428a034bef9c28d8f1897a4e9781ff02", - "shasum": "" - }, - "require": { - "data-values/data-values": "~0.1|~1.0", - "php": ">=5.5.9", - "wikimedia/assert": "~0.2.2" - }, - "require-dev": { - "ockcyp/covers-validator": "~0.4.0", - "phpmd/phpmd": "~2.3", - "phpunit/phpunit": "~4.8", - "wikibase/wikibase-codesniffer": "^0.1.0" - }, - "time": "2017-10-23T11:52:21+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "WikibaseDataModel.php" - ], - "psr-4": { - "Wikibase\\DataModel\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Thiemo Mättig" - }, - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com" - } - ], - "description": "PHP implementation of the Wikibase DataModel", - "homepage": "https://github.com/wmde/WikibaseDataModel", - "keywords": [ - "DataModel", - "wikibase", - "wikidata" - ] - }, - { "name": "wikibase/data-model-serialization", "version": "2.6.0", "version_normalized": "2.6.0.0", @@ -3780,5 +3716,69 @@ ], "description": "Provides library of common widgets, layouts, and windows.", "homepage": "https://www.mediawiki.org/wiki/OOjs_UI" + }, + { + "name": "wikibase/data-model", + "version": "7.3.0", + "version_normalized": "7.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/wmde/WikibaseDataModel.git", + "reference": "738cc82eb7c8a994ed06392ccb456abf00eb702d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wmde/WikibaseDataModel/zipball/738cc82eb7c8a994ed06392ccb456abf00eb702d", + "reference": "738cc82eb7c8a994ed06392ccb456abf00eb702d", + "shasum": "" + }, + "require": { + "data-values/data-values": "~0.1|~1.0", + "php": ">=5.5.9", + "wikimedia/assert": "~0.2.2" + }, + "require-dev": { + "ockcyp/covers-validator": "~0.4.0", + "phpmd/phpmd": "~2.3", + "phpunit/phpunit": "~4.8", + "wikibase/wikibase-codesniffer": "^0.1.0" + }, + "time": "2017-11-13T13:21:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "WikibaseDataModel.php" + ], + "psr-4": { + "Wikibase\\DataModel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Thiemo Mättig" + }, + { + "name": "Jeroen De Dauw", + "email": "jeroended...@gmail.com", + "homepage": "http://jeroendedauw.com" + } + ], + "description": "PHP implementation of the Wikibase DataModel", + "homepage": "https://github.com/wmde/WikibaseDataModel", + "keywords": [ + "DataModel", + "wikibase", + "wikidata" + ] } ] diff --git a/wikibase/data-model/RELEASE-NOTES.md b/wikibase/data-model/RELEASE-NOTES.md index f7d4412..3e9dbbb 100644 --- a/wikibase/data-model/RELEASE-NOTES.md +++ b/wikibase/data-model/RELEASE-NOTES.md @@ -1,5 +1,11 @@ # Wikibase DataModel release notes +## Version 7.3.0 (2017-11-13) + +* Performance optimizations on `EntityId`: + * Added protected `$repositoryName` and `$localPart` properties + * Added protected `extractRepositoryNameAndLocalPart` + ## Version 7.2.0 (2017-10-23) * Performance optimizations on methods critical for dump generation: diff --git a/wikibase/data-model/WikibaseDataModel.php b/wikibase/data-model/WikibaseDataModel.php index 3f25b06..8919128 100644 --- a/wikibase/data-model/WikibaseDataModel.php +++ b/wikibase/data-model/WikibaseDataModel.php @@ -11,4 +11,4 @@ return; } -define( 'WIKIBASE_DATAMODEL_VERSION', '7.2.0' ); +define( 'WIKIBASE_DATAMODEL_VERSION', '7.3.0' ); diff --git a/wikibase/data-model/src/Entity/EntityId.php b/wikibase/data-model/src/Entity/EntityId.php index 130df85..72bf81f 100644 --- a/wikibase/data-model/src/Entity/EntityId.php +++ b/wikibase/data-model/src/Entity/EntityId.php @@ -16,16 +16,34 @@ protected $serialization; + /** + * @since 7.3 + * + * @var string + */ + protected $repositoryName; + + /** + * @since 7.3 + * + * @var string + */ + protected $localPart; + const PATTERN = '/^:?(\w+:)*[^:]+\z/'; /** * @since 6.2 * * @param string $serialization + * + * @throws InvalidArgumentException */ public function __construct( $serialization ) { self::assertValidSerialization( $serialization ); $this->serialization = self::normalizeIdSerialization( $serialization ); + + list ( $this->repositoryName, $this->localPart ) = self::extractRepositoryNameAndLocalPart( $serialization ); } private static function assertValidSerialization( $serialization ) { @@ -63,12 +81,31 @@ * @since 6.2 * * @param string $serialization + * + * @throws InvalidArgumentException * @return string[] Array containing the serialization split into 3 parts. */ public static function splitSerialization( $serialization ) { self::assertValidSerialization( $serialization ); - $parts = explode( ':', self::normalizeIdSerialization( $serialization ) ); + return self::extractSerializationParts( self::normalizeIdSerialization( $serialization ) ); + } + + /** + * Splits the given ID serialization into an array with the following three elements: + * - the repository name as the first element (empty string for local repository) + * - any parts of the ID serialization but the repository name and the local ID (if any, empty string + * if nothing else present) + * - the local ID + * Note: this method does not perform any validation of the given input. Calling code should take + * care of this! + * + * @param string $serialization + * + * @return string[] + */ + private static function extractSerializationParts( $serialization ) { + $parts = explode( ':', $serialization ); $localPart = array_pop( $parts ); $repoName = array_shift( $parts ); $prefixRemainder = implode( ':', $parts ); @@ -86,9 +123,9 @@ * @since 6.2 * * @param string[] $parts - * @return string * * @throws InvalidArgumentException + * @return string */ public static function joinSerialization( array $parts ) { if ( end( $parts ) === '' ) { @@ -112,9 +149,7 @@ * @return string */ public function getRepositoryName() { - $parts = self::splitSerialization( $this->serialization ); - - return $parts[0]; + return $this->repositoryName; } /** @@ -125,9 +160,7 @@ * @return string */ public function getLocalPart() { - $parts = self::splitSerialization( $this->serialization ); - - return self::joinSerialization( [ '', $parts[1], $parts[2] ] ); + return $this->localPart; } /** @@ -144,6 +177,7 @@ /** * @param string $id + * * @return string */ private static function normalizeIdSerialization( $id ) { @@ -179,4 +213,20 @@ && $target->serialization === $this->serialization; } + /** + * Returns a pair (repository name, local part of ID) from the given ID serialization. + * Note: this does not perform any validation of the given input. Calling code should take + * care of this! + * + * @since 7.3 + * + * @param string $serialization + * + * @return string[] Array of form [ string $repositoryName, string $localPart ] + */ + protected static function extractRepositoryNameAndLocalPart( $serialization ) { + $parts = explode( ':', $serialization, 2 ); + return isset( $parts[1] ) ? $parts : [ '', $parts[0] ]; + } + } diff --git a/wikibase/data-model/src/Entity/ItemId.php b/wikibase/data-model/src/Entity/ItemId.php index 01a2200..53a6021 100644 --- a/wikibase/data-model/src/Entity/ItemId.php +++ b/wikibase/data-model/src/Entity/ItemId.php @@ -83,6 +83,7 @@ public function unserialize( $serialized ) { $array = json_decode( $serialized ); $this->serialization = is_array( $array ) ? $array[1] : $serialized; + list ( $this->repositoryName, $this->localPart ) = self::extractRepositoryNameAndLocalPart( $this->serialization ); } /** diff --git a/wikibase/data-model/src/Entity/PropertyId.php b/wikibase/data-model/src/Entity/PropertyId.php index bd7e3d5..4221cd4 100644 --- a/wikibase/data-model/src/Entity/PropertyId.php +++ b/wikibase/data-model/src/Entity/PropertyId.php @@ -83,6 +83,7 @@ public function unserialize( $serialized ) { $array = json_decode( $serialized ); $this->serialization = is_array( $array ) ? $array[1] : $serialized; + list ( $this->repositoryName, $this->localPart ) = self::extractRepositoryNameAndLocalPart( $this->serialization ); } /** -- To view, visit https://gerrit.wikimedia.org/r/391195 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9c29f6259fa25526e8a659776f77ac18a75b0cea Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/vendor Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.kr...@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