Skip to content

Commit 781a3bb

Browse files
committed
fix adding builtin snippets
1 parent ffc7337 commit 781a3bb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

classes/snippets.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ private static function cleanup_header_comment($str) {
196196
*
197197
* @param string $file Absolute path to the file.
198198
*
199+
* @copyright forked from https://developer.wordpress.org/reference/functions/get_file_data/
199200
* @return string[] Array of file header values keyed by header name.
200201
*/
201202
public static function get_snippet_meta_from_file($file) {
@@ -248,6 +249,7 @@ public static function add_builtin_snippets() {
248249
global $DB;
249250
$paths = self::get_builtin_snippet_paths();
250251

252+
// Get builtin snippets which are known in the database.
251253
$present = $DB->get_records(
252254
'theme_boost_union_snippets',
253255
['source' => 'theme_boost_union'],
@@ -257,7 +259,8 @@ public static function add_builtin_snippets() {
257259
0,
258260
);
259261

260-
$sortorder = empty($present) ? 0 : $present[0]->sortorder + 1;
262+
// Get the highest sortorder present.
263+
$sortorder = empty($present) ? 0 : intval(reset($present)->sortorder) + 1;
261264

262265
foreach ($paths as $path) {
263266
if (!array_key_exists($path, $present)) {
@@ -269,6 +272,7 @@ public static function add_builtin_snippets() {
269272
'sortorder' => $sortorder,
270273
]
271274
);
275+
// We add each record with incrementing sortorder.
272276
$sortorder += 1;
273277
}
274278
}

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'theme_boost_union';
28-
$plugin->version = 2024060109;
28+
$plugin->version = 2024060110;
2929
$plugin->release = 'v4.4-r1';
3030
$plugin->requires = 2024042200;
3131
$plugin->supported = [404, 404];

0 commit comments

Comments
 (0)