We recently set up a Calendar month view for registration nodes, displaying the title as a link and number of slots filled out of the maximum seats. Whether in the Views GUI preview or the page itself, if we browse to a month containing a registration node we are greeted with:

"Fatal error: __clone method called on non-object in [...]/sites/all/modules/contrib/calendar/includes/calendar_plugin_row.inc on line 381"

The line in question:

$entity = clone($this->entities[$id]);

The error is being generated by calendar module, but I believe it's being caused by registration module. The error only appears when we try to include Registration Settings: Slots Used (capacity_used) in the calendar output. calendar_plugin_row::render() needs to clone() the entity, but $row->nid is not set when this field is used. I cannot grok what's happening in registration_views_views_data_alter() and registration_handler_field_entity_capacity_used::render() clearly enough to tell where the problem is.

Has anyone else encountered this or have any idea of what might be up?

Comments

micahw156’s picture

Issue summary: View changes

Fixed markdown formatting.

ecclescake’s picture

I've encountered this same error. It's low on my issue queue, but I'd really like to solve it.

bentobey’s picture

I'm encountering the same error. Anyone have any idea what's causing this and how to work around it?

bentobey’s picture

I was able to work around this issue by using the Views Field View module (https://drupal.org/project/views_field_view) to render the events themselves inside of a calendar view.

bentobey’s picture

This is still occurring for me on the latest dev that was just released a few days ago. It's possible to work around it with the Views Field View module, but the query is intense on a large calendar. It would be great to be able to fix this in Registration directly. If anyone needs more information or has a fix, please update this issue.

Is it possible this bug is in Calendar instead of Registration?

bentobey’s picture

Issue summary: View changes

Additional formatting fixes for better readability.

redkelpie’s picture

Issue summary: View changes

I don't know if this is necessarily a good fix, but is working for my specific situation.

For whatever reason, when you add the "Registration Settings: Slots Used" field, it affects what's getting returned by $row->{$this->field_alias}. In my case I was getting back "int 6." This is problematic because later on we try to get the entity object based on the $id in the foreach loop..

Since I'm only using nodes, I changed $id in the render function to use $row->_field_data['nid']['entity']->nid. I also removed the clone() on clone($this->entities[$id]) in the foreach loop and haven't run into any conflicts with the Upcoming block.

I then used the math expression solution found in this issue https://www.drupal.org/node/1991806 to output the slots remaining.

I have a feeling this isn't the root of the issue, but have a work around that is working for me.

oranges13’s picture

I was having a different issue caused by the same problem, the error I was getting was

Notice: Undefined offset: 0 in calendar_plugin_row->render() (line 382 of /var/www/drupal-7.34/sites/all/modules/calendar/includes/calendar_plugin_row.inc).

From redkelpie's suggestion I modified line 366 as follows:

$id = $row->_field_data['nid']['entity']->nid;

And this worked. I did not have to remove the clone() in line 381.

Michael_Lessard_micles.biz’s picture

Greetings,

This might help any who have this error.

In my case, the error was provoked by one corrupt node that had a date field.

That node was considered "Page not found' on the site. Therefore, in my database, via a search in phpMyAdmin, I carefully deleted by hand all instances of that specific nid/entity_id (note: one must be very careful not to delete the same number for vid/revision_id, etc.). It requires some time since the D7 database structure is rather complex, but it removed the Calendar view bug.

weizrd’s picture

I can confirm that #6 fixed my issue with no apparent other effects (done everything on a clean install done specifically to debug this). I suggest that a patch should be made.

drewfranz’s picture

Patch submitted on child issue https://www.drupal.org/node/2883537

Chris Matthews’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Closed (works as designed)
oranges13’s picture

Is this actually fixed? Why was this issue closed with no information?

Chris Matthews’s picture

Hi oranges13, it seems like this issue was a result of a Calendar bug, or is that not correct?