mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-74910 core_files: Return SQL to initial state
MDL-73727 aimed to improve the performance of the get_conversions_for_file SQL. Unfortunately it also changed the behvaiour of the SQL. On further investigation, there is nothing wrong with the SQL. This patch returns it back to its initial state.
This commit is contained in:
parent
d9632ca8b2
commit
c9da36d731
@ -128,36 +128,13 @@ class conversion extends \core\persistent {
|
||||
|
||||
// Fetch actual conversions which relate to the specified source file, and have a matching conversion record,
|
||||
// and either have a valid destination file which still exists, or do not have a destination file at all.
|
||||
$dbfamily = $DB->get_dbfamily();
|
||||
switch ($dbfamily) {
|
||||
// For certain DB engines, use a more optimised query.
|
||||
case 'mysql':
|
||||
case 'postgres':
|
||||
$sql = "SELECT {$sqlfields}
|
||||
FROM {" . self::TABLE . "} c
|
||||
JOIN (SELECT id
|
||||
FROM {files}
|
||||
WHERE contenthash = :ccontenthash
|
||||
LIMIT 1
|
||||
) conversionsourcefile ON conversionsourcefile.id = c.sourcefileid
|
||||
LEFT JOIN {files} conversiondestfile ON conversiondestfile.id = c.destfileid
|
||||
WHERE c.targetformat = :cformat
|
||||
AND (c.destfileid IS NULL
|
||||
OR conversiondestfile.id IS NOT NULL)";
|
||||
break;
|
||||
|
||||
// For everything else, use the standard cross-db compatible query.
|
||||
default:
|
||||
$sql = "SELECT {$sqlfields}
|
||||
FROM {" . self::TABLE . "} c
|
||||
INNER JOIN {files} conversionsourcefile ON conversionsourcefile.id = c.sourcefileid
|
||||
LEFT JOIN {files} conversiondestfile ON conversiondestfile.id = c.destfileid
|
||||
WHERE conversionsourcefile.contenthash = :ccontenthash
|
||||
AND c.targetformat = :cformat
|
||||
AND (c.destfileid IS NULL
|
||||
OR conversiondestfile.id IS NOT NULL)";
|
||||
break;
|
||||
}
|
||||
$sql = "SELECT {$sqlfields}
|
||||
FROM {" . self::TABLE . "} c
|
||||
JOIN {files} conversionsourcefile ON conversionsourcefile.id = c.sourcefileid
|
||||
LEFT JOIN {files} conversiondestfile ON conversiondestfile.id = c.destfileid
|
||||
WHERE conversionsourcefile.contenthash = :ccontenthash
|
||||
AND c.targetformat = :cformat
|
||||
AND (c.destfileid IS NULL OR conversiondestfile.id IS NOT NULL)";
|
||||
|
||||
// Fetch a empty conversion record for each source/destination combination that we find to match where the
|
||||
// destination file is in the correct filearea/filepath/filename combination to meet the requirements.
|
||||
|
Loading…
x
Reference in New Issue
Block a user