bozoh / moodle-mod_simplecertificate

It's NOT RECOMMENDED to install version below 2.2.6 (MOODLE_31), due a security issues See more in README
17 stars 44 forks source link

3.9 version ( 2020041239 ) cannot write files #256

Open goose2000 opened 2 years ago

goose2000 commented 2 years ago

Describe the bug I would really like to continue using Simple Certificate with Moodle 4.0 so I tried to install and knew it would probably have problems but I want to report - hoping I might get some insight on fixing it for M4.x

In essence, it all installs and is configurable, but it has trouble writing files or temp file I believe: Error code: storedfilenotcreated

Moodle Version(s) Moodle 4.0 (Build: 20220419) - PHP 7.4 - MySQL 8.0

To Reproduce Steps to reproduce the behavior:

  1. Install version for moodle 3.9 from github branch - on a fresh Moodle 4.0 instance
  2. Create example Simple Certificate activity
  3. Try to view from "Issue a test certificate" tab - click Get Certificate
  4. Here is the debug info from Moodle :

Coding error detected, it must be fixed by a programmer: PHP catchable fatal error

More information about this error

×Debug info: Object of class stored_file could not be converted to string Error code: codingerror ×Stack trace: line 427 of \lib\setuplib.php: coding_exception thrown line 2315 of \lib\filelib.php: call to default_error_handler() line 2602 of \lib\filelib.php: call to readfile_accel() line 2756 of \lib\filelib.php: call to send_file() line 1325 of \mod\simplecertificate\locallib.php: call to send_stored_file() line 1911 of \mod\simplecertificate\locallib.php: call to simplecertificate->output_pdf() line 122 of \mod\simplecertificate\view.php: call to simplecertificate->view_default()

Expected behavior Open a PDF certificate in a pop-up window.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

dankonobre commented 1 year ago

Tracing back the error stack, it seems that moodle's debbugger is throwing an error 'cause is not possible to generate a file and show it in the same call (buffer error).

Disabling the debug messages in "/admin/settings.php?section=debugging" seems to avoid this problem.

leonstr commented 1 year ago

This issue is complicated by the code to the handle errors in readfile_accel() containing an error, see MDL-72582. The _Object of class storedfile could not be converted to string message is this second error within Moodle, not the error causing the problem.