Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
You can see the lines in the code below where the error occurs. The 3 lines with + signs is the code added in as a workaround. Doing print_r($minis); you can see that the very first array item is empty (NULL) and I suspect this happened when I deleted a panel but I am unsure.
Array
(
[] =>
[news_menu] => stdClass Object
(
[pid] => 16
[name] => news_menu
<?php
67 function panels_mini_block_info() {
68 // Safety: go away if CTools is not at an appropriate version.
69 if (!defined('PANELS_REQUIRED_CTOOLS_API') || !module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
70 return array();
71 }
72
73 $blocks = array();
74
75 $minis = panels_mini_load_all();
76 foreach ($minis as $panel_mini) {
77 if (empty($mini->disabled) && empty($mini->requiredcontext)) {
+ if (!isset($panel_mini->name)) {
+ continue;
+ }
78 $blocks[$panel_mini->name] = array(
79 'info' => t('Mini panel: "@title"', array('@title' => $panel_mini->admin_title)),
80 'cache' => DRUPAL_NO_CACHE,
81 );
82 }
83 }
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedHm. Yeah the load_all() shouldn't be able to bring up an empty panel.
There does seem to be a mismatch there betwen $panel_mini and $mini.
Comment #2
Reg CreditAttribution: Reg commentedI'm not sure what you mean by mismatch. Do you mean line 77 which should probably be $panel_mini?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedThe code is looping over $minis as $panel_mini but is testing $mini-> -- that is a potential problem in this code.
Comment #4
Reg CreditAttribution: Reg commentedIt's a bug but unrelated in the sense that if it's NULL you are still trying to reference a property of a non-object although using empty(...) as it does might allow you to get away with it since empty is pretty forgiving. I don't know the specifics regarding this usage. Better would probably be something like:
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedThe mismatch in variables is fixed in #1212492: Incorrect use of $mini in panels_mini_block_info()
The problem here is that load_all() should not be able to bring up an empty. It simply shouldn't. So if there's a bug, it's not in this part of the code. This is simply where the bug is revealed.
Figuring out why your load_all has an invalid object in it is the key.
Comment #6
Letharion CreditAttribution: Letharion commentedComment #7
SunRhythms CreditAttribution: SunRhythms commentedThis patch worked here... *duplicate entry yet later for those that are still looking for resources*
http://drupal.org/node/1480366
Comment #7.0
SunRhythms CreditAttribution: SunRhythms commented.