@@ -659,6 +659,8 @@ class Model {
659659 * @returns mixed $val or $default if the path prefix does not exist
660660 */
661661 public static function set_config (string $ path , mixed $ value , mixed $ default = null ): mixed {
662+ # Clear the object cache for this Model class since config is being modified
663+ self ::clear_object_cache ();
662664 return config_set_path (self ::normalize_config_path ($ path ), $ value , $ default );
663665 }
664666
@@ -703,6 +705,8 @@ class Model {
703705 * @returns array copy of the removed value or null
704706 */
705707 public static function del_config (string $ path ): mixed {
708+ # Clear the object cache for this Model class since config is being modified
709+ self ::clear_object_cache ();
706710 return config_del_path (self ::normalize_config_path ($ path ));
707711 }
708712
@@ -739,6 +743,9 @@ class Model {
739743 write_config (sprintf (gettext (' ' . $ change_note )));
740744 session_destroy ();
741745
746+ # Clear the object cache for this Model class since config has been modified
747+ self ::clear_object_cache ();
748+
742749 # If a subsystem is specified for this Model, mark it as dirty
743750 if ($ this ->subsystem ) {
744751 mark_subsystem_dirty ($ this ->subsystem );
@@ -766,6 +773,10 @@ class Model {
766773 */
767774 public static function reload_config (bool $ force_parse = false ): void {
768775 global $ config ;
776+
777+ # Clear the object cache for all Model classes since config is being reloaded
778+ self ::clear_object_cache ();
779+
769780 $ config = parse_config (parse: $ force_parse );
770781 }
771782
@@ -2123,9 +2134,6 @@ class Model {
21232134
21242135 # Refresh the initial object
21252136 $ this ->initial_object = $ this ->copy ();
2126-
2127- # Clear the object cache for this Model class
2128- $ this ->clear_object_cache ();
21292137 }
21302138
21312139 # Return the current representation of this object
@@ -2216,9 +2224,6 @@ class Model {
22162224
22172225 # Refresh the initial object
22182226 $ this ->initial_object = $ this ->copy ();
2219-
2220- # Clear the object cache for this Model class
2221- $ this ->clear_object_cache ();
22222227 }
22232228
22242229 # Return the current representation of this object
@@ -2314,9 +2319,6 @@ class Model {
23142319 clear_subsystem_dirty ($ this ->subsystem );
23152320 }
23162321
2317- # Clear the object cache for this Model class
2318- $ this ->clear_object_cache ();
2319-
23202322 return $ new_objects ;
23212323 }
23222324
@@ -2400,9 +2402,6 @@ class Model {
24002402
24012403 # Refresh the initial object
24022404 $ this ->initial_object = $ this ->copy ();
2403-
2404- # Clear the object cache for this Model class
2405- $ this ->clear_object_cache ();
24062405 }
24072406
24082407 # Return the current representation of this object
@@ -2452,10 +2451,8 @@ class Model {
24522451 offset: $ offset ,
24532452 );
24542453
2455- # Delete the Model objects that matched the query and clear the object cache
2456- $ deleted_model_objects = $ model_objects ->delete ();
2457- self ::clear_object_cache ();
2458- return $ deleted_model_objects ;
2454+ # Delete the Model objects that matched the query
2455+ return $ model_objects ->delete ();
24592456 }
24602457
24612458 /**
@@ -2465,10 +2462,8 @@ class Model {
24652462 # Obtain all Model objects for this Model
24662463 $ model_objects = self ::read_all ();
24672464
2468- # Delete all Model objects for this Model and clear the object cache
2469- $ deleted_model_objects = $ model_objects ->delete ();
2470- self ::clear_object_cache ();
2471- return $ deleted_model_objects ;
2465+ # Delete all Model objects for this Model
2466+ return $ model_objects ->delete ();
24722467 }
24732468
24742469 /**
0 commit comments