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
Comment #0.0
micahw156Fixed markdown formatting.
Comment #1
ecclescake CreditAttribution: ecclescake commentedI've encountered this same error. It's low on my issue queue, but I'd really like to solve it.
Comment #2
bentobey CreditAttribution: bentobey commentedI'm encountering the same error. Anyone have any idea what's causing this and how to work around it?
Comment #3
bentobey CreditAttribution: bentobey commentedI 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.
Comment #4
bentobey CreditAttribution: bentobey commentedThis 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?
Comment #4.0
bentobey CreditAttribution: bentobey commentedAdditional formatting fixes for better readability.
Comment #5
redkelpie CreditAttribution: redkelpie commentedI 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.
Comment #6
oranges13I 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.
Comment #7
Michael_Lessard_micles.biz CreditAttribution: Michael_Lessard_micles.biz commentedGreetings,
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.
Comment #8
weizrd CreditAttribution: weizrd commentedI 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.
Comment #9
drewfranz CreditAttribution: drewfranz commentedPatch submitted on child issue https://www.drupal.org/node/2883537
Comment #10
Chris Matthews CreditAttribution: Chris Matthews commentedComment #11
oranges13Is this actually fixed? Why was this issue closed with no information?
Comment #12
Chris Matthews CreditAttribution: Chris Matthews commentedHi oranges13, it seems like this issue was a result of a Calendar bug, or is that not correct?