MDL-31071 core: initial deprecation of file_encode_url
Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
issueNumber: MDL-31071
|
||||
notes:
|
||||
core:
|
||||
- message: >-
|
||||
The following function has been deprecated and should no longer be used:
|
||||
`file_encode_url`. Please consider using the `core\url` factory methods
|
||||
instead.
|
||||
type: deprecated
|
||||
@@ -854,3 +854,48 @@ function imagecopybicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $d
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
return imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes file serving url
|
||||
*
|
||||
* @deprecated use moodle_url factory methods instead
|
||||
* @todo Final deprecation on Moodle 6.0. See MDL-84939.
|
||||
*
|
||||
* @param string $urlbase
|
||||
* @param string $path /filearea/itemid/dir/dir/file.exe
|
||||
* @param bool $forcedownload
|
||||
* @param bool $https https url required
|
||||
* @return string encoded file url
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
replacement: 'core\url factory methods',
|
||||
since: '5.1',
|
||||
mdl: 'MDL-31071'
|
||||
)]
|
||||
function file_encode_url($urlbase, $path, $forcedownload = false, $https = false) {
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($CFG->slasharguments) {
|
||||
$parts = explode('/', $path);
|
||||
$parts = array_map('rawurlencode', $parts);
|
||||
$path = implode('/', $parts);
|
||||
$return = $urlbase . $path;
|
||||
if ($forcedownload) {
|
||||
$return .= '?forcedownload=1';
|
||||
}
|
||||
} else {
|
||||
$path = rawurlencode($path);
|
||||
$return = $urlbase . '?file=' . $path;
|
||||
if ($forcedownload) {
|
||||
$return .= '&forcedownload=1';
|
||||
}
|
||||
}
|
||||
|
||||
if ($https) {
|
||||
$return = str_replace('http://', 'https://', $return);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -55,47 +55,6 @@ require_once("$CFG->libdir/filestorage/file_storage.php");
|
||||
require_once("$CFG->libdir/filestorage/zip_packer.php");
|
||||
require_once("$CFG->libdir/filebrowser/file_browser.php");
|
||||
|
||||
/**
|
||||
* Encodes file serving url
|
||||
*
|
||||
* @deprecated use moodle_url factory methods instead
|
||||
*
|
||||
* @todo MDL-31071 deprecate this function
|
||||
* @global stdClass $CFG
|
||||
* @param string $urlbase
|
||||
* @param string $path /filearea/itemid/dir/dir/file.exe
|
||||
* @param bool $forcedownload
|
||||
* @param bool $https https url required
|
||||
* @return string encoded file url
|
||||
*/
|
||||
function file_encode_url($urlbase, $path, $forcedownload=false, $https=false) {
|
||||
global $CFG;
|
||||
|
||||
//TODO: deprecate this
|
||||
|
||||
if ($CFG->slasharguments) {
|
||||
$parts = explode('/', $path);
|
||||
$parts = array_map('rawurlencode', $parts);
|
||||
$path = implode('/', $parts);
|
||||
$return = $urlbase.$path;
|
||||
if ($forcedownload) {
|
||||
$return .= '?forcedownload=1';
|
||||
}
|
||||
} else {
|
||||
$path = rawurlencode($path);
|
||||
$return = $urlbase.'?file='.$path;
|
||||
if ($forcedownload) {
|
||||
$return .= '&forcedownload=1';
|
||||
}
|
||||
}
|
||||
|
||||
if ($https) {
|
||||
$return = str_replace('http://', 'https://', $return);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if area contains subdirs,
|
||||
* this is intended for file areas that are attached to content
|
||||
|
||||
Reference in New Issue
Block a user