Download & Extend

Fatal error: Cannot use string offset as an array in ...\filefield_paths\filefield_paths.module on line 362

Project:File (Field) Paths
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hello!

To reproduce you should just create the filefield with unlimited values (so that you have the "Add another item" button on the node editing form).

The reason if that this button ("Add another item") is returned as a separate field of type "filefield" and is being processed. But the resulting $file variable in the code is just a string "Add another item" and is not an array. Thus, this code generates the fatal error:

<?php
if ($file['status'] == 0) {
 
$file['data']['process'] = TRUE;
}
?>

I managed to fix it by checking the $file variable using the is_array() function:

<?php
if (($file['status'] == 0) && is_array($file)) {
 
$file['data']['process'] = TRUE;
}
?>

Probably, it should be checked in some other place - please advise.

Thanks

Comments

#1

Priority:critical» normal

While I was unable to reproduce this issue, there is no harm implementing a check.

Will be committed in next development build.

#2

Status:active» fixed

Committed to DRUPAL-6--1.

#3

Status:fixed» closed (fixed)

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

nobody click here