Skip to content

Commit e5140f3

Browse files
manickiWMDE bot
authored andcommitted
Formally disallowed using colons/prefixes in the Item/Property ID
While no longer allowed/recognized, colon-separated repository prefixes have still been formally allowed in the Item or Property ID. Also, if the ID was including a single leading colon, it was quietly removed from the ID, and accepted. Those are no longer allowed, and no "normalization" happens anymore. Bug: T291823 Depends-On: I9839880d965051fa4b70986e744fe60d38f69a8a Change-Id: I226cf78a82a26078519a2f89e72f845f04f650fe
1 parent d6d0769 commit e5140f3

5 files changed

Lines changed: 9 additions & 20 deletions

File tree

src/Entity/SerializableEntityId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class SerializableEntityId implements EntityId {
2222
*/
2323
protected $localPart;
2424

25-
public const PATTERN = '/^:?(\w+:)*[^:]+\z/';
25+
public const PATTERN = '/^[^:]+\z/';
2626

2727
/**
2828
* @param string $serialization

tests/unit/Entity/DispatchingEntityIdParserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static function invalidIdSerializationProvider() {
6363
[ ':Q1337' ],
6464
[ 'foo:' ],
6565
[ 'foo:bar:' ],
66+
[ ':Q1337' ],
6667
[ '::Q1337' ],
6768
[ ':' ],
6869
[ 'q:0' ],

tests/unit/Entity/EntityIdTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,16 @@ public static function invalidJoinSerializationDataProvider() {
152152
];
153153
}
154154

155-
public function testGivenNotNormalizedSerialization_splitSerializationReturnsNormalizedParts() {
156-
$this->assertSame( [ '', '', 'Q42' ], SerializableEntityId::splitSerialization( ':Q42' ) );
157-
}
158-
159-
public static function localPartDataProvider() {
160-
return [
161-
[ 'Q42', 'Q42' ],
162-
[ ':Q42', 'Q42' ],
163-
];
164-
}
165-
166-
/**
167-
* @dataProvider localPartDataProvider
168-
*/
169-
public function testGetLocalPart( $serialization, $localPart ) {
170-
$id = new ItemId( $serialization );
171-
$this->assertSame( $localPart, $id->getLocalPart() );
155+
public function testGetLocalPart() {
156+
$id = new ItemId( 'Q42' );
157+
$this->assertSame( 'Q42', $id->getLocalPart() );
172158
}
173159

174160
public static function invalidSerializationProvider() {
175161
return [
162+
[ 'foo:Q42' ],
176163
[ 's p a c e s:Q42' ],
164+
[ ':Q42' ],
177165
[ '::Q42' ],
178166
[ '' ],
179167
[ ':' ],

tests/unit/Entity/ItemIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public static function idSerializationProvider() {
3636
[ 'q31337', 'Q31337' ],
3737
[ 'Q31337', 'Q31337' ],
3838
[ 'Q42', 'Q42' ],
39-
[ ':Q42', 'Q42' ],
4039
[ 'Q2147483647', 'Q2147483647' ],
4140
];
4241
}
@@ -71,6 +70,7 @@ public static function invalidIdSerializationProvider() {
7170
// no longer supported (T291823, T338223)
7271
[ 'foo:Q42', 'foo:Q42' ],
7372
[ 'foo:bar:q42', 'foo:bar:Q42' ],
73+
[ ':Q42', 'Q42' ],
7474
];
7575
}
7676

tests/unit/Entity/NumericPropertyIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public static function idSerializationProvider() {
3535
[ 'p31337', 'P31337' ],
3636
[ 'P31337', 'P31337' ],
3737
[ 'P42', 'P42' ],
38-
[ ':P42', 'P42' ],
3938
[ 'P2147483647', 'P2147483647' ],
4039
];
4140
}
@@ -70,6 +69,7 @@ public static function invalidIdSerializationProvider() {
7069
// no longer supported (T291823, T338223)
7170
[ 'foo:P42', 'foo:P42' ],
7271
[ 'foo:bar:p42', 'foo:bar:P42' ],
72+
[ ':P42', 'P42' ],
7373
];
7474
}
7575

0 commit comments

Comments
 (0)