-
Bug
-
Resolution: Not a bug
-
Major
-
None
-
2.0.2
-
Windows Server 2008 R2 SP1 with SQL 2008 R2, PHP 5.3.5
-
Microsoft SQL
-
MOODLE_20_STABLE
-
s10_
MDL-27261_recentfiles_plugin_sql_fix_master -
Easy
-
Choosing Recent Files repository in the filepicker always returns a Database Error window.
An SQL error message is logged in the PHP-errors log file, see attached example of the error.
Changed LIB.PHP in the Recent repository:
Use this SQL query:
$sql = 'SELECT * FROM
JOIN (SELECT MAX(id) AS maxid
FROM {files}
WHERE userid = ? AND filename != ? AND ((filearea = ? AND itemid = ?) OR filearea != ?)
GROUP BY contenthash, filename) files2 ON files1.id = files2.maxid
ORDER BY files1.timemodified DESC';
Is joining the table onto itself and was returning the same fieldnames more than once, removed dups and renamed the key.
Now works as expected.