MDL-22503 blocks upgrade - avoid problems with orphaned sticky blocks
authorEloy Lafuente <stronk7@moodle.org>
Tue, 22 Jun 2010 09:50:30 +0000 (09:50 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Tue, 22 Jun 2010 09:50:30 +0000 (09:50 +0000)
lib/db/upgrade.php

index 5e3d972..c2be5f3 100644 (file)
@@ -1882,6 +1882,10 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         );
         $stickyblocks = $DB->get_recordset('block_pinned_old');
         foreach ($stickyblocks as $stickyblock) {
+            // Only if the block exists (avoid orphaned sticky blocks)
+            if (!isset($blocks[$stickyblock->blockid]) || empty($blocks[$stickyblock->blockid]->name)) {
+                continue;
+            }
             $newblock = new object();
             $newblock->blockname = $blocks[$stickyblock->blockid]->name;
             $newblock->contextid = $syscontext->id;