Skip to content

Commit 0d74bad

Browse files
refactor: clear model cache on api crud methods
1 parent 772cdf6 commit 0d74bad

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Model.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,9 @@ class Model {
21312131
$this->initial_object = $this->copy();
21322132
}
21332133

2134+
# Reset the object cache as the config has changed
2135+
Model::$object_cache = [];
2136+
21342137
# Return the current representation of this object
21352138
return $this;
21362139
}
@@ -2221,6 +2224,9 @@ class Model {
22212224
$this->initial_object = $this->copy();
22222225
}
22232226

2227+
# Reset the object cache as the config has changed
2228+
Model::$object_cache = [];
2229+
22242230
# Return the current representation of this object
22252231
return $this;
22262232
}
@@ -2314,6 +2320,9 @@ class Model {
23142320
clear_subsystem_dirty($this->subsystem);
23152321
}
23162322

2323+
# Reset the object cache as the config has changed
2324+
Model::$object_cache = [];
2325+
23172326
return $new_objects;
23182327
}
23192328

@@ -2399,6 +2408,9 @@ class Model {
23992408
$this->initial_object = $this->copy();
24002409
}
24012410

2411+
# Reset the object cache as the config has changed
2412+
Model::$object_cache = [];
2413+
24022414
# Return the current representation of this object
24032415
return $this;
24042416
}
@@ -2446,6 +2458,9 @@ class Model {
24462458
offset: $offset,
24472459
);
24482460

2461+
# Reset the object cache as the config has changed
2462+
Model::$object_cache = [];
2463+
24492464
# Delete the Model objects that matched the query
24502465
return $model_objects->delete();
24512466
}
@@ -2457,6 +2472,9 @@ class Model {
24572472
# Obtain all Model objects for this Model
24582473
$model_objects = self::read_all();
24592474

2475+
# Reset the object cache as the config has changed
2476+
Model::$object_cache = [];
2477+
24602478
# Delete all Model objects for this Model
24612479
return $model_objects->delete();
24622480
}

0 commit comments

Comments
 (0)