moodle-block_configurablereports icon indicating copy to clipboard operation
moodle-block_configurablereports copied to clipboard

Fix preferred log reader obtaining

Open Royerino opened this issue 2 years ago • 1 comments

There is a minor bug in the cr_logging_info() function in locallib.php. If more than one log reader is enabled on a Moodle site, it will ignore the order priority, as the foreach that iterates through the readers doesn't stop once it obtains the first reader. In my proposed solution, it will break the foreach once it obtains the first log reader established in the configuration, be it the standard log, the legacy log, or whichever other log reader is preferred.

This bug can be easily reproduced if you have some courses with user activity and try to create a configurable report that calculates the time spent on a course. If the preferred log reader is the Standard Log, it will show 0 hours for every user, as it won't find any record of user activity on the mdl_log, which is the one that is consulting due to this bug.

Royerino avatar Oct 20 '22 08:10 Royerino

Hi @Royerino! Thanks for reporting this and working on a patch for fixing it. I've tried to reproduce the error but I haven't been able to... Could you please share some more detailed testing instructions? The first break looks OK to me but, as I don't know logs deeply, I'm worried because looking at the code it seems the idea is to prioritise logstore_legacy over sql_internal_table_reader or sql_internal_reader... so adding the second break might remove priority to logstore_legacy.

sarjona avatar Dec 01 '22 16:12 sarjona