thexerteproject / xerteonlinetoolkits

Xerte Online Toolkits
www.xerte.org.uk
Apache License 2.0
62 stars 61 forks source link

critical error in develop after latest changes #1194

Closed ronm123 closed 1 year ago

ronm123 commented 1 year ago

Hi all I know we've got a session scheduled for tomorrow to test the folder sharing but I thought I'd pull down the latest develop changes and test with that in advance of tomorrow. May not be related to the folder sharing code but I pulled down the changes, ran upgrade, cleared offline files and now I get the following error when trying to edit any projects: Uncaught TypeError: Cannot read properties of null (reading 'src') at 22677 (commons.js:2:2005233) at l (content.js:1:708728) at content.js:1:710077 at l.O (content.js:1:709014) at content.js:1:710092 at content.js:1:710098

ronm123 commented 1 year ago

With debugging on this points to: Parse error: syntax error, unexpected ':', expecting '{' in modules\xerte\edithtml.php on line 29 and line 29 is: function get_children ($parent_id, $lookup, $column, $type) : array {

is this another PHP compatibility error? On my local xampp I'm running 5.6.8 deliberately to pick up on these errors and the last time we had something similar I seem to recall that we changed the code so that 5.6.8 still works.

ronm123 commented 1 year ago

I did some further testing and this does seem to be a PHP compatibility issue... If I switch to PHP 7.2 on the same xampp develop install that previous error goes away however I then get the following error which seems to be with finding the plugins folder e.g. Warning: scandir(modules/xerte/parent_templates/Nottingham/plugins/,modules/xerte/parent_templates/Nottingham/plugins/): The system cannot find the file specified. (code: 2) in modules\xerte\play.php on line 125 Warning: scandir(modules/xerte/parent_templates/Nottingham/plugins/): failed to open dir: No such file or directory in modules\xerte\play.php on line 125 Warning: scandir(): (errno 2): No such file or directory in modules\xerte\play.php on line 125 Warning: Invalid argument supplied for foreach() in modules\xerte\play.php on line 127

line 125 is: $pluginfiles = scandir($template_path . "plugins/"); if I change that to a baxkslash instead e.g.: $pluginfiles = scandir($template_path . "plugins\"); I get following error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in modules\xerte\play.php on line 130

Not sure if resolving the first error so that it works with PHP 5.6.8 will then result in similar plugins folder issues so I'm going to stop at this point and await suggests.

ronm123 commented 1 year ago

So nobody else getting these issues?

With the first error I changed function get_children ($parent_id, $lookup, $column, $type) : array { to function get_children ($parent_id, $lookup, $column, $type) { e.g. removing : array and then it works with PHP 5.6.8 however I don't know if that means something is incorrect/needed?

With the path to plugins error which arises with PHP 5.6.8 too once the array error is removed is simply because the code in play.php on line 125 is looking for a plugins folder inside modules\xerte\parent_templates\Nottingham\ which doesn't exist! So are there new plugins or an empty folder that hasn't been committed?

ronm123 commented 1 year ago

@FayCross as discussed the first error (array declaration) showed when trying to edit an XOT or Bootstrap project when using PHP 5.6.8. I have committed a fix for that for both projects https://github.com/thexerteproject/xerteonlinetoolkits/commit/7af597986a205b99090e0296b7988e1a0c90ce25

The second error regarding plugins folder isn't related to PHP version and the immediate fix we can do in our own test installation is to manually add an empty plugins folder inside modules\xerte\parent_templates\Nottingham\

However before the release @torinfo is going to ensure that an empty plugins folder is included or do a check for the folder in the code to avoid the errors.

@torinfo I'll leave this issue open as a reminder so perhaps you can just close it when you have added a fix for the plugins folder issue?

torinfo commented 1 year ago

@ronm123 @FayCross I fixed the issue with the plugins folder as well (check in the code)