this is the notice message i am getting when ever i add taxanomy term or picture and few other fields ,
am using Panels->Pages->node_edit to reneder this content type.

Notice: Undefined property: stdClass::$nid in ctools_node_created_content_type_render() (line 35 of /var/www/html/dev1/sites/all/modules/ctools/plugins/content_types/node_context/node_created.inc).

wat can i do about this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel’s picture

Status: Needs work » Active

It looks like you are trying to add *display* fields on an *edit* form. Try using node_view if you want to try rendering a node. This won't at all especially if there's no node yet, so there's a slight chance this is not possible at all (which would make sense though)

mgifford’s picture

I just got this related error:

Notice: Undefined property: stdClass::$nid in ctools_node_updated_content_type_render() (line 34 of /DRUPAL7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_updated.inc).

joel_osc’s picture

Just to ellaborate on the above comment...we are seeing this error on a node/add form when selecting a value from a hiearchical select widget on an entity reference (taxonomy) field which uses AJAX to update the form. Since we are on a node/add form and have not yet submitted the node, I am not sure we should be in this code at all? If we should be then we should likely check $node->nid is set before using it on line 34.

 21  */
 22 function ctools_node_updated_content_type_render($subtype, $conf, $panel_args, $context) {
 23   if (empty($context) || empty($context->data)) { 
 24     return;
 25   } 
 26   
 27   // Get a shortcut to the node.
 28   $node = $context->data;
 29   // Build the content type block.
 30   $block = new stdClass();
 31   $block->module  = 'node_updated';
 32   $block->title   = t('Last updated date');
 33   $block->content = format_date(!empty($node->changed) ? $node->changed : $node->created, $conf['format']);
 34   $block->delta   = $node->nid;
 35   
 36   return $block;
 37 } 

I guess one possible solution would be to see if the $context->data->nid is set as well at line 23:

23 if (empty($context) || empty($context->data) || empty($context->data->nid)) {

Although, there is likely a better way to see if the form has been submitted.

joel_osc’s picture

Status: Active » Needs review
FileSize
585 bytes

Here is a one line patch file if anyone needs it.

joel_osc’s picture

Issue summary: View changes

Notice: Undefined property: stdClass::$nid in ctools_node_created_content_type_render() (line 35 of /var/www/html/dev1/sites/all/modules/ctools/plugins/content_types/node_context/node_created.inc).

DamienMcKenna’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Assigned: madhudvs » Unassigned
Issue summary: View changes

You should only assign an issue to yourself if you're going to work on it, otherwise please leave it unassigned. Thanks :)

mgifford’s picture

This seem like a pretty simple one line patch. It still applies, but it's been sitting here for over 2 years now.

Can we get this into the repo and fix issue? Still applies nicely but I haven't got a local environment set up now to replicate the problem.

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community

RTBC.

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Quick simple fix. Committed.

  • japerry committed 9cea778 on 7.x-1.x authored by joel_osc
    Issue #1596720 by joel_osc:  Undefined property: stdClass::$nid in...
mgifford’s picture

Thanks @DamienMcKenna & @japerry

Status: Fixed » Closed (fixed)

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

beerbomber’s picture

I am wondering why the patch was only applied and committed for node_update.inc
Seems like someone else encountered it with node_create.inc
And myself, have seen it with node_content.inc and I applied the same patch but to the function impacting me (ctools_node_content_content_type_render) and it works now.

Looking at node_update, node_create and node_content .inc they all assume that nid is not empty coming in the function.

beerbomber’s picture

I updated to 7.x-1.10 (Aug-17-2016) and I noticed that I was getting Notice: Undefined property: stdClass::$nid in ctools_node_created_content_type_render() again.

To fix it, I had to reapply this to line 30 of node_content.inc because I have the same exact scenario explained at #3

function ctools_node_content_content_type_render($subtype, $conf, $panel_args, $context) {
if (!empty($context) && ( empty($context->data) || empty($context->data->nid)) ){
return;
}

I have never contributed a patch or else, where can I find the instruction so that I will suggest a patch ?

beerbomber’s picture