Fatal error: Cannot use string offset as an array in ....filefield_paths.module on line 186
| Project: | FileField Paths |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Hi
When I have a node type with a CCK field of type File set-up to allow an Unlimited number of values in the 'Global settings' fieldset I get this error when attempting to save a node of that content type that has only 1 value entered:
Fatal error: Cannot use string offset as an array in C:\xampp\htdocs\ReefAtlasDev\sites\all\modules\filefield_paths\filefield_paths.module on line 186
I tried setting the number of values to 1 and 2 and got no error in either case, it only seems to be with the Unlimited value.
To fix this I changed line 177 of fielfield_paths.module in function filefield_paths_nodeapi() from:
if (empty($file['filepath'])) {
to
if (!is_array($file) || empty($file['filepath'])) {
You only get the "Cannot use string offset as an array" error when you try to assign something to the array on line 186 but the earlier accesses of $file are also incorrect.
The problem is that the foreach loop is gone through twice, once with the actual file information and then a second time when $file just contains the string "Add another item".
Using the same test case with the dev version that I just downloaded I get the same error but a different line number:
Fatal error: Cannot use string offset as an array in C:\xampp\htdocs\ReefAtlasDev\sites\all\modules\filefield_paths\filefield_paths.module on line 235.
| Attachment | Size |
|---|---|
| create_filefieldpathsbug.png | 63.45 KB |
| managefields.png | 153.58 KB |

#1
Hi there,
I've run multiple tests with the latest dev version on both my lamp and wamp setups and have not been able to replicate the issue.
What version of FileField are you running?
#2
#3
FileField 6.x-3.0-alpha5
#4
and CCK 6.x-2.1
#5
#6
I am getting this:
array(4) { ["type"]=> int(1) ["message"]=> string(36) "Cannot use string offset as an array" ["file"]=> string(111) "/sites/all/modules/filefield_paths/filefield_paths.module" ["line"]=> int(183) } n/a
i am using fp 6.1.0
#7
I also tried fp 6.1.x dev version and same result
array(4) { ["type"]=> int(1) ["message"]=> string(36) "Cannot use string offset as an array" ["file"]=> string(111) "/sites/all/modules/filefield_paths/filefield_paths.module" ["line"]=> int(183) } n/a
#8
@activelyOUT
I have never managed to replicate this issue, is there any information you can provide that will help me reproduce it?
Did the fix pauline_perren suggested work for you? It's line 318 in the dev build instead of line 177.
If it does, can you install the devel module and enter the following line before line 318 and post the results here?
dpm($file);Let me know how you go.
Cheers,
Deciphered.
#9
FYI: I've upgraded to 1.1 (without my fix from before) and I no longer get the error. I'm running version 3.0-rc1 of FileFields now.
#10
Thanks Pauline, that is fantastic news.
However, there where no major changes on my end for this issue. It is possible that it is related to FileField?
@activelyOUT
What version of FileField are you using? And are you still seeing this issue on 6.x-1.1?
Cheers,
Deciphered.
#11
Hi all,
I've got the same issue as Pauline with the latest version of filepath. The fix of Pauline worked very well, but it's on a different line number: 412
#12
Hi joachimds,
Is it possible for you to provide some information on what you did to reproduce the issue? Such as steps taken, modules enabled and settings used.
Also, if possible could you run the FileField Paths tests using the simpletest module and let me know the results?
Cheers,
Deciphered.
#13
Marking this as closed to lack of information and the inability to reproduce the issue.
Cheers,
Deicphered.
#14
I believe it may be a conflict with the Context module, which in turn uses the PURL module. I am also using spaces and features modules.
#15
@naptown
Can you provide more information, such as how you came about this assumption and how to reproduce this issue?
#16
I'm running into this issue on CCk 2.5, Filefield 3.2 and FileField Paths 6.x-1.3. Like paulinie, I can change the number of items to a fixed number of values, there is no problem. Only when using 'unlimited', I get the error displayed. It's on line 362 in my version of File Field Paths. The error is there, no difference if I upload a file, create a node with no file attached or save an existing node.
Changing line 356 like pauline suggested solves the problem, but I have no idea, what siedeffects this could have.
Attached a patch against 1.3. (sorry, seems to be a bit more than necessary. Damn CVS/Eclipse patch generation).
#17
Seems to be fixed in -dev. Please release a new version.
#18
Automatically closed -- issue fixed for 2 weeks with no activity.