Hi!

I was messing around on a test site with the Event module. I filled out the Event info, then clicked preview, and got these errors:

warning: date_parse() expects parameter 1 to be string, array given in /Applications/MAMP/htdocs/../sites/all/Modules/event/event.module on line 2801.
warning: date_parse() expects parameter 1 to be string, array given in /Applications/MAMP/htdocs/../sites/all/Modules/event/event.module on line 2801.

I'm using Drupal 6.2, the latest dev version of Event, and MAMP to power my Drupal site locally. I noticed there was another issue with a similar problem, but I think it was for a previous version.

Comments

marcelovborro’s picture

I have the same errors here. I'm using the latest drupal 6.2 and the latest event module.
No workarounds or fixes untill now?

marcelovborro’s picture

Category: support » bug
marcelovborro’s picture

Priority: Normal » Critical
marcelovborro’s picture

Just discovered that this happens only on Safari Browsers ( Konqueror ). So there sould be a simple fix. And it was.
Found a similar bug: http://drupal.org/node/191031

On file event.module, just change line 807
from:
$result = event_get_events($date, $end_date, $rewrite_parameter);

To:
$result = event_get_events(event_implode_date($date), event_implode_date($end_date), $rewrite_parameter);

Now I do not have any errors and the event rss feed works too.

I do not program in php, so if someone who does could check this change for security issues, it would be a good thing.
And if it's okay, please use this hack on next release :-)

Edited:

The errors are back :-(

I still receive:
recoverable fatal error: Object of class stdClass could not be converted to string in ....../bootstrap.inc on line 715.
warning: preg_match() expects parameter 2 to be string, object given in ....../bootstrap.inc on line 718.
recoverable fatal error: Object of class stdClass could not be converted to string in ....../bootstrap.inc on line 715.
warning: preg_match() expects parameter 2 to be string, object given in ....../bootstrap.inc on line 718.

marcelovborro’s picture

I hoped in vain this bug to be solved on todays release but it seens nobody cares about bugs in this module. I still got the same erros on the same situation. The hack on my previus post was ignored too. There are dozens of open bugs for this module and no answer by the developer.
Anyway here are the errors I got:

warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /srv/www/htdocs/blacktower/includes/database.mysqli.inc on line 323.
recoverable fatal error: Object of class stdClass could not be converted to string in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 715.
warning: preg_match() expects parameter 2 to be string, object given in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 718.
warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /srv/www/htdocs/blacktower/includes/database.mysqli.inc on line 323.
recoverable fatal error: Object of class stdClass could not be converted to string in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 715.
warning: preg_match() expects parameter 2 to be string, object given in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 718.
warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: date_parse() expects parameter 1 to be string, array given in /srv/www/htdocs/blacktower/modules/event/event.module on line 2716.
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /srv/www/htdocs/blacktower/includes/database.mysqli.inc on line 323.
recoverable fatal error: Object of class stdClass could not be converted to string in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 715.
warning: preg_match() expects parameter 2 to be string, object given in /srv/www/htdocs/blacktower/includes/bootstrap.inc on line 718.

Gerhard Killesreiter’s picture

Status: Active » Fixed
Fayna’s picture

Has this been fixed in the latest dev version or is there another issue discussing it?

Edit: It's been fixed in the latest dev version. Just looked at the CVS messages.

http://drupal.org/cvs?commit=113690

marcelovborro’s picture

Thanks Gerhard, seems to be ok now :-D

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

mjvesper’s picture

Status: Closed (fixed) » Active

Hello all, this is my first post. I am using the 2008-May-19 6.x-2.x-dev release in a Drupal 6.2 site. I have been having this date_parse issue on preview though it seems that the issue was closed/resolved?

On preview when creating a new event I still get this:

    * warning: date_parse() expects parameter 1 to be string, array given in /home/.easterners/aidschicago/aidsconnect.org/community/modules/event/event.module on line 2695.
    * warning: date_parse() expects parameter 1 to be string, array given in /home/.easterners/aidschicago/aidsconnect.org/community/modules/event/event.module on line 2695.

Also, when looking at the preview that displays, the date is incorrect... It is listed the following though the start date was June 07 at 12:30 am:

Start: 00/00/ - 12:00am
Timezone: Etc/GMT-5

Any help would be appreciated.

killes@www.drop.org’s picture

Status: Active » Closed (fixed)
mjvesper’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Ok, so as I understand your reply, there is a problem with displaying time in a 12-hour format.

Is there any fix? Will simply changing the time format to 24-hour time bypass this bug for now?

More information would be helpful... The wiki link at http://drupal.org/node/253188 just gives the definition of 12-hour time.

killes@www.drop.org’s picture

Status: Postponed (maintainer needs more info) » Fixed

24 hour format should be fine.

I'll try the 12 hour format one day. If you could provide a patch, this could of course speed up the proces..

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

dsellers154’s picture

I am getting this same error using IE and Firefox

warning: date_parse() expects parameter 1 to be string, array given in /home1/xxxxxxx/public_html/modules/event/event.module on line 2785.
warning: date_parse() expects parameter 1 to be string, array given in /home1/xxxxxxx/public_html/modules/event/event.module on line 2785.

function event_explode_date($date) {
if (function_exists('date_parse')) {
$date = date_parse($date); <<<======LINE 2785
$return = array();
$return['year'] = $date['year'];
$return['month'] = str_pad($date['month'], 2, '0', STR_PAD_LEFT);
$return['day'] = str_pad($date['day'], 2, '0', STR_PAD_LEFT);
$return['hour'] = str_pad($date['hour'], 2, '0', STR_PAD_LEFT);
$return['minute'] = str_pad($date['minute'], 2, '0', STR_PAD_LEFT);
$return['second'] = str_pad($date['second'], 2, '0', STR_PAD_LEFT);
return $return;
}
else {
list($date, $time) = explode(' ', $date);
// make it work for "time only" and "date only" values as well
if (!isset($time)) {
if (strpos($date, '-') ) {
$time = '00:00:00';
}
else {
$time = $date;
$date = '--';
}
}

list($year, $month, $day) = explode('-', $date);
list($hours, $minutes, $seconds) = explode(':', $time);
return array('year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hours, 'minute' => $minutes, 'second' => $seconds);
}
}

hugafish’s picture

I am getting a similar error while previewing the post of an event creation. This error is:

* warning: date_parse() expects parameter 1 to be string, array given in /home1/jamacast/public_html/modules/event/event.module on line 2787.
* warning: date_parse() expects parameter 1 to be string, array given in /home1/jamacast/public_html/modules/event/event.module on line 2787.

However the post will go ahead and allow the save function and show within the calendar block. I am using Drupal 6.13, PHP 5.x and the event module is 6.x-2.x-dev . I have looked at all of these forum posts on this issue which seems to vary on the line numbers but still similar cause for error. I do not see any real committed fix to this problem with the Event module though, take a look at the posting dates from each person reporting this type of error. I do not advocate people injecting patch jobs for such errors because as soon as you do this, there will be a new module that fixes an assortment of other security / feature fixes that you will need to upgrade to. You will then see the problem or worse once again.

I wonder if this issue is more related to another module being updated to another version that the event module depends on?

I also tried to change the time format to 24 hr format which made no difference in this error.

Thanks for any help anyone may give.

Eric

dmuth’s picture

Status: Closed (fixed) » Patch (to be ported)

I am seeing this as well, using Drupal 6.14 and the Event 6.x-2.x-dev (2009-Aug-28) module:

warning: date_parse() expects parameter 1 to be string, array given in [PATH REDACTED]/event/event.module on line 2789.

I did some sleuthing and found out that when trying to save an event, event_explode_date() is called several times. The problem is that while the documentation for that function (and the code contained therein) says that the $date variable should be a string, it is an array in some cases, which causes problems.

I wrote a fix. Here's the patch:

--- ./event.module      2010/01/11 03:30:53     1.1
+++ ./event.module      2010/01/11 03:46:39
@@ -2786,6 +2786,15 @@
  */
 function event_explode_date($date) {
   if (function_exists('date_parse')) {
+
+       //
+       // If $date is a variable, turn it into a string so that date_parse()
+       // can understand it.
+       //
+       if (is_array($date)) {
+               $date = event_implode_date($date);
+       }
+
     $date = date_parse($date);
     $return = array();
     $return['year'] = $date['year'];

If anyone runs into issues with the patch, feel free to call on me and pick my brain. :-)

-- Doug

Gerhard Killesreiter’s picture

Status: Patch (to be ported) » Needs work

Well, it is great that you found where the problem is. But can't we fix this where the actual problem is? ie the code calling the function with an array should be fixed, not the function.

swood’s picture

I've run into the same problem and I believe the issue is in event_pre_render (line 2237). All of the event dates start their life as strings except for the exploded dates. The preview is changing all of them to arrays in event_pre_render because of the event_date_later call. The fix is to modify all of the dates to call implode on all of the dates except for the 2 exploded ones.

This appears to correct the issue.

  if (!isset($node->event['start_user'])) {
    $node->event['start_user'] = event_implode_date(event_date_later($node->event['start_exploded'], $user->timezone, 'seconds'));
  }
  if (!isset($node->event['end_user'])) {
    $node->event['end_user'] = event_implode_date(event_date_later($node->event['end_exploded'], $user->timezone, 'seconds'));
  }
  if (!isset($node->event['start_site'])) {
    $node->event['start_site'] = event_implode_date(event_date_later($node->event['start_exploded'], variable_get('date_default_timezone', 0), 'seconds'));
  }
  if (!isset($node->event['end_site'])) {
    $node->event['end_site'] = event_implode_date(event_date_later($node->event['end_exploded'], variable_get('date_default_timezone', 0), 'seconds'));
  }
  if (!isset($node->event['start_utc'])) {
    $node->event['start_utc'] = event_implode_date(event_date_later($node->event['start_exploded'], -1 * variable_get('date_default_timezone', 0), 'seconds'));
  }
  if (!isset($node->event['end_utc'])) {
    $node->event['end_utc'] = event_implode_date(event_date_later($node->event['end_exploded'], -1 * variable_get('date_default_timezone', 0), 'seconds'));
  }

gregarios’s picture

My date status gives me a warning every few days after this latest release too:
Date Timezone requirements The site timezone name may not be correct.

I'm not 100% sure if Event is the cause, but nothing else has changed since the problem cropped up. Saving the Date & Time settings fixes it for a day or so, but it always returns.

japerry’s picture

Status: Needs work » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.