Skip to content

Commit 3e16117

Browse files
committed
Clean cache of definitions
1 parent 1ae70e4 commit 3e16117

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"minimum-stability": "stable",
3535
"require": {
3636
"php": ">=7.4",
37-
"stellarwp/models": "dev-release/2.0.0",
37+
"stellarwp/models": "dev-feature/definition-cache-control",
3838
"stellarwp/schema": "dev-feat/adding-the-order-by-param-in-get-all-by"
3939
},
4040
"require-dev": {

src/SchemaModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ abstract class SchemaModel extends Model implements SchemaModelInterface {
6161
* @since 0.0.1
6262
*/
6363
protected function afterConstruct(): void {
64+
self::purgePropertyDefinitionCache();
6465
$this->propertyCollection = ModelPropertyCollection::fromPropertyDefinitions( $this->getPropertyDefinitionsFromSchema() );
6566
$this->constructRelationships();
6667
}
@@ -579,7 +580,6 @@ public static function fromData( $data, $mode = self::BUILD_MODE_IGNORE_EXTRA )
579580
throw new InvalidArgumentException( 'SchemaModel cannot be instantiated directly.' );
580581
}
581582

582-
// @phpstan-ignore-next-line
583583
$model = new static();
584584

585585
foreach ( static::propertyKeys() as $key ) {
@@ -596,7 +596,7 @@ public static function fromData( $data, $mode = self::BUILD_MODE_IGNORE_EXTRA )
596596
$model->setAttribute( $key, static::castValueForProperty( static::getPropertyDefinition( $key ), $data[ $key ], $key ) );
597597
}
598598

599-
foreach ( $model->getRelationships() as $key => $relationship ) {
599+
foreach ( array_keys( $model->getRelationships() ) as $key ) {
600600
if ( ! isset( $data[ $key ] ) ) {
601601
continue;
602602
}

0 commit comments

Comments
 (0)