"Illegal string offset 'lang_selected'" warnings
Posted: Fri Jul 11, 2014 7:57 am
Looking at the error logs of my webserver, I've noticed this error cropping up every so often:
I'm using the multilingual plugin (serendipity_plugin_multilingual), of course, so the blog's display language can be selected. But selecting the display language, or choosing a certain language version of a blog entry did not cause this error. If a certain action was causing it, it would have to be something else.
To pinpoint the cause, I've cross-checked the access log of the server with the error. The error apparently occurred when a page request is made in the form of:
Note the "&serendipity" part - it's missing something like [lang_selected]=default, i.e.:
So I've crafted the URL in the same manner as the first one, and was able to recreate the error message. Curiously, this does NOT generate an error, though:
The only difference is that it's omitting "index.php?url=" part.
I can't prevent someone entering a malformed URL - these requests were tracked down to a spam bot in Ukraine. But I would like the functions_config_inc.php to handle the error gracefully so that a PHP warning isn't issued every time. The code around line 993 is:
So I'm guessing that, when "&serendipity" is appended to the URL, "lang_selected" gets a certain value, but since the problematic URL does not have one specified, an "illegal string offset" error is generated. Perhaps an error-trapping code could be inserted?
P.S. I'm currently using version 1.7.8.
Code: Select all
PHP Warning: Illegal string offset 'lang_selected' in (server path)/include/functions_config.inc.php on line 993
To pinpoint the cause, I've cross-checked the access log of the server with the error. The error apparently occurred when a page request is made in the form of:
Code: Select all
http://(blog URL)/index.php?url=archives/(blog page).html&serendipity
Code: Select all
http://(blog URL)/index.php?url=archives/(blog page).html&serendipity[lang_selected]=default
Code: Select all
http://(blog URL)/archives/(blog page).html&serendipity
I can't prevent someone entering a malformed URL - these requests were tracked down to a spam bot in Ukraine. But I would like the functions_config_inc.php to handle the error gracefully so that a PHP warning isn't issued every time. The code around line 993 is:
Code: Select all
elseif (!empty($serendipity['languages'][$serendipity['GET']['lang_selected']])) {
if ($serendipity['expose_s9y']) serendipity_header('X-Serendipity-InterfaceLangSource: GET');
$lang = $serendipity['GET']['lang_selected'];
}
P.S. I'm currently using version 1.7.8.