Upgrading to Piwik 1.12: :)-D

After upgrading Piwik 1.1.11 to 1.12, I receive the same error message than last time :

[i][size=small]There is an error. Please report the message (Piwik 1.12) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning: htmlspecialchars() [function.htmlspecialchars]: Invalid multibyte sequence in argument in /home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php on line 52

Backtrace -->

#0 Piwik_ErrorHandler(…) called at [:]
#1 htmlspecialchars(…) called at [/home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php:52]
#2 Piwik_DataTable_Filter_SafeDecodeLabel::safeDecodeLabel(…) called at [/home/www/piwik/core/DataTable/Filter/SafeDecodeLabel.php:67]
#3 Piwik_DataTable_Filter_SafeDecodeLabel->filter(…) called at [/home/www/piwik/core/DataTable.php:390]
#4 Piwik_DataTable->filter(…) called at [/home/www/piwik/core/DataTable.php:415]
#5 Piwik_DataTable->applyQueuedFilters(…) called at [/home/www/piwik/core/API/ResponseBuilder.php:281]
#6 Piwik_API_ResponseBuilder->handleDataTable(…) called at [/home/www/piwik/core/API/ResponseBuilder.php:77]
#7 Piwik_API_ResponseBuilder->getResponse(…) called at [/home/www/piwik/core/API/Request.php:147]
#8 Piwik_API_Request->process(…) called at [/home/www/piwik/core/ViewDataTable.php:423]
#9 Piwik_ViewDataTable->loadDataTableFromAPI(…) called at [/home/www/piwik/core/ViewDataTable/HtmlTable.php:79]
#10 Piwik_ViewDataTable_HtmlTable->main(…) called at [/home/www/piwik/plugins/Actions/Controller.php:475]
#11 Piwik_Actions_Controller->configureGenericViewActions(…) called at [/home/www/piwik/plugins/Actions/Controller.php:420]
#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:125]
#15 Piwik_FrontController->dispatch(…) called at [/home/www/piwik/index.php:47][/size][/i]

This problem was mentionned after upgrading Piwik to 1.1.11 in this thread :
http://forum.piwik.org/read.php?2,101866,101866

PHP Version running Piwik : 5.2.6
Piwik language label : french

Here is a correction for your SafeDecodeLabel.php class :

[i][size=small]<?php
/**

/**

  • @package Piwik
  • @subpackage Piwik_DataTable
    */

function handleError($errno, $errstr, $errfile, $errline, array $errcontext)
{
// error was suppressed with the @-operator
if (0 === error_reporting()) {
return false;
}

throw new ErrorException($errstr, 0, $errno, $errfile, $errline);

}
set_error_handler(‘handleError’);

class Piwik_DataTable_Filter_SafeDecodeLabel extends Piwik_DataTable_Filter
{
private $columnToDecode;
static private $outputHtml = true;

/**
 * @param Piwik_DataTable $table
 */
public function __construct($table)
{
    parent::__construct($table);
    $this->columnToDecode = 'label';
}

/**
 * Decodes the given value
 *
 * @param string $value
 * @return mixed|string
 */
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: http://nikic.github.com/2012/01/28/htmlspecialchars-improvements-in-PHP-5-4.html
        // Note: at some point we should change ENT_IGNORE to ENT_SUBSTITUTE
        try
        { $value = htmlspecialchars($value, $style, 'UTF-8'); }
        catch (ErrorException $e)
		{
			//compatibility with PHP < 5.3
			$value = htmlspecialchars($value, $style);
		}
    }
    return $value;
}

/**
 * Decodes all columns of the given data table
 *
 * @param Piwik_DataTable $table
 */
public function filter($table)
{
    foreach ($table->getRows() as $row) {
        $value = $row->getColumn($this->columnToDecode);
        if ($value !== false) {
            $value = self::safeDecodeLabel($value);
            $row->setColumn($this->columnToDecode, $value);

            $this->filterSubTable($row);
        }
    }
}

}[/size][/i]