I am using File (Field) Paths.

Modules:

Drupal 7.18
Token 7.x-1.x-dev
File (Field) Paths 7.x-1.x-dev

Error message

Warning: Invalid argument supplied for foreach() filefield_paths_entity_update() függvényben (D:\htdocs\__drupal7\sites\all\modules\filefield_paths\filefield_paths.module 232 sor).

What's wrong?

Comments

Deciphered’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide some more information, preferably step-by-step instructions to reproduce this issue.

However, based on the code, this error should be impossible, because the line before the erring line is a conditional statement to ensure that there is a valid argument for the foreach() statement, and as the data is provided by the Fields system, the only reason it could be malformed is if something else was getting involved.

Happy to help further if you can provide more information.

Cheers,
Deciphered.

dpfitzsi’s picture

Issue summary: View changes

I get this same error if I have active updating enabled for my filefield, and I update the content of a node, I receive this error.

I've tried beta4 and the latest dev and I receive this error with both.

neRok’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta4
Assigned: vikicica22 » Unassigned
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I have just tested for this error with what little information is given, and cannot reproduce.

The original error refers to line 232, which is an empty line in the current dev version. Hence, going to close under the presumption that the error no longer occurs in current version.

Late edit: This may be related to a fix in the current dev #1985280: Warning: Invalid argument supplied for foreach() in filefield_paths_entity_update()

Uv516’s picture

I have tested width a field wich upload mp3-file.
I got the error in two ways: 1) When I create a new node - and - 2) When I add a file to a empty field in an exsting node.
When I press "Save" the error occur.
I can edit the same node (the file-filed is filled) and save again without error.

Then I empty the file-feld - save and edit - fill the field-field - save: Error again.
In line 247 the variable $enabled is TRUE and $entity->{$field['field_name']} is set, but is empty! (Not an array!)

A patch could be:

- if ($enabled && isset($entity->{$field['field_name']})) {
+ if ($enabled && isset($entity->{$field['field_name']}) && is_array($entity->{$field['field_name']})) {

This works for me now without error.

Aurochs’s picture

I have the same issue. Few days ago i moved to new VDS, installed ubuntu 14 and made fresh install of the server etc. I decided to start using graphicsmagic, installed from repositories and after that tried to create a node with pictures - i got the Deprecated function: preg_replace() , resolved the mistake with the fresh dev release but came to a new mistake - the one in this issue thread.
But i have a bit different notice:

.... filefield_paths_entity_update() (строка 259 в файле /var/www/gamepart.ru/sites/all/modules/filefield_paths/filefield_paths.module).

Aurochs’s picture

@Deciphered - i have a differnt line in dev release - #259 and patch from #4 fixed my issue now works fine.
Thank you, Uv516 !

Deciphered’s picture

@Aurochs,

This issue is marked as closed. If you believe it is still an issue, re-open the issue, otherwise there's a chance it will never be seen (I just happened to be looking closely).

It appears to have been closed due to lack of ability to reproduce, so if you can provide steps on how to reproduce this issue from a fresh install of Drupal that would be extremely helpful.

Leaving this closed, until you actively re-open the issue.

Aurochs’s picture

Issue tags: +code

I would like to re-open the issue because i had to aply the above mentioned fix again after another dev update. here is a screen on what image modules i use incl tokens http://prntscr.com/84ukob, my field settings where i see error (other fields same error0 http://prntscr.com/84um70

Deciphered’s picture

Don't say it, do it. Change the status of this issue to 'Active', and as I asked in the previous comment, provide me with steps to reproduce the issue. Not some screenshots, but steps (1. Install Drupal, 2. Download modules (provide list), etc).

If I can't reproduce an issue I can't fix it, and regardless of there being a 'patch' available, I don't blindly commit untested code.

While this may be too much to ask, it's the different between me spending a few minutes to get a working solution for all, or me spending hours try to reproduce an issue I've not seen before which for various reasons may not be possible, and potentially giving up on the issue.

Deciphered’s picture

Aurochs’s picture

@Deciphered really sorry dont hv much time as i am moving around 10 sites now to a new server+close to divorce with my wife. Let it be a duplicate thanks for your efforts

Bill Lea’s picture

Status: Closed (cannot reproduce) » Active

I am not sure how to reopen this issue but I am having the same problem. It will eventually crach sites. I had to go so far as reinstalling Apache as well as Drupal to get my development site back up. I lost all 4love sites on my hosted production server. I was able to recover but it was not pretty. So I at least consider this a sever bug.
To Deciphered.

It is apparent the the if statement gauarding the nested for each IS NOT WORKING. After some
extencive testing I have determined that if unfilled text fields exist strange things happen.
Some times all works as normal expected. These cases are where single fields are used.
Sometimes you will get a crash so severe it will take out Drupal and Apache.
This occurs where multiple fields are used.

To verify that this occurs all you have to do is:

1. write a custom module with a title,bidt and teo fields.
one a non file field and one a file field.
2. Used the Graphical ointerface to set the file fields directior to include
the $nid and the $fid as: [node:nid]/[file:fid]
3. Use the manage display function to set a simple generic display for the fields.
4. Create some content leaving the first field unfilled.
5. Save It. --error occurs
6. Create additional content with all fields filled in.
7. Save it = No Error.

I beleive the error occurs in this code:

  $fields = field_info_fields();
  foreach ($fields as $name => $field) {
    
    if ($field['module'] == 'text' && isset($entity->{$field['field_name']}) && is_array($entity->{$field['field_name']})) {
      foreach ($entity->{$field['field_name']} as &$language) {
        dvm($language);
        foreach ($language as &$item) {
          foreach (array('value', 'summary') as $column) {
            if (isset($item[$column])) {
              $item[$column] = preg_replace_callback($pattern, $callback, $item[$column]);
            }
          }
        }
      }

I believe the code contains a typographical error which allows it to try to process a Text field which has no path associated with it. In particular I question the ++" in the if statement.
if this code is changed to !== the error does not reoccur. So the revised code should be:

   $fields != field_info_fields();
  foreach ($fields as $name => $field) {
    
    if ($field['module'] == 'text' && isset($entity->{$field['field_name']}) && is_array($entity->{$field['field_name']})) {
      foreach ($entity->{$field['field_name']} as &$language) {
        dvm($language);
        foreach ($language as &$item) {
          foreach (array('value', 'summary') as $column) {
            if (isset($item[$column])) {
              $item[$column] = preg_replace_callback($pattern, $callback, $item[$column]);
            }
          }
        }
      }
 
Bill Lea’s picture

This is probably the wrong place to raise the issue. So Ill try and open a NEW one.

Bill Lea’s picture

Well its only bee TWO YEARS since I opened this back up. Going to wait for D7 EOL and hope it goes away?