Commit 47e9bc2 1 parent 5c8553e commit 47e9bc2 Copy full SHA for 47e9bc2
File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,12 @@ private static function get_builtin_snippet_paths() {
247
247
*/
248
248
public static function add_builtin_snippets () {
249
249
global $ DB ;
250
+
251
+ // Get builtin snippets that are present on disk.
250
252
$ paths = self ::get_builtin_snippet_paths ();
251
253
252
254
// Get builtin snippets which are known in the database.
253
- $ present = $ DB ->get_records (
255
+ $ snippets = $ DB ->get_records (
254
256
'theme_boost_union_snippets ' ,
255
257
['source ' => 'theme_boost_union ' ],
256
258
'sortorder DESC ' ,
@@ -260,10 +262,15 @@ public static function add_builtin_snippets() {
260
262
);
261
263
262
264
// Get the highest sortorder present.
263
- $ sortorder = empty ($ present ) ? 0 : intval (reset ($ present )->sortorder ) + 1 ;
265
+ $ sortorder = empty ($ snippets ) ? 0 : intval (reset ($ snippets )->sortorder ) + 1 ;
266
+
267
+ // Prepare an array with all the present builtin snippet paths.
268
+ $ presentpaths = array_map (function ($ snippet ) {
269
+ return $ snippet ->path ;
270
+ }, $ snippets );
264
271
265
272
foreach ($ paths as $ path ) {
266
- if (!array_key_exists ($ path , $ present )) {
273
+ if (!array_key_exists ($ path , $ presentpaths )) {
267
274
$ DB ->insert_record (
268
275
'theme_boost_union_snippets ' ,
269
276
[
You can’t perform that action at this time.
0 commit comments