Closed (fixed)
Project:
File (Field) Paths
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Oct 2008 at 16:14 UTC
Updated:
11 May 2009 at 09:32 UTC
I get the following error when using filefield paths in conjunction with pathauto:
* warning: mb_eregi_replace() expects parameter 3 to be string, array given in /sites/all/modules/pathauto/pathauto.inc on line 184.
* warning: mb_eregi_replace() expects parameter 3 to be string, array given in /sites/all/modules/pathauto/pathauto.inc on line 184.
Comments
Comment #1
decipheredHi,
I just ran a couple quick tests and was unable to reproduce the issue.
What versions of the modules are you using?
If possible, get the latest versions of the modules and check if the error persists.
Comment #2
B.P.B commentedThe error occurs when uploading a photo using filefield/imagefield.
I upgraded to the OCT22 dev release, but the bug persists.
When trying to reproduce, did you enable pathauto within filefield_paths to rewrite the filename.
Comment #3
decipheredYes, I enabled pathauto cleanup for both the filename and filepath, and I also tested with an Imagefield.
What version of Pathauto are you using?
Comment #4
B.P.B commentedHere is a list of all my modules from the updates page:
All are up to date according to drupal.
Comment #5
decipheredHmm, the modules seem good, running the same versions as I am for all the modules. Only difference is I don't have Node Map or Lightbox2, and I don't have ImageCache enabled, but I very much doubt they should be related to this issue.
What are the patterns you are using and the data for the tokens?
Comment #6
B.P.B commentedI disabled nodemap and lightbox2 but that had no effect.
I have only two fields in my content type, an imagefield, and a text field "name".
pattern:
[field_name-formatted].[filefield_paths-ext]
As for pathauto, I changed nothing from its original settings.
Comment #7
B.P.B commentedJust a quick update... I also disabled imagecache and views but the error persists.
Comment #8
decipheredI ran a test with that configuration and it worked fine.
Is it possible for you to setup another fresh install with just the required modules and see if the issue remains? I know it's a pain to do so, but without being able to reproduce the issue it's impossible for me to determine the cause.
Comment #9
decipheredAnother thing, what did you put in the 'name' field or does the error occur no matter what you use?
Comment #10
B.P.B commentedOk, very weird. I set up filefield paths on an established site with a similar module setup and it works error free. I should have done this from the beginning instead of wasting your time.
I'll completely reinstall the problem site (tommorrow) and post the results here.
Thanks for replying so quickly.
Comment #11
.kuma commentedSame error here. I'm curious to see your results!
Comment #12
B.P.B commentedI did a full reinstall and now filefield paths renames like a jiffy with no errors. I can't wait until alt tags support!
Comment #13
B.P.B commentedAn observation after more testing:
When the node has one image uploaded, it saves normally.
If there are 2 or more images, it saves VERY slow - around 10 seconds or longer.
This only happens when "cleanup with pathauto" is enabled. I absolutely need that feature, so that file name spaces are turned from %20 into hyphens. Unfortunately its very slow, so I'm stuck between a rock and hard place.
Sometimes I get this error:
or this error:
Please advise.
Comment #14
B.P.B commentedI gave up on pathauto for removing filename spaces by adding this line to the module:
AFTER
Comment #15
.kuma commentedI was looking to use the pathauto cleanup for space removal as well. Thanks for your solution!!
Comment #16
B.P.B commentedYou're welcome my friend.
When you tried to cleanup with pathauto, was it very slow when saving?
Comment #17
.kuma commentedYes, it was a little slow. I suspect because of all the errors. I would receive around 4 mb_eregi_replace() errors per uploaded file.
Thanks again!
Comment #18
deciphered@B.P.B.
I'm glad you got a workaround, however I would still like to work out the exact issue. I will continue to reproduce the issue, and if I ever manage to do so then I will attempt to fix it.
As for the workaround, it might be a useful feature. Can you create a feature request with any ideas of what you think are the primary things needed for replacements and I will look into it ASAP.
Comment #19
thoral75 commentedI have the same error
I don t want to reinstall my website, too much work. Is there an other solution ?
To do that, will it fix my problem ?
gave up on pathauto for removing filename spaces by adding this line to the module:
Comment #20
B.P.B commentedIf all you want to do is convert spaces to hyphens, then yes.
Uncheck pathauto and add my fix.
Comment #21
pauline_perren commentedI think that the problem is data dependent. It seems that the pathauto_cleanstring() function (the one giving the warnings) is called over all possible tokens whether they are used in the particular filename or not.
The warnings occur when the value passed in as the string parameter is an array.
It is interesting that the problem only occurs when 'Cleanup using Pathauto' is enabled for 'File name cleanup settings and not for 'File path cleanup settings' (in my case anyway).
BTW. My comments are true for 6.x-1.0, I haven't had a look at dev yet.
Comment #22
Flying Drupalist commentedGetting this too.
Comment #23
pauline_perren commentedThe reason for these warnings is that several modules implement the hook_token_values() function and return tokens when $type=='field'. Unfortunately some of them return tokens with the same keys.
For example:
Thus getting these warnings is dependent upon which CCK related modules you have enabled. Each one on its own behaves well but when module_invoke_all is called to retrieve the token lists from these modules it bangs them together using array_merge_recursive. When Array_merge_recursive finds identical keys in arrays it is merging it merges their values together into an array for the one instance of the key in the final array. This array of values is then passed into a pathauto function that is expecting a string.
This problem is not related to FileField Paths. It is one of the modules that prefixes its keys with its module name, so its keys don't conflict with other modules.
Comment #24
deciphered@pauline_perren
Thanks for the detailed response, that means I may be able to finaly replicate the issue and rule it out if what you say is true. :)
Comment #25
Flying Drupalist commented@pauline_perren, just realized I'm not using filefield paths, so thank you for the explaination.
Comment #26
dti commentedOne possible fix would be to patch pathauto so it doesn't warn on multiple values per key name. For example:
This doesn't get to the root problem (either token-providing modules should have unique token names, or token itself should better handle non-unique names). Also, not sure if this bug should be reassigned to either pathauto (where the above patch would go), token, or CCK?
I'm seeing this when I have CCK text and number modules enabled, and using PHP with mbstring module installed.
Comment #27
decipheredImplemented temporary fix to prevent issue and committed to DRUPAL-6--1 and HEAD.
Comment #28
paganwinter commentedWhere can I get this version from?
Meanwhile, is it ok if I get this warning?
Does it break functionality anywhere?
Comment #29
decipheredThe fix is in 6.x-1.x-dev and 5.x-1.x-dev..
The warning should not have broken any functionality, but I can not say that with 100% certainty.
Comment #30
paganwinter commentedWhat does the File Alias option do?
Comment #31
mckeen_greg commentedJust thought I would let you know that the error still persists with the latest of all the required modules.
Strange behaviour though...
My filepath settings are as such: [type-name]/[nid]/logo and filename: [nid]-[filefield-fid]-[filefield-filesize].[filefield_paths-ext]
Directories have been created as: [type-name]/[nid]/logo into which the old filename the image is stored.
Additionally, the tokens were also replaced and directories were created: group/153/logo with my new filename too: 153-55-36595.png. Stranger still, my generic files display links to the original, unfiltered, unpathautoed settings.
Comment #32
deciphered@mckeen_greg,
This particular issue is closed. While you have said you are still seeing this issue, I will need more information to confirm that it is still a problem. A screenshot, module versions, reproduction steps would be great,
You're other issue needs to be re-posted as a separate issue. And some more information about it would be great as I have attempted to reproduce the issue with no luck so far.
Comment #33
marcanoWe get this on our site (Redmami - a site for Spanish parents), when users create content, but NOT when admins or editors create content. Is this a permissions issue?
warning: mb_eregi_replace() expects parameter 3 to be string, array given in /########/htdocs/sites/all/modules/pathauto/pathauto.inc on line 184.
Comment #34
deciphered@redmani This issue is closed.
There are many different causes to this issue, FileField Paths was one, but that is now fixed so if you have the latest version of FileField Paths it is not the issue.
As the error you are receiving mentions Pathauto, it would probably be the best place to start, so maybe create a new issue in the Pathauto issue queue.
Cheers,
Deciphered.