I get the following errors when an Event (CiviCRM Multiday) is created via Add Content or when an existing event is edited and saved.

Notice: Undefined index: value in civicrm_multiday_event_node_presave() (line 354 of ..\sites\all\modules\civicrm_multiday_event\civicrm_multiday_event.module).
Notice: Undefined index: value in civicrm_multiday_event_node_presave() (line 356 of ..\sites\all\modules\civicrm_multiday_event\civicrm_multiday_event.module).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 219 of ..\profiles\commerce_kickstart\modules\contrib\entity\includes\entity.controller.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 219 of ..\profiles\commerce_kickstart\modules\contrib\entity\includes\entity.controller.inc).
Notice: Trying to get property of non-object in civicrm_multiday_event_node_presave() (line 379 of ..\sites\all\modules\civicrm_multiday_event\civicrm_multiday_event.module).
Notice: Trying to get property of non-object in civicrm_multiday_event_node_presave() (line 380 of ..\sites\all\modules\civicrm_multiday_event\civicrm_multiday_event.module).

This is on a site running Commerce Kickstart 7.x-2.13 with Entity API 7.x-1.3. I'm not sure if this is an issue with CiviCRM Multiday or the Entity modules (or both).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bcobin’s picture

I'm having the same issue, but I'm not running Commerce Kickstart:

https://drupal.org/node/2228821

I think there's something different in Civi 4.4.5, but I've not heard anything for about a month now...

seascoot’s picture

@bcobin
I should have mentioned -I'm on Civi 4.4.5.

coderdan’s picture

Status: Active » Postponed (maintainer needs more info)

@seascoot: First, what you are seeing are PHP warnings and notices. Note these are not the same things are outright errors and shouldn't be preventing things from working (you don't have PHP notices enabled on a production site do you?). Second, I cannot replicate your problem and will need more details. What version of Drupal are you using? What version of civicrm_multiday_event? What version of PHP?

seascoot’s picture

@coderdan

Understood - these are not fatal errors. I'm running a development site on WAMP with PHP 5.3.13.

As shown in the issue summary/metadata, civicrm_multiday_event is 7.x-1.0-beta7.

Commerce Kickstart 7.x-2.13 uses Drupal 7.27 as core.

MySQL is 5.5.24.

seascoot’s picture

I first got these error on a WAMP development site.

I set a completely new install from scratch on a Linux CentOS shared server running php 5.4.29. No data was imported to the database, so it was "clean" apart from setting up modules. Drupal is 7.27, Commerce Kickstart 7.x-2.14, CiviCRM Multiday Event 7.x-1.0-rc1+2-dev, Field collection 7.x-1.0-beta7, CiviCRM 4.4.5.

I got the same set of errors with this new install. I also notice that the event gets saved in CiviCRM with a start date and time of 12/31/1969 08:00AM but the event title in CiviCRM Multiday Event shows as Tue, 09/16/2014 - 15:40 to Tue, 09/23/2014 - 16:40 which is what was entered. I can add two sessions, but attempts to add another create an ajax error "an error occurred while attempting to process system/ajax: cannot read property "drupal" of undefined". If I save and exit, I can go back and manage content to edit the event and add another session, but it has to be done one at a time because the same ajax error shows after the first addition.

bcobin’s picture

Thanks for confirming this - I reported the same behavior in https://drupal.org/node/2228821 but I'm not running Commerce Kickstart, nor have I tried to add additional events before fixing the faulty event.

I'm running the module on several installations and the main differences I can think of would be PHP version and Civi 4.4.5 - I've already tried both PHP 5.3.13 and 5.4 - no joy.

Here's hoping this can be tracked down - as per my original post, I've resigned myself to handling new events myself (and dealing with the errors) until the problem is solved. I can't let clients see this.

Thanks to all and good luck!

seascoot’s picture

I think I've tracked down the AJAX error. I have the event body field set to Full HTML so that I can format the description using the WYSIWYG module with CKEditor set in the profile. When I disable the WYSIWYG module the AJAX issue relating to adding additional session dates disappears.

There is a similar issue reported here related to WYSIWYG/CKeditor #2243413: Error when adding field items - Add another item and also here for WYSIWYG #1757684: Ajax error on Add another item. Applying patch #28 from the latter did not fix the problem.

The undefined index/array_flip issues still remain unresolved.

seascoot’s picture

Thanks to bcobin as posted in www.drupal.org/node/2228821 there is a work-around for this by rolling back Field Collection beta 7 to beta 5.

coderdan’s picture

I was able to re-produce the errors. The problem is the way civicrm_multiday_event is checking the dates of the sessions. Field Collection changed the node attached data structure dramatically (in a good way); the entire FC related entity is now available in the node data. This will eliminate the need to do a field_collection_item_load() in the middle of CME processing.

The reason that the CiviEvent gets created with a Jan 01 1970 date is because Civi uses the Unix epoch for event dates that are set to NULL due to CME being unable to correctly find the original entities.

A patch is in the works.

coderdan’s picture

After getting into the code a bit more and doing some debugging, I realized that my conclusion was essentially correct but my logic in reasoning it out was flawed. What is happening is that Field Collection is saving the node along with the form submission. Due to this we are entering into the hook_node_presave function twice for each node being saved in the UI. When the FC is saving the node, it attaches in the entire FC entity to the node object instead of going through the Field API to format the field values.

I have run into this issue when doing a CME Migration, so patching this up will be that much more useful.

  • coderdan committed 46015bf on 7.x-1.x
    Issue #2271335 by dsasser: Add check for Field Collection entity on...
coderdan’s picture

Assigned: Unassigned » coderdan
Status: Postponed (maintainer needs more info) » Needs review

Fix has been added to the latest 7.x-1.x branch of CiviCRM Multiday Event. Please try out the latest dev version and let me know if your problems are resolved.

  • coderdan committed 57fbede on 7.x-1.x
    Revert "Issue #2271335 by dsasser: Add check for Field Collection entity...
kreynen’s picture

Issue tags: +cmd-mnn, +cmd-next-release
coderdan’s picture

Assigned: coderdan » Unassigned
Status: Needs review » Fixed
kreynen’s picture

Version: 7.x-1.0-beta7 » 7.x-1.x-dev
Status: Fixed » Needs work

This is why developers should move issues to "Needs Review" instead of "Fixed" themselves. The latest commit had a PHP error.

http://cgit.drupalcode.org/civicrm_multiday_event/tree/civicrm_multiday_...

Not sure if the intent there is $end_entity = end($node->field_civicrm_multiday_session[LANGUAGE_NONE]); or $end_entity = end($node->field_civicrm_multiday_session[LANGUAGE_NONE]['entity']);, but what was committed obviously isn't right.

coderdan’s picture

Not sure if the intent there is $end_entity = end($node->field_civicrm_multiday_session[LANGUAGE_NONE]); or $end_entity = end($node->field_civicrm_multiday_session[LANGUAGE_NONE]['entity']);, but what was committed obviously isn't right.

@kreynen - the code works perfectly fine for me. My guess is that I'm running a more current version of Field Collection (7.x-1.0-beta7). Could you confirm this?

coderdan’s picture

coderdan’s picture

I am unable to reproduce the problem with Field Collection 7.x-1.0-beta5. If I could see a var_dump or dpm() of your $node->field_civicrm_multiday_session value, that would be awesome.

Note that I'm working on a fresh D7 core build, not a starter kit.

kreynen’s picture

I am able to enable the module on Pantheon where they run PHP 5.3.17, but this code results in a PHP parse error at the syntax level on other servers.

This isn't an issue with the version of field_collection or the use of a distribution. The PHP parser on these servers doesn't believe that end($node->field_civicrm_multiday_session[LANGUAGE_NONE])['entity'] is valid PHP.

We never get far enough to check the change in the logic in the update.

When a site running on PHP 5.3.3 upgraded to the dev snapshot that included this change and the module was already enabled, it WSOD the entire site. When I try enabling the module on a clean site running 5.3.14, I get the same error...

Parse error: syntax error, unexpected '[' in ...sites/all/modules/civicrm_multiday_event/civicrm_multiday_event.module on line 366

On a clean site, the module never enables.

I've tried disabling APC. No difference.

I can get the site to work/module enabled if I chance the code at line 366 to...

elseif ($node->field_civicrm_multiday_session[LANGUAGE_NONE][0]['field_session_date']) {
      $start_entity = $node->field_civicrm_multiday_session[LANGUAGE_NONE][0]['entity'];
      $lastkey = key(end($node->field_civicrm_multiday_session[LANGUAGE_NONE]));
      $end_entity = $node->field_civicrm_multiday_session[LANGUAGE_NONE][$lastkey]['entity'];
    }

But I'm not sure that's the same intent as end($node->field_civicrm_multiday_session[LANGUAGE_NONE])['entity']. If it is, I suggest we change to that vs. trying to figure why specific versions of PHP throw a parse error.

coderdan’s picture

FileSize
768 bytes

I believe the problem is with versions of PHP earlier than 5.4.10. I was able to reproduce the WSOD by switching to PHP 5.3.20. Seems PHP 5.4 thinks more like I do than does PHP 5.3.

Let me know if this patch helps.

seascoot’s picture

Just an FYI. I am hosted on a server running PHP 5.4.29 and I do not see the problem Kreynen noted when running the dev version. The dev version also allowed me to update Field Collection to beta 7 without producing the originally reported errors.

stefanwray’s picture

Status: Needs work » Reviewed & tested by the community

On channelAustin's live community site I upgraded to the latest dev snapshot for this module which included the commits referenced in this issue.

I'm changing the status.

  • kreynen committed 2340c31 on 7.x-1.x authored by coderdan
    fixes regression from #2271335 that contributed to #2327375
    
kreynen’s picture

@seascoot can you test the latest dev snapshot and make sure this works for your version of PHP as well? I've tested it on a few different configurations and think we're ready to roll a new release.

kreynen’s picture

Assigned: Unassigned » synchlayer
seascoot’s picture

@kreynen

I'm pleased to report that I've been running that snapshot for 3 days now on the same server without issues.

synchlayer’s picture

Status: Reviewed & tested by the community » Closed (fixed)