File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class EntityRetrievingDataTypeLookup implements PropertyDataTypeLookup {
2020 * @var EntityLookup
2121 */
2222 private $ entityLookup ;
23+ private array $ propertyIdsInProcess = [];
2324
2425 public function __construct ( EntityLookup $ entityLookup ) {
2526 $ this ->entityLookup = $ entityLookup ;
@@ -34,6 +35,11 @@ public function __construct( EntityLookup $entityLookup ) {
3435 * @throws PropertyDataTypeLookupException
3536 */
3637 public function getDataTypeIdForProperty ( PropertyId $ propertyId ) {
38+ if ( array_key_exists ( $ propertyId ->getSerialization (), $ this ->propertyIdsInProcess ) ) {
39+ // avoid self-referencing loop for newly created properties (T374230)
40+ throw new PropertyDataTypeLookupException ( $ propertyId , 'loop detected ' );
41+ }
42+ $ this ->propertyIdsInProcess [ $ propertyId ->getSerialization () ] = true ;
3743 return $ this ->getProperty ( $ propertyId )->getDataTypeId ();
3844 }
3945
@@ -50,6 +56,8 @@ private function getProperty( PropertyId $propertyId ) {
5056 throw new PropertyDataTypeLookupException ( $ propertyId );
5157 }
5258
59+ unset( $ this ->propertyIdsInProcess [ $ propertyId ->getSerialization () ] );
60+
5361 return $ property ;
5462 }
5563
You can’t perform that action at this time.
0 commit comments