Closed (fixed)
Project:
Event
Version:
4.7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2006 at 08:09 UTC
Updated:
5 Apr 2006 at 23:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
benwei commentedNevermind, I'm either an idiot or I'm delusional. I did a fresh CVS checkout and the issue seems to be gone. Sorry folks.
Comment #2
dado commentedNot sure if this is my fault but for the record:
I just upgraded to Drupal 4.7 beta 6 and I get the same error when I try to preview or submit a new node (of my own node type)
I was not getting this error prior to upgrading to beta 6.
I applied the patch in this post and it fixed the error.
Here was the error I was getting
Fatal error: Cannot use string offset as an array in line 835 of ... filter.module
Comment #3
dopry commentedThis is fixed in cvs HEAD. Wait for beta7 if it exists in beta6.
Comment #4
dado commentedI'm still getting this bug. Just downloaded the latest CVS tar.gz file from here
http://drupal.org/files/projects/drupal-cvs.tar.gz
and replaced all core code. Still getting same bug when I try to create content.
Fatal error: Cannot use string offset as an array in C:\workspace\mysite\modules\filter.module on line 835
Comment #5
kkaefer commenteddado, could you explain exactly what you did to get this error?
Comment #6
dado commentedI can post story & blog post no problem. However, when I try to create new node from the contrib modules I have tested, I get the error
To reproduce error: place latest CVS version of event module's folder in modules directory. enable event & basicevent modules. Go to create content -> event
Fill out minimal info, then click "submit" or "preview". You should get the error. Unless I have done something stupid (likely).
Thanks
Comment #7
chx commentedThis means that you are running with a pre4.7/bogus filter module. How do I know this?
so,
$form[$key]is a string. However, it's a child. Children are supposed to be arrays in form API. Case closed.Comment #8
mgiffordI'm running into this problem too. My site was running on CVS HEAD, I've since moved it to the last RC. However, I have a parallel site up with the old code. I was running into this problem in php5 when trying to upload images.
So, Just to make sure we're talking apples to apples here, I deleted the filter.module, pulled down a deleted version. Here's what I'm left with:
[mike@team2 modules]$ pwd
/home/dm7_test/modules
[mike@team2 modules]$ cat CVS/Root
:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal
[mike@team2 modules]$ cat CVS/Repository
drupal/modules
[mike@team2 modules]$ less filter.module
<?php
// $Id: filter.module,v 1.113 2006/03/14 15:15:46 unconed Exp $
....
But when I try to upload a image all I get is this in the logs:
[client 64.26.*.*] PHP Fatal error: Cannot use string offset as an array in /home/dm7/modules/filter.module on line 835, referer: http://openconcept.ca/node/add/image
and a blank screen at this path:
node/add/image
So, either I'm missing something or this is an outstanding and critical bug.
Mike
Comment #9
dopry commented@mgifford - a bunch of blank space don't tell me much.
Comment #10
benwei commentedLike dado, I am still getting this with the contrib event module, but not with the builtin modules (tested page, blog, book, forum, and story with HEAD).
Based on this, it seems to me this is more accurately classified as a bug in event (and possibly other contrib modules) and not in filter.module. I will see if I can figure out a solution from within event.
Comment #11
benwei commentedDoing a search in the drupal base, the only places I could find where custom validation functions like filter_form_validate() were registered for forms were in system.module and filter.module. In both cases these validation functions (password_confirm_validate() and filter_form_validate(), respectively) take only one argument, which is expected to be the form array.
However, when these functions are actually called in _form_validate(), they will have a form_id prepended to their arguments list if such a $form_id is set.
From includes/form.inc, in _form_validate():
This is the source of the problem. When password_confirm_validate() and filter_form_validate() are usually called, $form_id is not set, so the first argument actually is the form array, as expected. However when filter_form_validate() is called in event.module, $form_id is set, so it is passed to filter_form_validate() as the first argument instead of the actual form array. It seems to me that _form_validate() should be appending the extra array containing the $form_id to the arguments list at the end, instead of putting it at the beginning. This way, custom validation functions can expect only one argument and have it guaranteed to be the form array instead of the form_id. They can also be written to accept a second argument for the form_id and have it default to null. But maybe there is some piece of history that I'm missing here.
Comment #12
chx commentedi delegate this to event module but care to tell me, please where event module calls filter_form_validate??
Comment #13
chx commentedComment #14
benwei commentedOK, I think I've got this figured out. The problem actually lies more specifically in event/contrib/basicevent.module. Near the end of the file, in the function basicevent_form(), the filter format selection form is appended to the event node form like this:
filter_form() then sets $form['#validate'] to filter_form_validate(), which is later called from _form_validate() as I discussed above. The problem is that _form_validate() calls filter_form_validate() with a form_id as the first argument, which filter_form_validate() is not expecting. In all of the core modules this doesn't happen because the filter form is it's own separate form within the whole node form. This matters because _form_validate() is recursive and recurses through each child form, but when it calls itself, it does *not* pass a form_id parameter.
The bottom line here is that if you put the filter form as it's own separate form inside the main node form, things work fine, but if you just tack it onto the end, as basicevent.module does, you run into trouble. So, I looked at how page.module does it and basically copied the approach there, and came up with the attached patch, which works pretty nicely for me. Also, I checked to make sure that filter_form_validate() is still being called, and it is.
Let me know what you think.
Comment #15
dado commentedgreat work, benwei! This was my problem with my contrib module. The random contrib modules I tested also must have the same code. (basicevent, decisions)
I see this is a bug in drupaldocs, node_example.module code.
http://drupaldocs.org/api/head/file/contributions/docs/developer/example...
I gather that anybody who has copied or will copy node_example.module as a start to their new node will have this bug.
To fix my contrib module, I used benwei's lead and changed the above offending line of code to
Not sure if this works for all cases. My node module's form validation is still working
Comment #16
grbitz commentedbenwei's patch fixed this for me, fatal error on line 835 of filter.module. Thank you. : )
Comment #17
killes@www.drop.org commentedapplied to cvs.
Comment #18
(not verified) commented