]> git.mjollnir.org Git - moodle.git/commitdiff
fixing 2 warnings
authortoyomoyo <toyomoyo>
Thu, 20 Sep 2007 05:59:26 +0000 (05:59 +0000)
committertoyomoyo <toyomoyo>
Thu, 20 Sep 2007 05:59:26 +0000 (05:59 +0000)
tag/lib.php

index ba798bb2e5701faa5339e274710458978207e982..9c8ceea0743154e71d8ef37b1a90c85be1d3d1a9 100644 (file)
@@ -893,28 +893,29 @@ function tag_instance_table_cleanup() {
         {$CFG->prefix}tag_instance
     ";
 
-    $items_types = get_records_sql($query);
-
-    // for each itemtype, remove tag_instances that are orphans
-    // That is: For a given tag_instance, if in the itemtype table there's no entry with id equal to itemid,
-    //          then this tag_instance is an orphan and it will be removed.
-    foreach ($items_types as $type) {
-
-        $query = "
-            {$CFG->prefix}tag_instance.id
-        IN
-            ( SELECT sq1.id
-              FROM
+    if ($items_types = get_records_sql($query)) {
+
+        // for each itemtype, remove tag_instances that are orphans
+        // That is: For a given tag_instance, if in the itemtype table there's no entry with id equal to itemid,
+        //          then this tag_instance is an orphan and it will be removed.
+        foreach ($items_types as $type) {
+
+            $query = "
+                {$CFG->prefix}tag_instance.id
+            IN
+                ( SELECT sq1.id
+                FROM
                     (SELECT sq2.*
                      FROM {$CFG->prefix}tag_instance sq2
                      LEFT JOIN {$CFG->prefix}{$type->itemtype} item
                      ON sq2.itemid = item.id
                      WHERE item.id IS NULL
                      AND sq2.itemtype = '{$type->itemtype}')
-              sq1
-            ) ";
+                sq1
+                ) ";
 
-        delete_records_select('tag_instance', $query);
+            delete_records_select('tag_instance', $query);
+        }
     }
 
     // remove tag_instances that are orphans because tagid does not correspond to an
@@ -1130,10 +1131,11 @@ function tag_cron(){
 
     tag_instance_table_cleanup();
 
-    $tags = get_all_tags('*');
+    if ($tags = get_all_tags('*')) {
 
-    foreach ($tags as $tag){
-        cache_correlated_tags($tag->id);
+        foreach ($tags as $tag){
+            cache_correlated_tags($tag->id);
+        }
     }
 
 }