Wunderbyte-GmbH / moodle-theme_squared

Moodle Theme based on squares
GNU General Public License v3.0
2 stars 3 forks source link

Problem with renderer in mod workshop - Moodle 3.9, newest squared #6

Closed dasistwas closed 3 years ago

dasistwas commented 3 years ago

When I open the workshop activity, I get this error:

Warning: strpos() expects parameter 1 to be string, array given in /moodleroot/theme/squared/classes/output/core_renderer.php on line 1087

Can't find data record in database.

More information about this error
Debug info: SELECT cm.*, m.name, md.name AS modname
FROM {course_modules} cm
JOIN {modules} md ON md.id = cm.module
JOIN {book} m ON m.id = cm.instance

WHERE cm.id = :cmid AND md.name = :modulename

[array (
'cmid' => 131534,
'modulename' => 'book',
)]
Error code: invalidrecordunknown
Stack trace:

    line 1627 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
    line 1230 of /lib/datalib.php: call to moodle_database->get_record_sql()
    line 1093 of /theme/squared/classes/output/core_renderer.php: call to get_coursemodule_from_id()
    line 3081 of /lib/outputrenderers.php: call to theme_squared\output\core_renderer->box_start()
    line 497 of /lib/outputrenderers.php: call to core_renderer->box()
    line 564 of /mod/workshop/view.php: call to plugin_renderer_base->__call()

Error does not appear when using theme boost with same activity.

dasistwas commented 3 years ago

Screenshot_2020-12-22 eTivity 8 Abschlussaufgabe (Closed)

dasistwas commented 3 years ago

also there are some styling issues, but maybe due to custom css.

dasistwas commented 3 years ago

The id shown in the debug is a workshop id not a book id: mod/workshop/view.php?id=131534

gjb2048 commented 3 years ago

@dasistwas Odd. Stack trace and code reads like a core issue. Need to think of how can be fixed in theme and why does not affect Boost.

gjb2048 commented 3 years ago

@dasistwas Given https://www.php.net/manual/en/function.call-user-func-array.php what version of PHP are you running please?

dasistwas commented 3 years ago

7.4

gjb2048 commented 3 years ago

@dasistwas Thank you. I believe I've fixed it with https://github.com/Wunderbyte-GmbH/moodle-theme_squared/commit/fbfef7be95708a7648313e6b4b3fd1551f589e2a. I've tested with both the Workshop and Book activities. Please pull from 'master' of Squared and test. It's an oddity whereby the code documentation say its a string, when rather it is an array of strings when called from Workshop's view.php on line 564 as stated in the stack trace. The magic 'call' is decoding the parameter array correctly and assigning the relevant order for the parameter list, its just that 'classes' is being passed an array by Mod Workshop when it should not, hence core code has the call to 'renderer_base::prepare_classes' before it does anything with it, and it has a 'is_array' check that when true, 'impodes' the array into a string with a space as a delimiter.

dasistwas commented 3 years ago

@gjb2048 great analysis of the problem. The fix solved the problem. Thank you.