I guess this is very minor stuff, but anyway...
If the mbstring extension is loaded, the call to strrpos() in [...]/includes/menu.inc on line 910 will give a warning: mb_strrpos(): Empty haystack in [...]\includes\menu.inc on line 910. This will output sometimes (e.g. when saving the theme selection in the admin area) before headers are sent producing thus additional errors. On other occurrences it will simply appear at the top of the page.
The problem is easily solved by not using the mbstring extension in PHP, which anyway is not set by default.
Tried on Windows XP + Apache 2.0.49 + PHP 4.3.2 + Drupal 4.5.0
Comment | File | Size | Author |
---|---|---|---|
#8 | menu_mbstring.diff | 973 bytes | Richard Archer |
Comments
Comment #1
vitamin-1 CreditAttribution: vitamin-1 commentedThat's because mbstring doesn't like empty arguments.
The fix is described here (in russian), thanks to Basielienis: http://drupal.ru/node/view/310
Shortly, you should search in menu.inc (line 910 in 4.5.0) and replace line
$parent = substr($parent, 0, strrpos($parent, '/'));
with
if ($parent) $_lenght = strrpos($parent, "/");
$parent = substr($parent, 0, $_lenght);
ps: Can anybody commit this in HEAD?
Comment #2
Uwe Hermann CreditAttribution: Uwe Hermann commentedThis looks a bit strange to me (I haven't tested it though). Isn't $_length uninitialized if $parent is non-empty?Is that desired? If yes, though it may work, it's not a very obvious or clean solution, IMHO.
Comment #3
(not verified) CreditAttribution: commentedI had this same issue. The solution for me was to revert back to default values on a setting I had changed in my /etc/php.ini. My php.ini included
mbstring.func_overload = 7
after resetting it back to the default value
mbstring.func_overload = 0
drupal as once again happy.
I had set that value to 7 at the suggestion of eGroupWare, to allow support for utf extended characters (if I understood it correctly).
Hope that helps--
rob@shrouded.net
Comment #4
vitamin-1 CreditAttribution: vitamin-1 commentedYes, but disabling function overload you disable using unicode aware string functions in php.
As a result, you loose case insensetive searching in languages other than English.
AFAIR, drupal doesn't use mbstring extension directly, so the only way for non-english speaking people to use full functional searching is to enable function overloading, so strrpos() is automagically replaced with mb_strrpos(), ereg() with mb_ereg() etc.
I hope that one day somebody of developers will fix this annoying bug..
Comment #5
Steven CreditAttribution: Steven commentedThis won't be fixed unless there is a clear description of the problem and its solution, which complies with the Drupal coding standards.
Comment #6
enarsson CreditAttribution: enarsson commentedWell, I am competely new to Drupal, and this error was part of my first impression. It should be fixed as mbstring extension should not need to interfere with Drupal and the problem is there in 4.6.0 as well. My host has this extension on by default.
As far as I can understand, strrpos gets replaced with mb_strrpos by the mbstring extension (http://php.net/manual/en/ref.mbstring.php) and mb_strrpos doesn't like the empty haystack unlike strrpos (at least in php4).
So the current code (line 973-976) in version 4.6.0 is
and could be replaced with
There might be better and more logical solutions to this problem, but this at least seams to fix it for me.
Comment #7
Steven CreditAttribution: Steven commentedDrupal 4.7 has a unicode layer which deals with mbstring. Note however that function overloading is optional for mbstring, and explicitly unsupported in Drupal. Drupal now instructs you in how to fix a broken mbstring setup.
Comment #8
Richard Archer CreditAttribution: Richard Archer commentedThis problem makes the theme settings unusable if mb_strrpos is active and I think it should be fixed in all supported versions of Drupal. Including HEAD because even if mb_string overloading is enabled that is no excuse for throwing these warnings.
The solution is to wrap the
do..while
in anif
to make sure the loop body is not executed if$item['path']
is empty. Which happens every time the menu tree is built when root is processed.Here's a patch which applies with various offsets against all Drupals from 4.5 to HEAD.
Comment #9
Dries CreditAttribution: Dries commentedI wonder why $item['path'] is empty to begin with ... is that the correct/expected behavior?
Comment #10
Richard Archer CreditAttribution: Richard Archer commentedMenu item 0 always has a blank path. So one warning is thrown every time the menu is built.
Comment #11
Dries CreditAttribution: Dries commentedCommitted to HEAD, DRUPAL-4-6 and DRUPAL-4-5. Thanks.
Comment #12
(not verified) CreditAttribution: commentedComment #13
beate_r CreditAttribution: beate_r commentedto make things short: it appears to have reappeared in 4.7.3. Still the requirements are in conflict to those of egroupware (and probably phpgroupware as well).
Why is it so hard to fix this permanently?
best wishes
Beate
Comment #14
beate_r CreditAttribution: beate_r commentedplease excuse, i just noticed that the problem seems to be a missing fix in the taxonomy_menu module. So i reported it in the wrong place.