From 2027feaaa19361b87559f8abb1d3f510da1a6bd3 Mon Sep 17 00:00:00 2001
From: William Hearn <sylus1984@gmail.com>
Date: Tue, 23 Aug 2016 23:28:45 -0400
Subject: [PATCH] Issue #2788633 by sylus: panelizer_update_7120: Not null
 violation: 7 ERROR: null value in column "pid" violates not-null

---
 panelizer.install | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/panelizer.install b/panelizer.install
index 19f8aef..5ae8b1c 100644
--- a/panelizer.install
+++ b/panelizer.install
@@ -1079,7 +1079,7 @@ function panelizer_update_7120(&$sandbox) {
               $new_pane = clone $pane;
 
               // Erase the pid so a new record can be saved.
-              $new_pane->pid = NULL;
+              unset($new_pane->pid);
 
               // Tie the pane to this display.
               $new_pane->did = $display->did;
@@ -1195,12 +1195,17 @@ function panelizer_update_7300(&$sandbox) {
     }
 
     // Delete panelizer records that have one of the default names.
-    $deleted = db_delete('panelizer_entity')
-      ->condition('name', $default_names, 'IN')
-      ->condition('entity_type', $entity_type)
-      ->execute();
-    if ($deleted > 0) {
-      watchdog('panelizer', '@count default panelizer records were removed for entity type: @entity_type.', array('@count' => $deleted, '@entity_type' => $entity_type));
+    if (!empty($default_names)) {
+      $deleted = db_delete('panelizer_entity')
+        ->condition('name', $default_names, 'IN')
+        ->condition('entity_type', $entity_type)
+        ->execute();
+      if ($deleted > 0) {
+        watchdog('panelizer', '@count default panelizer records were removed for entity type: @entity_type.', array('@count' => $deleted, '@entity_type' => $entity_type));
+      }
+      else {
+        watchdog('panelizer', 'No default panelizer records were found for entity type: @entity_type.', array('@entity_type' => $entity_type));
+      }
     }
     else {
       watchdog('panelizer', 'No default panelizer records were found for entity type: @entity_type.', array('@entity_type' => $entity_type));
-- 
2.5.4 (Apple Git-61)

