open-lms-open-source / moodle-theme_snap

GNU General Public License v3.0
79 stars 75 forks source link

imagejpeg error #258

Open mikeatcityuni opened 1 year ago

mikeatcityuni commented 1 year ago

Hi, we're getting an error with snap when we add a course image in the course settings. Actually we don't even use snap but the error is still reported! We've got version 4.0.5 (2023012400)

debug message:

line 190 of /theme/snap/classes/image.php: ArgumentCountError thrown line 190 of /theme/snap/classes/image.php: call to imagejpeg() line 1296 of /theme/snap/classes/local.php: call to theme_snap\image::resize() line 1569 of /theme/snap/classes/local.php: call to theme_snap\local::set_course_card_image() line 58 of /theme/snap/classes/event_handlers.php: call to theme_snap\local::process_coverimage() line ? of unknownfile: call to theme_snap\event_handlers::course_updated() line 155 of /lib/classes/event/manager.php: call to call_user_func() line 75 of /lib/classes/event/manager.php: call to core\event\manager::process_buffers() line 834 of /lib/classes/event/base.php: call to core\event\manager::dispatch() line 2472 of /course/lib.php: call to core\event\base->trigger() line 191 of /course/edit.php: call to update_course()

https://www.php.net/manual/en/function.imagejpeg.php

imagejpeg(GdImage $image, resource|string|null $file = null, int $quality = -1): bool imagejpeg() creates a JPEG file from the given image.

so it should have 3 arguments but Snap gives it four, when a jpeg is used:

moodle-theme_snap/classes/image.php line: 189-192

\ob_start(); if (!$imagefnc($newimage, null, $quality, $filters)) { return false; }

if png it should be fine as that does take 4 arguments, sure enough, adding a png results in no error