@@ -598,7 +598,10 @@ class Model {
598598 * @param $path string config path with '/' as separators
599599 */
600600 protected static function init_config (string $ path ) {
601- # Initialize the configuration array of a specified path.
601+ # Remove leading slashes and extra slashes
602+ $ path = trim ($ path , '/ ' );
603+
604+ # Initialize the configuration array of a specified path
602605 config_init_path ($ path );
603606 }
604607
@@ -610,6 +613,9 @@ class Model {
610613 * path keys an empty string and $default is non-null
611614 */
612615 public static function get_config (string $ path , mixed $ default = null ) {
616+ # Remove leading slashes and extra slashes
617+ $ path = trim ($ path , '/ ' );
618+
613619 return config_get_path ($ path , $ default );
614620 }
615621
@@ -621,6 +627,9 @@ class Model {
621627 * @returns mixed $val or $default if the path prefix does not exist
622628 */
623629 public static function set_config (string $ path , mixed $ value , mixed $ default = null ) {
630+ # Remove leading slashes and extra slashes
631+ $ path = trim ($ path , '/ ' );
632+
624633 return config_set_path ($ path , $ value , $ default );
625634 }
626635
@@ -631,6 +640,9 @@ class Model {
631640 * @param $path string The Model config path including any Model ID
632641 */
633642 public function merge_config (string $ path ) {
643+ # Remove leading slashes and extra slashes
644+ $ path = trim ($ path , '/ ' );
645+
634646 # Loop through each field known to this Model
635647 foreach ($ this ->get_fields () as $ field ) {
636648 # Determine the field path
@@ -662,6 +674,9 @@ class Model {
662674 * @returns array copy of the removed value or null
663675 */
664676 public static function del_config (string $ path ): mixed {
677+ # Remove leading slashes and extra slashes
678+ $ path = trim ($ path , '/ ' );
679+
665680 return config_del_path ($ path );
666681 }
667682
@@ -675,6 +690,9 @@ class Model {
675690 * non-null value, otherwise false.
676691 */
677692 public static function is_config_enabled (string $ path , string $ enable_key = 'enable ' ): bool {
693+ # Remove leading slashes and extra slashes
694+ $ path = trim ($ path , '/ ' );
695+
678696 return config_path_enabled ($ path , $ enable_key );
679697 }
680698
0 commit comments