mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
MDL-70968 core: PHP8 compatibility, not allowed to pass extra parameters
This commit is contained in:
parent
95dd305cc6
commit
593540cc19
1 changed files with 16 additions and 0 deletions
|
@ -233,6 +233,14 @@ function process_new_icon($context, $component, $filearea, $itemid, $originalfil
|
||||||
|
|
||||||
$icon = array('contextid'=>$context->id, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>'/');
|
$icon = array('contextid'=>$context->id, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>'/');
|
||||||
|
|
||||||
|
if ($imagefnc === 'imagejpeg') {
|
||||||
|
// Function imagejpeg() accepts less arguments than imagepng() but we need to make $imagefnc accept the same
|
||||||
|
// number of arguments, otherwise PHP8 throws an error.
|
||||||
|
$imagefnc = function($image, $filename, $quality, $unused) {
|
||||||
|
return imagejpeg($image, $filename, $quality);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
if (!$imagefnc($im1, NULL, $quality, $filters)) {
|
if (!$imagefnc($im1, NULL, $quality, $filters)) {
|
||||||
// keep old icons
|
// keep old icons
|
||||||
|
@ -384,6 +392,14 @@ function resize_image_from_image($original, $imageinfo, $width, $height, $forcec
|
||||||
|
|
||||||
imagecopybicubic($newimage, $original, $dstx, $dsty, 0, 0, $targetwidth, $targetheight, $originalwidth, $originalheight);
|
imagecopybicubic($newimage, $original, $dstx, $dsty, 0, 0, $targetwidth, $targetheight, $originalwidth, $originalheight);
|
||||||
|
|
||||||
|
if ($imagefnc === 'imagejpeg') {
|
||||||
|
// Function imagejpeg() accepts less arguments than imagepng() but we need to make $imagefnc accept the same
|
||||||
|
// number of arguments, otherwise PHP8 throws an error.
|
||||||
|
$imagefnc = function($image, $filename, $quality, $unused) {
|
||||||
|
return imagejpeg($image, $filename, $quality);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Capture the image as a string object, rather than straight to file.
|
// Capture the image as a string object, rather than straight to file.
|
||||||
ob_start();
|
ob_start();
|
||||||
if (!$imagefnc($newimage, null, $quality, $filters)) {
|
if (!$imagefnc($newimage, null, $quality, $filters)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue