Download & Extend

Fatal error:__clone method called on non-object

Project:Panels
Version:6.x-3.9
Component:Panel pages
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (cannot reproduce)

Issue Summary

Since i'm new to this, i'm not sure if this is "user" error, or a bug. When I go to pages, then "user view" , then -operations/task handlers... I am getting this error on a blank screen.

Fatal error: __clone method called on non-object in /home2/xxxxxx/public_html/includes/common.inc on line 1685

Last night i went it (and i went through without getting the error), but I didn't complete a page before getting out of it... Now i can't manage to get in without the error. I uninstalled, cleared cache, etc. reinstalled... but it didn't change anything.

Comments

#1

I seem to be having this issue too -- everything was working fine as of a few days ago, and then I went today to the Task Handlers page for node/%node, I get that error.

What I'm seeing so far is that panels_panel_context_admin_summary() in panel_context.inc is calling drupal_clone() on a NULL value. That NULL is coming from $handler->conf['display']. I'll post more if I figure anything else out.

#2

My guess now is that my problem is being caused by a task handler that I added to the page that I don't seem to have finished. The task handler has no display value in its $conf settings, which ultimately ends up in drupal_clone() trying to clone a NULL value.

It's hard to say if that happened because I just started configuring a task handler and never finished configuring it all the wayl, or if it's the result of a small utility module that I had added to my project that is defining an additional selection criteria that I needed for my specific project. Either way, I'd certainly ideally prefer the system catch things like that -- even if it's Panels saying, "hey, I don't know how but this task handler is busted, so go figure out what's wrong or delete it."

Anyway, the fix for me was a simple:

if ($handler->conf['display'] == NULL)
return;

... added toward the top of panels_panel_context_admin_summary().

Once that check is in, the defective handler (which somehow has no conf->display set) can be deleted, and everything is good to go.

(As a side note: since drupal_clone() curiously does not validate its parameters and assumes everything is alright, I'd think it to be a good idea to do that basic validation to avoid meaningless error messages like "clone method called on non-object" (and replace that error message with a "invalid task handler"-type message that Panels could show.)

#3

Yeah, I thought it was probably the same thing... never completed the task handler before closing it.

Thanks for the fix! I am not much of a coder, could you tell me what file that goes in? I haven't been able to find that string anywhere.

#4

Sorry, you probably didn't find the string because it's not literally panels_panel_context_admin_summary(), but the full function panels_panel_context_admin_summary($handler, $task, $subtask_id). The function should be in sites/all/modules/panels/plugins/task_handlers/panel_context.inc around line 220.

#5

Aaahhh.. okay I appreciate it. Worked for me as well.

Thanks!

#6

So I'm glad there's a temporary fix here, but I can't recommend PeteS's solution for any sort of long term. The validation that prevents this needs to happen earlier in the stack, putting it directly into the task handler plugin as a workaround for some not-so-hot logic in the core is unsustainable.

Re: drupal_clone(), it's doubtful such a change would ever go in, and imo shouldn't. Two basic reasons: drupal's general "don't babysit broken code" rule, and also because drupal_clone() works quite well right now as just a shorthand function for people who don't want to do the somewhat awkward version comparison in their own code.

#7

Definitely agree that it should be considered a temporary fix, and that the issue should be handled earlier in the process.

For what it's worth (probably not much), I grant that the "no babysitting" rule is an accepted principle. But... I have a hard time as a programmer buying into that. A complex system shouldn't allow itself to get into an unknown state, and passing a NULL value to a central core function is one of those unknown states. Will PHP throw an error? Will it let it go through and return a reference to a NULL? Maybe there are different results in PHP 4 versus PHP 5? Who knows? Now you potentially have several people all posting for support about the same problem, and no one can know what it is until a coder does a backtrace.

Maybe it costs an extra fraction of a millisecond and 2-3 lines of code, but it sure would cut down on the frustration of not knowing where an error originates from. This issue and the countless other ones like it (where Drupal is accepting a NULL, or a string where it expects an array, etc.) would take a fraction of the time to fix, and Drupal users would be a lot more at ease that they aren't going to get scary PHP-error white screens.

#8

On the same side as PeteS, some of us are on deadlines to complete projects, therefore, we can't just sit on our ass waiting for some update (and not knowing when one may come- I've heard April).

So to me, this is completely acceptable short term, to get things done. We can worry about updating it later, as we are competent enough to maintain codebases.

However, he is correct that this simple and obvious bug shouldn't exist in the first place.

#9

Guys, you do realize that I read this stuff, right?

Of course this code has bugs in it. Big ones.

If this 'simple and obvious bug' should never have happened, please go and write your own software. Otherwise, please accept that you're using something that's very early and I think it's pretty well stated up front isn't entirely stable, and if that makes you angry, please stuff it. I don't care, and this issue queue is not the place for it.

#10

Merlin, I don't think you need take offence -- as I read it the other guys were aware it's alpha code, happy to go with short term workarounds and were digressing into discussion of longer term software engineering principles (i.e. whether "no babysitting" is a viable usability/performance trade-off). The ref to "simple and obvious bug" isn't critical of the presence of oversights, but is just mentioning that firewalls elsewhere could reduce their impact.

Funny thing -- when people start getting passionate discussing a piece of software and forget courtesies, it's often because they like the software a lot and want to see it even better!

#11

Status:active» fixed

Fix for this committed.

#12

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#13

No, we were just pretty stressed to hit a hard deadline and wondered what if any workaround there was. Heh, you did not want to be in this room at the time of that posting. :D Panels saves us a lot of content-design time, we just want to help get it polished!

#14

Does anyone have a thought on where this same temp fix would need to be applied to 5.x? I'm getting this error ...

Fatal error: __clone method called on non-object in /home/public_html/includes/common.inc on line 1388

... but there is no panel_context.inc or panels_panel_context_admin_summary() function. There are 20 panels files in 5.x which reference drupal_clone(). I narrowed down to panels_mini.module, panels_page.module, panels.module, and display_edit.inc as files which use the drupal_clone() function, but didn't have any handling in front of them in the case where a value might be empty.

In front of the four situations where drupal_clone is called, I added a line similar to this (obviously variable/array is changed in each unique situation):

if(empty($panel_page)) { return; }

It didn't seem to work. This is a situation where I am creating a view to be added as a separate group page under another tab. I was able to add a first page summarizing group posts, but the second page used to present a group event calendar causes the problem.

#15

gh0st25: Ahh, deadlines. Thanks for the explanation, all good.

As for the 5.x issue, it is definitely something different, as we're talking about code that does not exist in the 5.x version. You should file a separate issue.

#16

Status:closed (fixed)» active

I'm getting this with Panels 3.2:
( ! ) Fatal error: __clone method called on non-object in [path]/includes/common.inc on line 1956

To see this happening, have the taxonomy/term handler enabled and try to load a taxonomy/term page that doesn't exist, e.g.:
http://example.com/taxonomy/term/9999999

For me this results in the following:

  • Time - Memory - Function
  • 0.0006 - 64944 - {main}( ) - ../index.php:0
  • 0.7810 - 40122164 - menu_execute_active_handler( $path = ??? ) - ../index.php:18
  • 0.7848 - 40187580 - call_user_func_array ( 'page_manager_term_view', array (0 => '9999999') ) - ../menu.inc:348
  • 0.7848 - 40187684 - page_manager_term_view( $terms = '9999999', $depth = ???, $op = ??? ) - ../menu.inc:0
  • 0.8297 - 40857064 - ctools_context_handler_render( $task = array ('task type' => 'page', 'title' => 'Taxonomy term template', 'admin title' => 'Taxonomy term template', 'admin description' => 'When enabled, this overrides the default Drupal behavior for displaying taxonomy terms at taxonomy/term/%term. If you add variants, you may use selection criteria such as vocabulary or user access to provide different displays of the taxonomy term and associated nodes. If no variant is selected, the default Drupal taxonomy term display will be used. This page only affects items actually displayed ad taxonomy/term/%term. Some taxonomy terms, such as forums, have their displays moved elsewhere. Also ...', 'admin path' => 'taxonomy/term/%term', 'admin summary' => 'page_manager_term_view_admin_summary', 'hook menu' => 'page_manager_term_view_menu', 'hook menu alter' => 'page_manager_term_view_menu_alter', 'admin settings' => 'page_manager_term_view_admin_settings', 'save subtask callback' => 'page_manager_term_view_save', 'task admin' => 'page_manager_term_view_task_admin', 'handler type' => 'context', 'get arguments' => 'page_manager_term_view_get_arguments', 'get context placeholders' => 'page_manager_term_view_get_contexts', 'operations' => array ('settings' => array (...)), 'disabled' => FALSE, 'enable callback' => 'page_manager_term_view_enable', 'module' => 'page_manager', 'name' => 'term_view', 'path' => 'sites/all/modules/platform/ctools/page_manager/plugins/tasks', 'file' => 'term_view.inc', 'plugin module' => 'page_manager', 'plugin type' => 'tasks'), $subtask = '', $contexts = array ('argument_terms_1' => class ctools_context { public $type = array (...); public $data = FALSE; public $title = NULL; public $page_title = ''; public $identifier = 'Term(s) being viewed'; public $argument = '9999999'; public $keyword = 'term'; public $original_argument = '9999999'; public $restrictions = array (...); public $empty = FALSE; public $plugin = 'terms'; public $operator = 'and'; public $tids = array (...); public $id = 'argument_terms_1' }), $args = array (0 => '9999999', 1 => 0, 2 => 'page'), $page = ??? ) - ../term_view.inc:140
  • 0.9182 - 42958104 - panels_panel_context_render( $handler = class stdClass { public $did = '12'; public $name = 'term_view_panel_context_2'; public $task = 'term_view'; public $subtask = ''; public $handler = 'panel_context'; public $weight = '-3'; public $conf = array ('autogenerate_title' => TRUE, 'title' => 'Panel', 'no_blocks' => 0, 'css_id' => 'term-page', 'css' => '', 'contexts' => array (...), 'relationships' => array (...), 'access' => array (...), 'did' => '27', 'display' => class panels_display { ... }); public $table = 'page_manager_handlers'; public $type = 'Normal'; public $export_type = 1 }, $base_contexts = array ('argument_terms_1' => class ctools_context { public $type = array (...); public $data = FALSE; public $title = NULL; public $page_title = ''; public $identifier = 'Term(s) being viewed'; public $argument = '9999999'; public $keyword = 'term'; public $original_argument = '9999999'; public $restrictions = array (...); public $empty = FALSE; public $plugin = 'terms'; public $operator = 'and'; public $tids = array (...); public $id = 'argument_terms_1' }), $args = array (0 => '9999999', 1 => 0, 2 => 'page'), $test = ??? ) - ../context-task-handler.inc:46
  • 0.9220 - 42965556 - panels_render_display( $display = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' } ) - ../panel_context.inc:276
  • 0.9249 - 43128520 - _panels_render_display( $display = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' } ) - ../panels.module:821
  • 1.0426 - 43370896 - panels_render_layout( $layout = array ('title' => 'Two column', 'icon' => 'twocol.png', 'theme' => 'panels_twocol', 'css' => 'twocol.css', 'panels' => array ('left' => 'Left side', 'right' => 'Right side'), 'module' => 'panels', 'name' => 'twocol', 'path' => 'sites/all/modules/platform/panels3/plugins/layouts/twocol', 'file' => 'twocol.inc', 'plugin module' => 'panels', 'plugin type' => 'layouts'), $content = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' }, $css_id = 'term-page', $settings = array (), $display = ??? ) - ../display-render.inc:36
  • 1.0427 - 43371784 - panels_render_panes( $display = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' } ) - ../display-render.inc:84
  • 1.0940 - 43645732 - panels_render_pane_content( $display = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' }, $pane = class stdClass { public $pid = '315'; public $did = '27'; public $panel = 'left'; public $type = 'term_list'; public $subtype = 'term_list'; public $shown = TRUE; public $access = array (); public $configuration = array ('title' => NULL, 'type' => 'child', 'list_type' => 'ul', 'context' => 'argument_terms_1', 'override_title' => 0, 'override_title_text' => ''); public $cache = array ('method' => 'signal_cache_panel', 'settings' => array (...)); public $style = array (); public $css = array (); public $extras = array (); public $position = '1' }, $keywords = array () ) - ../display-render.inc:157
  • 1.0940 - 43646080 - panels_get_pane_content( $display = class panels_display { public $args = array (0 => '9999999', 1 => 0, 2 => 'page'); public $content = array (291 => class stdClass { ... }, 315 => class stdClass { ... }, 312 => class stdClass { ... }, 103 => class stdClass { ... }, 104 => class stdClass { ... }); public $panels = array ('left' => array (...), 'right' => array (...)); public $incoming_content = NULL; public $css_id = 'term-page'; public $context = array ('argument_terms_1' => class ctools_context { ... }); public $did = '27'; public $layout = 'twocol'; public $layout_settings = array (); public $panel_settings = array (); public $cache = array (); public $title = ''; public $hide_title = '1'; public $title_pane = '0' }, $pane = class stdClass { public $pid = '315'; public $did = '27'; public $panel = 'left'; public $type = 'term_list'; public $subtype = 'term_list'; public $shown = TRUE; public $access = array (); public $configuration = array ('title' => NULL, 'type' => 'child', 'list_type' => 'ul', 'context' => 'argument_terms_1', 'override_title' => 0, 'override_title_text' => ''); public $cache = array ('method' => 'signal_cache_panel', 'settings' => array (...)); public $style = array (); public $css = array (); public $extras = array (); public $position = '1' }, $keywords = array (), $args = array (0 => '9999999', 1 => 0, 2 => 'page'), $context = array ('argument_terms_1' => class ctools_context { public $type = array (...); public $data = FALSE; public $title = NULL; public $page_title = ''; public $identifier = 'Term(s) being viewed'; public $argument = '9999999'; public $keyword = 'term'; public $original_argument = '9999999'; public $restrictions = array (...); public $empty = FALSE; public $plugin = 'terms'; public $operator = 'and'; public $tids = array (...); public $id = 'argument_terms_1' }), $incoming_content = NULL ) - ../display-render.inc:211
  • 1.0962 - 43655312 - ctools_content_render( $type = 'term_list', $subtype = 'term_list', $conf = array ('title' => NULL, 'type' => 'child', 'list_type' => 'ul', 'context' => 'argument_terms_1', 'override_title' => 0, 'override_title_text' => ''), $keywords = array (), $args = array (0 => '9999999', 1 => 0, 2 => 'page'), $context = array ('argument_terms_1' => class ctools_context { public $type = array (...); public $data = FALSE; public $title = NULL; public $page_title = ''; public $identifier = 'Term(s) being viewed'; public $argument = '9999999'; public $keyword = 'term'; public $original_argument = '9999999'; public $restrictions = array (...); public $empty = FALSE; public $plugin = 'terms'; public $operator = 'and'; public $tids = array (...); public $id = 'argument_terms_1' }), $incoming_content = NULL ) - ../plugins.inc:64
  • 1.0969 - 43656460 - ctools_term_list_content_type_render( $subtype = 'term_list', $conf = array ('title' => NULL, 'type' => 'child', 'list_type' => 'ul', 'context' => 'argument_terms_1', 'override_title' => 0, 'override_title_text' => ''), $panel_args = array (0 => '9999999', 1 => 0, 2 => 'page'), $context = class ctools_context { public $type = array (0 => 'terms', 1 => 'term'); public $data = FALSE; public $title = NULL; public $page_title = ''; public $identifier = 'Term(s) being viewed'; public $argument = '9999999'; public $keyword = 'term'; public $original_argument = '9999999'; public $restrictions = array (); public $empty = FALSE; public $plugin = 'terms'; public $operator = 'and'; public $tids = array (0 => 9999999); public $id = 'argument_terms_1' }, NULL ) - ../content.inc:264
  • 1.0969 - 43657628 - drupal_clone( $object = FALSE )

#17

Version:6.x-3.0-alpha2» 6.x-3.x-dev

Fatal error: __clone method called on non-object in /Users/alfrednutile/Sites/demorvtc/includes/common.inc on line 1736

I see why this came up for me on this latest version. In my case it was a user error but it would be great if somehow this could be prevented via a check of some sort.
I created a mini panel with context Node/User

Then I could pull in more info to that mini panel.

Later I removed the Context cause I had trouble getting that mini panel to show in the panel selection area. This is a user error but....

So the minipanel was working (ie showing up next to the node I was testing it with) but any pane in that minipanel that needed this context had the message in its config area "will not display due to misson context" which makes sense.

So as a typical end user I went right back and added the context I removed.

Then the refresh of the node stopped at that error. And when I went back to the minipanel I got an error as well (not a show stopper just the warning area in drupal sorry I did not copy paste that error here)

So at this point the minipanel no longer has the "will not display due to misson context" message but the panel now just stops when I look at that Page Node it was suppose to manage.

The way I got it to all work again so far was to remove the minipanel from that panels settings save and refresh and the node worked. Added back the same minipanel and it all worked. I did try to clear drupal cache before this.

#18

just wanted to tag this comment to bring attention to the comment above it I forgot to tag.

#19

I've been trying to dup what you found in #17 but I can't seem to make that error happen. Adding and removing the context seems to work okay.

#20

Status:active» closed (cannot reproduce)

Shoudl've marked this when I said I could not reproduce it.

#21

Version:6.x-3.x-dev» 6.x-3.9
Category:support request» bug report
Status:closed (cannot reproduce)» active

I get this kind of error, if I use mini panels inside of node view panels with a required node context:

Fatal error: __clone method called on non-object in /[...]/includes/common.inc on line 1733

After configuring the required node context, error appears during page view.

After deleting the context, that page view works fine / but obviously without content / as I planed to use node content on the minipanels ...

regards
ChrisZZ

#22

I did some further testing.

It also happens with user required context.

It does not happen with context that is not required.

I was checking, whether the context in the mother panel is actually there, and yes / as it is a node view, the Node being viewed is there.....

regards
Christian

#23

#2 did not fix the problem for me...

#24

Status:active» closed (cannot reproduce)

I am putting it back to closed, cannot reproduce.

Works now as it should.

nobody click here