catalyst / moodle-report_coursesize

upgraded coursesize report
14 stars 19 forks source link

PHP 8.1 support: Exception - Call to undefined function core\task\proc_open() #58

Open michael-milette opened 9 months ago

michael-milette commented 9 months ago

When I run the Course Size task manually, I get the following error message:

image

Here is the text from the screenshot:

Exception - Call to undefined function core\task\proc_open() Coding error detected, it must be fixed by a programmer: Invalid state passed to moodle_page::set_status. We are in state 3 and state 3 was requested.

With debugging set to DEVELOPER MODE, I see the following errors:

Some HTML tags were opened in the body of the page but not closed.

Open header/footer at: line 2656 of /lib/outputlib.php: call to xhtml_container_stack->log() line 1453 of /lib/outputrenderers.php: call to xhtml_container_stack->push() line 1979 of /lib/setuplib.php: call to core_renderer->header() line 64 of /admin/tool/task/schedule_task.php: call to bootstrap_renderer->__call()

Close header/footer at: line 2684 of /lib/outputlib.php: call to xhtml_container_stack->log() line 1515 of /lib/outputrenderers.php: call to xhtml_container_stack->pop() line 87 of /admin/tool/task/schedule_task.php: call to core_renderer->footer()

Open box at: line 2656 of /lib/outputlib.php: call to xhtml_container_stack->log() line 3298 of /lib/outputrenderers.php: call to xhtml_container_stack->push() line 3286 of /lib/outputrenderers.php: call to core_renderer->box_start() line 3036 of /lib/outputrenderers.php: call to core_renderer->box() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler()

Close box at: line 2684 of /lib/outputlib.php: call to xhtml_container_stack->log() line 3310 of /lib/outputrenderers.php: call to xhtml_container_stack->pop() line 3286 of /lib/outputrenderers.php: call to core_renderer->box_end() line 3036 of /lib/outputrenderers.php: call to core_renderer->box() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler() line 2701 of /lib/outputlib.php: call to debugging() line 1586 of /lib/outputrenderers.php: call to xhtml_container_stack->pop_all_but_last() line 1513 of /lib/outputrenderers.php: call to core_renderer->container_end_all() line 3062 of /lib/outputrenderers.php: call to core_renderer->footer() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler() There are no more open containers. This suggests there is a nesting problem.

Open header/footer at: line 2656 of /lib/outputlib.php: call to xhtml_container_stack->log() line 1453 of /lib/outputrenderers.php: call to xhtml_container_stack->push() line 1979 of /lib/setuplib.php: call to core_renderer->header() line 64 of /admin/tool/task/schedule_task.php: call to bootstrap_renderer->__call()

Close header/footer at: line 2684 of /lib/outputlib.php: call to xhtml_container_stack->log() line 1515 of /lib/outputrenderers.php: call to xhtml_container_stack->pop() line 87 of /admin/tool/task/schedule_task.php: call to core_renderer->footer()

Open box at: line 2656 of /lib/outputlib.php: call to xhtml_container_stack->log() line 3298 of /lib/outputrenderers.php: call to xhtml_container_stack->push() line 3286 of /lib/outputrenderers.php: call to core_renderer->box_start() line 3036 of /lib/outputrenderers.php: call to core_renderer->box() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler()

Close box at: line 2684 of /lib/outputlib.php: call to xhtml_container_stack->log() line 3310 of /lib/outputrenderers.php: call to xhtml_container_stack->pop() line 3286 of /lib/outputrenderers.php: call to core_renderer->box_end() line 3036 of /lib/outputrenderers.php: call to core_renderer->box() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler() line 2672 of /lib/outputlib.php: call to debugging() line 1515 of /lib/outputrenderers.php: call to xhtml_container_stack->pop() line 3062 of /lib/outputrenderers.php: call to core_renderer->footer() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler()

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /lib/outputrenderers.php on line 1546

Exception - Call to undefined function core\task\proc_open() Debug info: Error code: generalexceptionmessage Stack trace: line 1539 of /lib/classes/task/manager.php: Error thrown line 1519 of /lib/classes/task/manager.php: call to core\task\manager::passthru_via_mtrace() line 96 of /admin/tool/task/schedule_task.php: call to core\task\manager::run_from_cli() Coding error detected, it must be fixed by a programmer: Invalid state passed to moodle_page::set_state. We are in state 3 and state 3 was requested. Debug info: Error code: codingerror Stack trace: line 1119 of /lib/pagelib.php: coding_exception thrown line 1557 of /lib/outputrenderers.php: call to moodle_page->set_state() line 3062 of /lib/outputrenderers.php: call to core_renderer->footer() line 390 of /lib/setuplib.php: call to core_renderer->fatal_error() line ? of unknownfile: call to default_exception_handler()

Also, when I go to Site Administration > Reports > Course size, I see the following error:

The options argument should not be a context object directly. Please pass an array with a context key instead. line 1543 of /lib/weblib.php: call to debugging() line 241 of /report/coursesize/index.php: call to format_string()

Additional Information:

Course size version: 2023010900 Moodle version: 4.3.2+ PHP version: 8.1

Let me know if you need any additional information.

Best regards,

Michael Milette

melvyng commented 9 months ago

hi @michael-milette, the plugin need to be updated to work with php 8.1; you can fix at least 1 error editing the line 241 of /report/coursesize/index.php for this code

$context = context_system::instance();
$options[$cat->id] = format_string($cat->name, true, ['context' => $context]);

Melvyn

danmarsden commented 9 months ago

thanks for the report (and suggested patch) - feel free to help further by submitting a Pull request for review.

thanks!

michael-milette commented 8 months ago

Hi @danmarsden ,

Update:

I was able to resolve the issue with proc_open(). Turns out it had been disabled on the server for security reasons.

Thank you @melvyng for the fix of line 241. I replaced:

$options[$cat->id] = format_string($cat->name, true, context_system::instance());

... with ...

$options[$cat->id] = format_string($cat->name, true, ['context' => context_system::instance()]);

Now all I have left are a couple of hundred instances of the following deprecation notices (probably one per course):

Since neither of these functions appears anywhere in the code for Course Size, I assume that this might be a Moodle core issue.

By the way, I am now using it with PHP 8.2!

Best regards,

Michael