I just upgraded it from date-6.x-2.0-rc6.tar
and I have cleaned my cache and ran update.php. but the error remains.

CommentFileSizeAuthor
#3 Untitled-1.jpg797.03 KBWuekkie

Comments

webwriter’s picture

Subscribing. I have this error and cannot add any content that includes a date field.

karens’s picture

Status: Active » Postponed (maintainer needs more info)

I can't replicate any problem in the latest code. Update to the very latest -dev and try again.

Wuekkie’s picture

StatusFileSize
new797.03 KB

I get the same error in the may 12 dev: Fatal error: Cannot unset string offsets in /var/www/www.westervillepack966.org/sites/default/modules/date/date/date_elements... on line 279
Was on 6.x -2.1 when trying to fix a "now" views filter then updated to this dev. Tried everything in KarenS' "do these things first" ie; clear all caches, latest dev etc... both before and after the dev upgrade. Same result in two envirnoments, NO LOVE:

Dev site:
Wamp Server 2.0
Appache 2.2.11
PHP 5.2.8
MySQL 5.1.30

Production site:
Ubuntu 6.4
Appache 2.2.4
PHP 5.2.3-1
MySQL 5.0.45

Attached is a screen cap of what I see when trying to edit a node with my CCK date field.

Other Modules:

Views 6.x - 2.5
Calendar 6.x - 2.x dev 2009 May 11
CCK 6.x - 2.x dev 2009 May 11

Thanks for the help,
Wuekkie

pvanderspek’s picture

Version: 6.x-2.x-dev » 6.x-2.2

I just installed the new 6.x-2.2 and now I'm getting the same error.
I want to create a new content item having a CCK Date field and it opens the page with this error

Fatal error: Cannot unset string offsets in /home/kerk/domains/mydomain.nl/public_html/sites/default/modules/date/date/date_elements.inc on line 282

For existing nodes, it's possible to edit the node, but the CCK Date field is gone.

I also have the date popup calendar enabled.

pvanderspek’s picture

I've been looking around a bit more and when clicking on the modify-link for the cck field I get a similar error

Fatal error: Cannot unset string offsets in /home/kerk/domains/mydomain.nl/public_html/sites/default/modules/cck/includes/content.node_form.inc on line 71
pvanderspek’s picture

Status: Postponed (maintainer needs more info) » Active
pvanderspek’s picture

I'm currently doing some debugging. So I printed all the contents of $elements and this is it:

Array
(
    [#type] => date_combo
    [#weight] => 0
    [#default_value] => 2ow
    [#date_timezone] => Europe/Amsterdam
    [#element_validate] => Array
        (
            [0] => date_combo_validate
            [1] => date_widget_validate
        )

    [#title] => Datum
    [#description] => 
    [#required] => 1
    [#delta] => 0
    [#columns] => Array
        (
            [0] => value
        )

    [#field_name] => field_datum
    [#type_name] => agenda
    [#post] => Array
        (
        )

    [#programmed] => 
    [#tree] => 1
    [#parents] => Array
        (
            [0] => field_datum
            [1] => 0
        )

    [#array_parents] => Array
        (
            [0] => field_datum
            [1] => 0
        )

    [#processed] => 
    [#attributes] => Array
        (
        )

    [#input] => 1
    [#process] => Array
        (
            [0] => date_combo_process
        )

    [#name] => field_datum[0]
    [#id] => edit-field-datum-0
    [#value] => 2ow
)

However, in the code a reference is being made to $element['#default_value'][$to_field] which doesn't even seem to exist. I hope this helps in solving the problem, because currently I cannot create any new content items which have a date field.

If I just comment out line 282, I don't get any error messages anymore. However, the date field is not visible on the form.

pvanderspek’s picture

I just tested if I could add new date fields to existing content types. The new field does show up, but the existing one doesn't. I have no clue yet what might cause the problem with existing date field, but at least I know it can work. Below the database settings for the date field. Perhaps it helps±

INSERT INTO `content_node_field` VALUES ('field_datum', 'date', 'a:7:{s:11:"granularity";a:5:{s:4:"year";s:4:"year";s:5:"month";s:5:"month";s:3:"day";s:3:"day";s:4:"hour";s:4:"hour";s:6:"minute";s:6:"minute";}s:11:"timezone_db";s:3:"UTC";s:11:"tz_handling";s:4:"site";s:6:"todate";s:0:"";s:6:"repeat";i:0;s:16:"repeat_collapsed";s:0:"";s:14:"default_format";s:5:"short";}', 1, 0, 0, 'date', 'a:1:{s:5:"value";a:5:{s:4:"type";s:7:"varchar";s:6:"length";i:20;s:8:"not null";b:0;s:8:"sortable";b:1;s:5:"views";b:1;}}', 1, 0);

And also the database settings for a field instance:

INSERT INTO `content_node_field_instance` VALUES ('field_datum', 'agenda', 0, 'Datum', 'date_popup', 'a:10:{s:13:"default_value";s:3:"now";s:18:"default_value_code";s:0:"";s:14:"default_value2";s:5:"blank";s:19:"default_value_code2";s:0:"";s:12:"input_format";s:11:"m/d/Y - H:i";s:19:"input_format_custom";s:0:"";s:9:"increment";s:1:"1";s:10:"text_parts";a:0:{}s:10:"year_range";s:5:"-3:+3";s:14:"label_position";s:5:"above";}', 'a:3:{s:5:"label";a:1:{s:6:"format";s:5:"above";}s:4:"full";a:2:{s:6:"format";s:5:"short";s:7:"exclude";i:0;}s:6:"teaser";a:2:{s:6:"format";s:5:"short";s:7:"exclude";i:0;}}', '', 'date', 1);

I thought "2ow" might be a result of parsing "now" and then replacing the "n" by a "2", but at least in the database the default value is correct.

pvanderspek’s picture

Ok, well it seems I've found the cause of the problem. Somehow, Date Popup (as well as some other, unrelated modules) had been disabled. This caused the problem described above.

karens’s picture

Status: Active » Fixed

I can't tell if the problem in #9 was the original problem, but you should certainly check that your modules are still enabled. I have been seeing sporadic reports of them getting disabled during updates, so that's the first thing to check.

Status: Fixed » Closed (fixed)

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

texas-bronius’s picture

Thanks @KarenS-- enabling date popup fixed it for me too.

Anyone else stumbling across this googe hit: Going from dev to staging my remote site exhibited the same issue; drush en date_popup -y to enable the calendar popup module (like it is in dev) did it for me. Guess I need to add this to my Feature.

soundboy89’s picture

Thank you, had this same problem and #9 solved it for me.

somersoft’s picture

Thank you, had this same problem and #9 solved it for me.

Where it goes wrong, if you have this problem and date_popup is disabled, is with the following code in _date_widget() in date/date/date_elements.inc (6.x-2.9)

  foreach ($process as $processed) {
    if (!isset($items[$delta][$processed])) {
      $items[$delta][$processed] = '';
    }
    $date = date_local_date($form, $form_state, $delta, $items[$delta], $timezone, $field, $processed);
    $items[$delta][$processed] = is_object($date) ? date_format($date, DATE_FORMAT_DATETIME) : '';
  }

$items[$delta] is a string 'now' and not an array. $processed then evalutes to zero index and as PHP treats the string as an array of characters, it replaces the single character 'n' with the first character returned by date_format() which currently is a '2' as the year is 2012.