diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 1971bdc9f3b..8c85c9d60bc 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2359,3 +2359,23 @@ function get_timezone_record($timezonename) { } /* === Apis deprecated since Moodle 3.0 === */ +/** + * Returns the URL of the HTTP_REFERER, less the querystring portion if required. + * + * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more. + * @todo Remove this function in Moodle 3.2 + * @param boolean $stripquery if true, also removes the query part of the url. + * @return string The resulting referer or empty string. + */ +function get_referer($stripquery = true) { + debugging('get_referer() is deprecated. Please use get_local_referer() instead.', DEBUG_DEVELOPER); + if (isset($_SERVER['HTTP_REFERER'])) { + if ($stripquery) { + return strip_querystring($_SERVER['HTTP_REFERER']); + } else { + return $_SERVER['HTTP_REFERER']; + } + } else { + return ''; + } +} \ No newline at end of file diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 347855f7eef..b787dd8b11c 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -3,6 +3,7 @@ information provided here is intended especially for developers. === 3.0 === +* get_referer() has been deprecated, please use the get_local_referer function instead. * \core\progress\null is renamed to \core\progress\none for improved PHP7 compatibility as null is a reserved word (see MDL-50453). * \webservice_xmlrpc_client now respects proxy server settings. If your XMLRPC server is available on your local network and not via your proxy server, you may need to add it to the list of proxy server exceptions in $CFG->proxybypass. See MDL-39353 for details. diff --git a/lib/weblib.php b/lib/weblib.php index 696caa53e0c..3c7d44e4c03 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -158,24 +158,6 @@ function strip_querystring($url) { } } -/** - * Returns the URL of the HTTP_REFERER, less the querystring portion if required. - * - * @param boolean $stripquery if true, also removes the query part of the url. - * @return string The resulting referer or empty string. - */ -function get_referer($stripquery=true) { - if (isset($_SERVER['HTTP_REFERER'])) { - if ($stripquery) { - return strip_querystring($_SERVER['HTTP_REFERER']); - } else { - return $_SERVER['HTTP_REFERER']; - } - } else { - return ''; - } -} - /** * Returns the name of the current script, WITH the querystring portion. *