Merge branch 'MDL-73727-master' of https://github.com/keevan/moodle
This commit is contained in:
@@ -128,16 +128,36 @@ 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.
|
||||
$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
|
||||
)";
|
||||
$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;
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20220524" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20220531" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -2600,6 +2600,7 @@
|
||||
<INDEX NAME="contenthash" UNIQUE="false" FIELDS="contenthash"/>
|
||||
<INDEX NAME="pathnamehash" UNIQUE="true" FIELDS="pathnamehash"/>
|
||||
<INDEX NAME="license" UNIQUE="false" FIELDS="license"/>
|
||||
<INDEX NAME="filename" UNIQUE="false" FIELDS="filename"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="files_reference" COMMENT="Store files references">
|
||||
|
||||
@@ -4530,5 +4530,20 @@ privatefiles,moodle|/user/files.php';
|
||||
upgrade_main_savepoint(true, 2022052700.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2022052700.02) {
|
||||
|
||||
// Define index filename (not unique) to be added to files.
|
||||
$table = new xmldb_table('files');
|
||||
$index = new xmldb_index('filename', XMLDB_INDEX_NOTUNIQUE, ['filename']);
|
||||
|
||||
// Conditionally launch add index filename.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2022052700.02);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2022052700.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2022052700.02; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.1dev (Build: 20220527)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user