From 1c52db58032d067e49abaa19809ff4616730e1b5 Mon Sep 17 00:00:00 2001 From: eSilverStrike Date: Thu, 21 Nov 2019 10:28:28 -0500 Subject: [PATCH] Fix for URL class when Apache uses PHP FastCGI Fix for #999 --- plugins/links/functions.inc | 2 +- system/classes/url.class.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/links/functions.inc b/plugins/links/functions.inc index 0022e656a..37b90f7ae 100644 --- a/plugins/links/functions.inc +++ b/plugins/links/functions.inc @@ -98,7 +98,7 @@ function plugin_getmenuitems_links() return false; } - $menuitems[$LANG_LINKS[114]] = $_CONF['site_url'] . '/links/index.php'; + $menuitems[$LANG_LINKS[114]] = COM_buildURL($_CONF['site_url'] . '/links/index.php'); return $menuitems; } diff --git a/system/classes/url.class.php b/system/classes/url.class.php index f83fbfe34..d90ed37e6 100644 --- a/system/classes/url.class.php +++ b/system/classes/url.class.php @@ -239,8 +239,17 @@ private function getArguments() } array_shift($this->arguments); } elseif (isset($_ENV['ORIG_PATH_INFO'])) { - $this->arguments = explode('/', substr($_ENV['ORIG_PATH_INFO'], 1)); - $check_for_dirs = true; + if ($_ENV['ORIG_PATH_INFO'] == $_SERVER['SCRIPT_NAME']) { + // Added this check for Apache to work for PHP FastCGI + // This check is needed if the url does not contain any variables (ie "/links/index.php") in FastCGI on Apache. + // If contains variable then $_SERVER['PATH_INFO'] gets set (with or with out using FastCGI) + // On Apache that does not use FastCGI then none of the variables gets set ($_SERVER['PATH_INFO'], $_ENV['ORIG_PATH_INFO'], $_SERVER['ORIG_PATH_INFO']) + // so it ends up in the ELSE of the original IF statement + $this->arguments = array(); + } else { + $this->arguments = explode('/', substr($_ENV['ORIG_PATH_INFO'], 1)); + $check_for_dirs = true; + } } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { $this->arguments = explode('/', substr($_SERVER['ORIG_PATH_INFO'], 1)); $check_for_dirs = true;