Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors after upgrading: Kalacustomize not checking whether variables are set #168

Closed
solipsist opened this issue Feb 24, 2015 · 5 comments
Closed
Assignees
Milestone

Comments

@solipsist
Copy link

( ! ) Notice: Undefined index: devices in /var/www/abc/sites/all/themes/kalatheme/styles/kalacustomize/kalacustomize.inc on line 89

  1. Installed latest version of Kalatheme.
  2. Upgraded Panopoly to latest version.

Now when I try to change the style of a pane styled with the Kalacustomize plugin, I get the error message above. Been trying to locate the error by tracking the changes but it's slow going.

Changing default theme to Bartik and changing pane style to Custom Style results in other errors:
! ) Notice: Undefined property: stdClass::$type in /profiles/panopoly/modules/contrib/fieldable_panels_panes/fieldable_panels_panes.module on line 671

Site was built about a year ago using the then most recent versions of Kalatheme and Panopoly. Been working without much hassle since, until now.

Packages

Chaos tool suite                     Chaos tools (ctools)                                                       Module  Enabled        7.x-1.6
Panels                               Panels (panels)                                                            Module  Enabled        7.x-3.5
Other                                Kalatheme (kalatheme)                                                      Theme   Enabled        7.x-3.0
Panopoly                             Panopoly Admin (panopoly_admin)                                            Module  Enabled        7.x-1.17
Panopoly                             Panopoly Core (panopoly_core)                                              Module  Enabled        7.x-1.17
Panopoly                             Panopoly Images (panopoly_images)                                          Module  Enabled        7.x-1.17
Panopoly                             Panopoly Magic (panopoly_magic)                                            Module  Enabled        7.x-1.17
Panopoly                             Panopoly Pages (panopoly_pages)                                            Module  Enabled        7.x-1.17
Panopoly                             Panopoly Search (panopoly_search)                                          Module  Disabled       7.x-1.17
Panopoly                             Panopoly Theme (panopoly_theme)                                            Module  Enabled        7.x-1.17
Panopoly                             Panopoly Users (panopoly_users)                                            Module  Enabled        7.x-1.17
Panopoly                             Panopoly Widgets (panopoly_widgets)                                        Module  Enabled        7.x-1.17
Panopoly                             Panopoly WYSIWYG (panopoly_wysiwyg)                                        Module  Disabled       7.x-1.17

Very grateful for any help you can give.

@solipsist
Copy link
Author

I've fixed the issue and it seems to be due to Kalacustomize not checking whether variables were set. This seems to happen when you do what I did, upgrade from a previous version and using old pane style settings.

The attached patch affects Kalatheme and Panopoly Magic. I've submitted the patch to the Panopoly issue queue as well.

From ec6d38a80ee8d8eb0271273c89f7dfd1934258f0 Mon Sep 17 00:00:00 2001
From: Jakob Persson <jakob.persson@leancept.com>
Date: Wed, 25 Feb 2015 17:12:35 +0100
Subject: [PATCH] Fixing Kalacustomize plugin and Panopoly Magic causing
 problems when upgrading from previous version of Kalatheme

---
 .../panopoly/panopoly_magic/panopoly_magic.module        |  2 +-
 .../kalatheme/styles/kalacustomize/kalacustomize.inc     | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/profiles/panopoly/modules/panopoly/panopoly_magic/panopoly_magic.module b/profiles/panopoly/modules/panopoly/panopoly_magic/panopoly_magic.module
index 103555e..c34ab96 100644
--- a/profiles/panopoly/modules/panopoly/panopoly_magic/panopoly_magic.module
+++ b/profiles/panopoly/modules/panopoly/panopoly_magic/panopoly_magic.module
@@ -416,7 +416,7 @@ function panopoly_magic_form_alter(&$form, &$form_state, $form_id) {

       // Move all elements which aren't fieldsets or the submit buttons into the general settings fieldset.
       foreach ($children as $child) {
-        if ((!empty($form[$child]['#type']) || !empty($form[$child]['#tree'])) && $form[$child]['#type'] != 'fieldset' && $child != 'buttons' && $child != 'submit') {
+        if (isset($form[$child]['#type']) && (!empty($form[$child]['#type']) || !empty($form[$child]['#tree'])) && $form[$child]['#type'] != 'fieldset' && $child != 'buttons' && $child != 'submit') {
           $form['general_settings'][$child] = $form[$child];
           unset($form[$child]);
         }
diff --git a/sites/all/themes/kalatheme/styles/kalacustomize/kalacustomize.inc b/sites/all/themes/kalatheme/styles/kalacustomize/kalacustomize.inc
index 256e6bd..febf57d 100644
--- a/sites/all/themes/kalatheme/styles/kalacustomize/kalacustomize.inc
+++ b/sites/all/themes/kalatheme/styles/kalacustomize/kalacustomize.inc
@@ -23,8 +23,14 @@ function theme_kalatheme_kalacustomize_render_region($vars) {
   $settings = $vars['settings'];

   $settings['attributes'] = '';
-  $settings['attributes'] .= _kalatheme_get_styles($settings['devices']);
-  $settings['attributes'] .= _kalatheme_get_styles($settings['pane_style']);
+  
+  if (isset($settings['devices'])) {
+    $settings['attributes'] .= _kalatheme_get_styles($settings['devices']);
+  }
+  
+  if (isset($settings['pane_style'])) {
+    $settings['attributes'] .= _kalatheme_get_styles($settings['pane_style']);
+  }

     // Theme.
   if (!empty($settings['theme']) && $settings['theme']) {
@@ -70,6 +76,8 @@ function theme_kalatheme_kalacustomize_render_pane($vars) {
  */
 function kalatheme_kalacustomize_pane_settings_form($style_settings) {

+  $form = array();
+
   $settings_exposed = 0;
   $default_theme = variable_get('theme_default', NULL);

@@ -86,13 +94,13 @@ function kalatheme_kalacustomize_pane_settings_form($style_settings) {
       '#type' => 'checkboxes',
       '#options' => $mobile_options,
       '#title' => t('Hide this pane on the following devices.'),
-      '#default_value' => $style_settings['devices'],
+      '#default_value' => isset($style_settings['devices']) ? $style_settings['devices'] : array(),
     );
     $settings_exposed++;
   }

   if (theme_get_setting('pane_styles_toggle', $default_theme)) {
-    $pane_style_default_value = isset($style_settings['pane_style']) ? $style_settings['pane_style'] : '';
+    $pane_style_default_value = isset($style_settings['pane_style']) ? $style_settings['pane_style'] : array();
     $pane_options = array(
       'pull-left' => 'Float Left',
       'pull-right' => 'Float Right',
-- 
1.9.3 (Apple Git-50)

@andrewmallis andrewmallis added this to the 7.x-3.2 milestone Aug 4, 2015
@andrewmallis andrewmallis changed the title Errors after upgrading: ( ! ) Notice: Undefined index: devices in ...kalatheme/styles/kalacustomize/kalacustomize.inc Errors after upgrading: Kalacustomize not checking whether variables are set Aug 4, 2015
@soniktrooth
Copy link
Contributor

@solipsist Did you submit this patch to the panopoly issue queue? If so please link us to it so we can move forward on this issue

@solipsist
Copy link
Author

Here: https://www.drupal.org/node/2437979

I haven't tested dsnopek's patch however.

@soniktrooth
Copy link
Contributor

@solipsist I can't replicate this issue.

After doing a bit of digging I can see that some code has already been added that is similar to what you are proposing.

Line 26 & 27 of kalacustomize.inc currently looks like this:

  $settings['attributes'] .= isset($settings['devices']) ? _kalatheme_get_styles($settings['devices']) : '';
  $settings['attributes'] .= isset($settings['pane_style']) ? _kalatheme_get_styles($settings['pane_style']) : '';

This is jus an inline version of what you were proposing for that part of the code. I think this may have been enough to make sure empty attributes aren't being passed through and therefore prevent the rest of the errors. Are you able to confirm this with Kalatheme 7.x-3.1?

@soniktrooth
Copy link
Contributor

@solipsist I'm going to close this issue as I don't' believe it's a problem as of 3.1. Feel free to repoen if you find this isn't the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants