Error in Pages Widget (PIWIK 1.1.11)


There is an error. Please report the message (Piwik 1.11.1) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning: htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in /home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php on line 53 

Backtrace -->

#0 Piwik_ErrorHandler(...) called at [:]
#1 htmlspecialchars(...) called at [/home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php:53]
#2 Piwik_DataTable_Filter_SafeDecodeLabel::safeDecodeLabel(...) called at [/home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php:70]
#3 Piwik_DataTable_Filter_SafeDecodeLabel->filter(...) called at [/home/www/piwik/core/DataTable.php:387]
#4 Piwik_DataTable->filter(...) called at [/home/www/piwik/core/DataTable.php:414]
#5 Piwik_DataTable->applyQueuedFilters(...) called at [/home/www/piwik/core/API/ResponseBuilder.php:300]
#6 Piwik_API_ResponseBuilder->handleDataTable(...) called at [/home/www/piwik/core/API/ResponseBuilder.php:78]
#7 Piwik_API_ResponseBuilder->getResponse(...) called at [/home/www/piwik/core/API/Request.php:129]
#8 Piwik_API_Request->process(...) called at [/home/www/piwik/core/ViewDataTable.php:431]
#9 Piwik_ViewDataTable->loadDataTableFromAPI(...) called at [/home/www/piwik/core/ViewDataTable/HtmlTable.php:80]
#10 Piwik_ViewDataTable_HtmlTable->main(...) called at [/home/www/piwik/plugins/Actions/Controller.php:464]
#11 Piwik_Actions_Controller->configureGenericViewActions(...) called at [/home/www/piwik/plugins/Actions/Controller.php:406]
#12 Piwik_Actions_Controller->configureViewActions(...) called at [/home/www/piwik/plugins/Actions/Controller.php:46]
#13 Piwik_Actions_Controller->getPageUrls(...) called at [:]
#14 call_user_func_array(...) called at [/home/www/piwik/core/FrontController.php:136]
#15 Piwik_FrontController->dispatch(...) called at [/home/www/piwik/index.php:52]

To fix the problem edit SafeDecodeLabel.php and replace line 53 :

$value = htmlspecialchars($value, $style, ‘UTF-8’);
by
$value = htmlspecialchars($value, $style);

UTF-8 charset wasn’t forced in last release :wink:
Don’t forget to report the fix on 1.1.12

Best regards

I’ve no error,
but only a nice white page :’(
as the generated tracking code

@minos: Clear the cache (tmp/templates_c).
@beloko: Will look into it.

To many problems with this new release… I don’t know why.
I think I’ll try a new fresh install to be sure all my systems are ok.

I found a link after a long trail from teh intial error message

https://bugs.php.net/bug.php?id=47494

Could be just updating the php version. What php version are you running now?

Nothing better after my new fresh install of Piwik…

Thx for help :slight_smile:

I’ve got the same error on RedHat5.9 which provides PHP 5.1.6 (of course fully patched with security fixes).
There IS actually an RPM upgrade option to PHP5.3 but this involves a complete uninstall of PHP5.1 (with an unsure outcome regarding dependencies, haven’t tested that yet).
For now (and near future) i’d be glad to have 5.1 still supported in Piwik. And i’ll bet i’m not the only one. :slight_smile:

Haha !! And what about upgrading your hardware server and rebuilding your Linux core ?
My hoster is running PHP 5.2.1 and my tips work perfectly.

Why upgrading hardware server ? LAMP can work smoothly on a P2 633Mhz/256Mo RAM… no xeon needed with some gigs of ram :stuck_out_tongue:
Everything is working fine on this server… PHP 5.4.4-14 now… For me, it will be “downgrading” (when I see your 5.2.1), not upgrading… But this downgrade can solve the problem, yeah :stuck_out_tongue:

beleoko, that’s not the point.
RHEL 5.x is still widely used (7 years of support). As nice as it’d be, i have not the option of producing downtime right now. This is a huge installation where people rely on availability, not my own, personal site.

Piwik 2.x will require PHP 5.3 so please don’t downgrade to a version before that. It’s much more important to find the issue and solve it.

beloko, would you mind to let me look into your piwik / piwik ftp to track down the issue?

Peter (Piwik Team)

Hi Peter … sorry but I can’t, there 's personnal customer secure information stored on this server.
Elsewhere I can give you some clues if you need.

Minos, I was joking about upgrading your hardware and rebuilding your Linux core :wink:

$value = htmlspecialchars($value, $style); should work on any PHP version.
The encoding charset is optional and default is UTF8 in 5.4.x

http://php.net/manual/en/function.htmlspecialchars.php

Hooo ok! lol. catched!

beloko, in theory it should work yes. Problem is that the string is processed with substr() which is not multi-byte safe.

Hi Fabien,

Don’t see substr() command in the safeDecodeLabel command.
If you need to output an UTF8 string value, here is my suggestion :

static public function safeDecodeLabel($value)
{
if(empty($value)) {
return $value;
}
$raw = urldecode($value);
$value = htmlspecialchars_decode($raw , ENT_QUOTES);
if(self::$outputHtml)
{
// Pre 5.3
if(!defined(‘ENT_IGNORE’)) {
$style = ENT_QUOTES;
} else {
$style = ENT_QUOTES | ENT_IGNORE;
}
// See changes in 5.4: htmlspecialchars() improvements in PHP 5.4
// Note: at some point we should change ENT_IGNORE to ENT_SUBSTITUTE
$value = htmlspecialchars($value, $style);
}

	return utf8_encode($value);
}

And this work on my PHP 5.2.1 server.