From f31f885ed0f1b2d70f7b5887868940a52b2ac655 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 13 Apr 2020 13:31:03 -0400 Subject: [PATCH] Deprecate redundant function CRM_Utils_System::getUrlPath Both functions do the same thing; deprecating getUrlPath in favor of the older currentPath. --- CRM/Core/Controller.php | 2 +- CRM/Core/Resources.php | 2 +- CRM/Utils/System.php | 15 +++++++-------- CRM/Utils/System/DrupalBase.php | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 8bfbc6de4c..26a4eff054 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -442,7 +442,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { $$stateName->setOptions($options); } if (property_exists($$stateName, 'urlPath')) { - $$stateName->urlPath = explode('/', (string) CRM_Utils_System::getUrlPath()); + $$stateName->urlPath = explode('/', (string) CRM_Utils_System::currentPath()); } $this->addPage($$stateName); $this->addAction($stateName, new HTML_QuickForm_Action_Direct()); diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index b4532ff26c..653a4f3b08 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -865,7 +865,7 @@ class CRM_Core_Resources { ) { return TRUE; } - list($arg0, $arg1) = array_pad(explode('/', CRM_Utils_System::getUrlPath()), 2, ''); + list($arg0, $arg1) = array_pad(explode('/', CRM_Utils_System::currentPath()), 2, ''); return ($arg0 === 'civicrm' && in_array($arg1, ['ajax', 'angularprofiles', 'asset'])); } diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index a8f78576e3..08b874f1d3 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -322,15 +322,14 @@ class CRM_Utils_System { } /** - * Path of the current page e.g. 'civicrm/contact/view' + * @deprecated + * @see \CRM_Utils_System::currentPath * * @return string|null */ public static function getUrlPath() { - if (isset($_GET[CRM_Core_Config::singleton()->userFrameworkURLVar])) { - return $_GET[CRM_Core_Config::singleton()->userFrameworkURLVar]; - } - return NULL; + CRM_Core_Error::deprecatedFunctionWarning('CRM_Utils_System::currentPath'); + return self::currentPath(); } /** @@ -356,14 +355,14 @@ class CRM_Utils_System { } /** - * What menu path are we currently on. Called for the primary tpl. + * Path of the current page e.g. 'civicrm/contact/view' * - * @return string + * @return string|null * the current menu path */ public static function currentPath() { $config = CRM_Core_Config::singleton(); - return trim(CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET), '/'); + return isset($_GET[$config->userFrameworkURLVar]) ? trim($_GET[$config->userFrameworkURLVar], '/') : NULL; } /** diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index a9c72b07db..2dd06c9e7e 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -655,7 +655,7 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { * @return bool */ public function isFrontEndPage() { - $path = CRM_Utils_System::getUrlPath(); + $path = CRM_Utils_System::currentPath(); // Get the menu for above URL. $item = CRM_Core_Menu::get($path); -- 2.25.1