Skip to content

Commit

Permalink
Merge branch 'MDL-74283' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Mar 23, 2022
2 parents b46c643 + 4102ae3 commit d084f08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions h5p/tests/h5p_file_storage_test.php
Expand Up @@ -31,10 +31,9 @@
use file_archive;
use moodle_exception;
use ReflectionMethod;
use stored_file;
use zip_archive;

defined('MOODLE_INTERNAL') || die();

/**
* Test class covering the H5PFileStorage interface implementation.
*
Expand Down Expand Up @@ -782,7 +781,6 @@ public function test_getContentFile(): void {
* Tests that the content folder of an H5P content is imported in the Moodle filesystem.
*/
public function test_moveContentDiretory(): void {
global $DB;

// Create temp folder.
$tempfolder = make_request_directory(false);
Expand Down Expand Up @@ -818,19 +816,21 @@ public function test_moveContentDiretory(): void {
$this->h5p_file_storage->moveContentDirectory($h5pcontentfolder, $targeth5pcontentid);

// Get database records.
$sql = "SELECT concat(filepath, filename)
FROM {files}
WHERE filearea = :filearea AND itemid = :itemid AND component = :component AND filename != '.'";
$params = [
'component' => file_storage::COMPONENT,
'filearea' => file_storage::CONTENT_FILEAREA,
'itemid' => $targeth5pcontentid
];
$filesdb = $DB->get_fieldset_sql($sql, $params);
sort($filesdb);
$files = $this->h5p_fs_fs->get_area_files(
$this->h5p_fs_context->id,
file_storage::COMPONENT,
file_storage::CONTENT_FILEAREA,
$targeth5pcontentid,
'filepath, filename',
false
);

$filepaths = array_map(static function(stored_file $file): string {
return $file->get_filepath() . $file->get_filename();
}, $files);

// Check that created files match with database records.
$this->assertEquals($filesexpected, $filesdb);
$this->assertEquals($filesexpected, array_values($filepaths));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/task/manager.php
Expand Up @@ -986,7 +986,7 @@ public static function get_running_tasks($sort = ''): array {
$params = ['now1' => time(), 'now2' => time()];

$sql = "SELECT subquery.*
FROM (SELECT concat('s', ts.id) as uniqueid,
FROM (SELECT " . $DB->sql_concat("'s'", 'ts.id') . " as uniqueid,
ts.id,
'scheduled' as type,
ts.classname,
Expand All @@ -997,7 +997,7 @@ public static function get_running_tasks($sort = ''): array {
FROM {task_scheduled} ts
WHERE ts.timestarted IS NOT NULL
UNION ALL
SELECT concat('a', ta.id) as uniqueid,
SELECT " . $DB->sql_concat("'a'", 'ta.id') . " as uniqueid,
ta.id,
'adhoc' as type,
ta.classname,
Expand Down

0 comments on commit d084f08

Please sign in to comment.