From 1e76b27a3755f32ce0f092eeb19eaabf4d4a8255 Mon Sep 17 00:00:00 2001 From: Rossco Hellmans Date: Wed, 28 Aug 2024 16:13:13 +1000 Subject: [PATCH] Fix: php warnings and deprecations --- classes/editor_ajax.php | 3 ++- classes/file_storage.php | 2 +- classes/framework.php | 38 +++++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/classes/editor_ajax.php b/classes/editor_ajax.php index ef207649..2b22943c 100644 --- a/classes/editor_ajax.php +++ b/classes/editor_ajax.php @@ -65,7 +65,8 @@ public function getLatestLibraryVersions() { return $DB->get_records_sql(" SELECT hl4.id, hl4.machine_name, hl4.title, hl4.major_version, - hl4.minor_version, hl4.patch_version, hl4.has_icon, hl4.restricted + hl4.minor_version, hl4.patch_version, hl4.has_icon, hl4.restricted, + 0 AS patch_version_in_folder_name FROM {hvp_libraries} hl4 JOIN ({$maxminorversionsql}) hl3 ON hl4.machine_name = hl3.machine_name diff --git a/classes/file_storage.php b/classes/file_storage.php index 9fa73ef4..4be1a132 100644 --- a/classes/file_storage.php +++ b/classes/file_storage.php @@ -544,7 +544,7 @@ private static function readFileTree($source, $options, $archive = null, $relati if (empty($archive) && $exportzip) { $archive = new \ZipArchive(); $path = tempnam(get_request_storage_directory(),'libdir'); - $archive->open($path, \ZipArchive::CREATE || \ZipArchive::OVERWRITE); + $archive->open($path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); // Set recursion flag. $top = true; } else { diff --git a/classes/framework.php b/classes/framework.php index 2b7c92eb..e218499c 100644 --- a/classes/framework.php +++ b/classes/framework.php @@ -1521,23 +1521,27 @@ public function loadLibrary($machinename, $majorversion, $minorversion) { 'minor_version' => $minorversion )); - $librarydata = array( - 'libraryId' => $library->id, - 'machineName' => $library->machine_name, - 'title' => $library->title, - 'majorVersion' => $library->major_version, - 'minorVersion' => $library->minor_version, - 'patchVersion' => $library->patch_version, - 'embedTypes' => $library->embed_types, - 'preloadedJs' => $library->preloaded_js, - 'preloadedCss' => $library->preloaded_css, - 'dropLibraryCss' => $library->drop_library_css, - 'fullscreen' => $library->fullscreen, - 'runnable' => $library->runnable, - 'semantics' => $library->semantics, - 'restricted' => $library->restricted, - 'hasIcon' => $library->has_icon - ); + if ($library) { + $librarydata = array( + 'libraryId' => $library->id, + 'machineName' => $library->machine_name, + 'title' => $library->title, + 'majorVersion' => $library->major_version, + 'minorVersion' => $library->minor_version, + 'patchVersion' => $library->patch_version, + 'embedTypes' => $library->embed_types, + 'preloadedJs' => $library->preloaded_js, + 'preloadedCss' => $library->preloaded_css, + 'dropLibraryCss' => $library->drop_library_css, + 'fullscreen' => $library->fullscreen, + 'runnable' => $library->runnable, + 'semantics' => $library->semantics, + 'restricted' => $library->restricted, + 'hasIcon' => $library->has_icon + ); + } else { + return []; + } $dependencies = $DB->get_records_sql( 'SELECT hl.id, hl.machine_name, hl.major_version, hl.minor_version, hll.dependency_type