Closed (fixed)
Project:
D7 Media
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2011 at 11:09 UTC
Updated:
8 Oct 2011 at 22:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
slashrsm commentedSame issue created in Views queue #1064334: Cannot use object of type stdClass as array in views_handler_field_field.inc on line 621. Is this a media or views bug?
Comment #2
brandonjp commentedPretty sure mine is different... but I was having "Fatal error: Cannot use object of type stdClass as array in modules/field/field.form.inc on line 193" - Still not sure how or why, but when I changed the content type to not Require Previewing, the issue has gone away.
Comment #3
JacobSingh commentedIs this when used in conjunction w/ views?
#1102500: Media reference fields sets #items to objects, not arrays like other modules..
Is that a dupe?
Comment #4
bc commentedI encounter this error with and without views modules enabled
i'm on 7.x-1.x dev for media module
i'll be investigating this bug more today!
steps to reproduce:
/node/add/whatevercontentype-that-has-media-field
select media
(in media modal dialog, Web: specify an embed url, or Upload: upload an image, and then Submit)
save or preview node
php error results
BUT
node data is saved (or kept in preview mode) without the media attached... but with the media in the gallery!
where does the error occur? i'll find out soon!
Comment #5
bc commentedaha!
bug occurs when saving a preview with 2 or more media fields
see http://drupalcode.org/project/media.git/blob/HEAD:/media.fields.inc#l258
i'm working on a solution now.
Comment #6
bc commentedi can't come up with a clean fix right now, but this core patch makes things usable for the time being (but is evil and makes other things less functional, barf)
Comment #7
sreynen commentedI marked #1102500: Media reference fields sets #items to objects, not arrays like other modules.. as a duplicate.
The simplest steps to reproduce seem to be:
1) Add a multi-value media field to a content type.
2) Add at least one element to that field in a node.
3) Preview the node.
4) WSOD, PHP error in log.
I'm working on a patch now, which looks like it could be as simple as converting an object to an array.
Comment #8
sreynen commentedI changed this to "major" priority, because the priority definition for "major" sounds like it's using this issue as the example, i.e. "a PHP error which is only triggered under rare circumstances or which affects only a small percentage of all users."
Comment #9
sreynen commentedThis incredibly simple patch appears to fix it without causing any new problems.
Comment #11
sreynen commentedPatch is against dev.
Comment #12
sreynen commented#9: multivalue_error-1064502-9.patch queued for re-testing.
Comment #13
JacobSingh commentedThe above patch doesn't catch all the errors that this change causes. This patch isn't perfect either, but it does seem to do the casting w/o causing a bunch of warnings and notices.
Comment #14
bc commented#13: 1064502_multivalue_preview.patch queued for re-testing.
Comment #16
bc commentedpatch patched for recent refactor
Comment #17
effulgentsia commentedI agree with this approach. It breaks BC for any module that implements its own media field formatter, but one that's easy to fix, and I don't think there's very many of those, and there's already recently introduced BC-breakage, so now's probably a good time to do this.
Marked #1005642: $items[$delta] is sometimes an object when Field API requires array. Causes WSOD when previewing multi-valued media field. a duplicate.
Any other reviews / testing results to report on #16?
@bc: if you're up for it, please resubmit the patch, with the inclusion of removing code comments near the affected lines that are made unnecessary. Thanks.
Comment #18
bc commentedremoved irrelevant comments from patch, re #17
Comment #19
effulgentsia commentedThanks. Committed to 7.x-1.x. #18 missed another @todo that could be removed, but I included that in the commit: http://drupalcode.org/project/media.git/commitdiff/18a2777?hp=392e17bccc....
See #17 and Media project page for warnings about updating to a Media dev snapshot post-beta4. I'll release a beta5 when downstream projects have had a chance to update their code accordingly.
Comment #20
trillex commentedThanks for the new dev, but since I started using it, this happens everytime I try to enter a node with a media image:
Fatal error: Call to undefined function file_view_multiple() in /sites/all/modules/media/includes/media.fields.inc on line 169
Comment #21
effulgentsia commentedAfter updating to the new code, did you run update.php?
Comment #22
trillex commentedI had not. My bad. Carry on. :)
Comment #24
golubovicm commentedI got similar error here, it says:
Fatal error: Cannot use object of type stdClass as array in .../www/sites/all/modules/media/includes/media.fields.inc on line 392
This error appears when I try to save node that contains mm field, i.e. I got node $mm and
node_save($mm);
causes this, but not always!
When mine mm node is shown and I try to save it (I got some counter field inside) it trows error.
I also got some other content type which got node reference and "points" to multimedia node.
When that other kind of node is shows, and then I read from it mm nid load mm node and save it - it works well?!?
So, when node that have mm field is shown error appears, and when it's not, but mm node nid is calculated then there are no errors?!?
Another thing is that in "same" situation multimedia node looks different:
So, if $mm is node with multimedia field and $field_files is mm field this:
$mm->field_files['und'][$i]
is sometime object and sometime array, depends on that is multimedia node displayed or not.
This "patch" fixed problem of reading field for me:
if (is_object($mm->field_files['und'][$i])){
$file_thumb = file_load($mm->field_files['und'][$i]->fid);
}else{
$file_thumb = file_load($mm->field_files['und'][$i]['fid']);
}
, but I can't still save node.
Guys, please fix this.
Milan
Comment #25
golubovicm commentedP.S. I re-activated this issue, because I think it's some deeper node/array mistake. Probably some function that executes when node is displayed messes up something.
Comment #26
oierbravo commented#13: 1064502_multivalue_preview.patch queued for re-testing.
Comment #27
brsgnsbe commented#9: multivalue_error-1064502-9.patch queued for re-testing.
Comment #28
robeano commentedI'm not seeing any errors when running the latest 7.x-1.x version of Media module. I'm setting this back to Fixed. A new issue with specific errors should be created if people continue to have problems with Media and previewing nodes.