Closed spicymoodles closed 4 months ago
Thanks for the report - Moodle coding guidelines state that we should use || and not "or" but the comparison against $file should be sitting inside some more brackets - surprising it worked with "or" before but not with || - I don't really like that structure so moved the $file = into it's own chunk above which should fix it - please let me know if that's sorted and I'll push out a new release to the plugins db.
Hi Dan, Thank you for this change. We have tested it, it's now working fine. Cheers
Environment:
Moodle version: 4.1 PHP versions tested: 7.4, 8.1 Dialogue plugin version: Latest commit 1243d4c
Description:
We are experiencing an issue in the Dialogue plugin where files uploaded in any format cannot be accessed. The problem stems from an incorrect application of the logical OR operator (||). The use of || leads to premature boolean evaluation, which interrupts the expected flow of file handling, resulting in access failures.
Error Message:
Exception: Call to a member function is_external_file() on bool
Debug info: Error code: generalexceptionmessage
Stack Trace: line 460 of /mod/dialogue/lib.php: Error thrown line 5221 of /lib/filelib.php: call to dialogue_pluginfile() line 44 of /pluginfile.php: call to file_pluginfile()
Steps to reproduce:
Steps to rectify: (Googled from https://tracker.moodle.org/browse/CONTRIB-9214)
In line 454 in /mod/dialogue/lib.php
Change:
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) || $file->is_directory()) {
To:
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {