Skip to content

Commit

Permalink
Merge pull request Shardj#410 from muli/fix_deprecated_usage_of_strin…
Browse files Browse the repository at this point in the history
…g_functions

Fix deprecated usage of string functions in `BaseUrl` helper.
  • Loading branch information
develart-projects authored Jul 22, 2024
2 parents bd0c634 + 5f6cce1 commit 94d85ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Controller/Front.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public function setBaseUrl($base = null)
/**
* Retrieve the currently set base URL
*
* @return string
* @return string|null
*/
public function getBaseUrl()
{
Expand Down
12 changes: 8 additions & 4 deletions library/Zend/View/Helper/BaseUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public function baseUrl($file = null)
/**
* Set BaseUrl
*
* @param string $base
* @param string|null $base
* @return Zend_View_Helper_BaseUrl
*/
public function setBaseUrl($base)
{
$this->_baseUrl = rtrim($base, '/\\');
$this->_baseUrl = rtrim($base ?? '', '/\\');
return $this;
}

Expand Down Expand Up @@ -97,8 +97,8 @@ public function getBaseUrl()
/**
* Remove Script filename from baseurl
*
* @param string $url
* @return string
* @param string|null $url
* @return string|null
*/
protected function _removeScriptName($url)
{
Expand All @@ -107,6 +107,10 @@ protected function _removeScriptName($url)
return $url;
}

if ($url === null) {
return null;
}

if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) {
$url = substr($url, 0, $pos);
}
Expand Down

0 comments on commit 94d85ab

Please sign in to comment.