From 8fdefd873fe728430e537ce57f22444d9f1313fa Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Fri, 1 Nov 2024 11:43:39 -0400 Subject: [PATCH 1/3] Ensure a more graceful deprecation of props in Settings class. --- src/Tribe/Settings.php | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/Tribe/Settings.php b/src/Tribe/Settings.php index 0cbe3779d..8a5e17827 100755 --- a/src/Tribe/Settings.php +++ b/src/Tribe/Settings.php @@ -284,9 +284,59 @@ public function __construct() { $this->default_tab = null; $this->current_tab = null; + /** + * Once we remove our last usage these internally in Event Tickets and Event Tickets Plus we can + * remove these from our code and keep the magic getter to be able to catch any other usage. + * + * @deprecated 6.1.0 + */ + $this->menuName = $this->menu_name; + $this->requiredCap = $this->required_cap; + $this->allTabs = $this->all_tabs; + $this->defaultTab = $this->default_tab; + $this->currentTab = $this->current_tab; + $this->noSaveTabs = $this->no_save_tabs; + $this->adminSlug = $this->admin_slug; + $this->hook(); } + /** + * Magic getter for deprecated properties. + * + * @since TBD + * + * @param string $name + * + * @return mixed + */ + public function __get( $name ) { + // Map of deprecated properties and their respective actual property names. + $properties = [ + 'menuName' => 'menu_name', + 'requiredCap' => 'required_cap', + 'allTabs' => 'all_tabs', + 'defaultTab' => 'default_tab', + 'currentTab' => 'current_tab', + 'noSaveTabs' => 'no_save_tabs', + 'adminSlug' => 'admin_slug', + ]; + + // Check if the requested property exists in the map + if ( isset( $properties[ $name ] ) ) { + // Trigger deprecation notice for camel-case property names + trigger_deprecation( + __CLASS__, + '6.1.0', + 'Replace the use of ' . $name . ' with ' . $properties[ $name ] . ' in your code.' + ); + + return $this->{$properties[ $name ]}; + } + + return null; + } + /** * Hooks the actions and filters required for the class to work. */ From 7e4682bc6f9a636d7395d4ec5fbee11168cb2099 Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Fri, 1 Nov 2024 11:47:17 -0400 Subject: [PATCH 2/3] Fix some Code Sniffer problems --- src/Tribe/Settings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tribe/Settings.php b/src/Tribe/Settings.php index 8a5e17827..4a984298b 100755 --- a/src/Tribe/Settings.php +++ b/src/Tribe/Settings.php @@ -306,7 +306,7 @@ public function __construct() { * * @since TBD * - * @param string $name + * @param string $name The property name we are looking for. * * @return mixed */ @@ -322,9 +322,9 @@ public function __get( $name ) { 'adminSlug' => 'admin_slug', ]; - // Check if the requested property exists in the map + // Check if the requested property exists in the map. if ( isset( $properties[ $name ] ) ) { - // Trigger deprecation notice for camel-case property names + // Trigger deprecation notice for camel-case property names. trigger_deprecation( __CLASS__, '6.1.0', From 6c27025a19d42a2e5667500f91d645ee8761ac06 Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Fri, 1 Nov 2024 11:59:07 -0400 Subject: [PATCH 3/3] Include changelog --- changelog/fix-TEC-5312-deprecated-props-still-in-use | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-TEC-5312-deprecated-props-still-in-use diff --git a/changelog/fix-TEC-5312-deprecated-props-still-in-use b/changelog/fix-TEC-5312-deprecated-props-still-in-use new file mode 100644 index 000000000..e56f9eddd --- /dev/null +++ b/changelog/fix-TEC-5312-deprecated-props-still-in-use @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Include backwards compatibility for deprecated proprieties in the Settings class used in The Events Calendar and Event Tickets [TEC-5312]