Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#1776 closed Bug (fixed)

Installation: detect disabled gzcompress/gzuncompress

Reported by: N3trunn3r Owned by:
Priority: normal Milestone: Piwik 1.1
Component: Core Keywords:
Cc: Sensitive: no

Description

On the Dashboard almost all the Tabs show the same bug.

Here is the phpinfo from the server I am using: http://23.se.gp/phpinfo.php

Warning: gzuncompress() [<a href='function.gzuncompress'>function.gzuncompress</a>]: data error in /data/multiserv/users/452235/projects/1039869/www/piwik/core/Archive/Single.php on line 270

Backtrace -->
#0 Piwik_ErrorHandler(2, gzuncompress() [<a href='function.gzuncompress'>function.gzuncompress</a>]: data error, /data/multiserv/users/452235/projects/1039869/www/piwik/core/Archive/Single.php, 270, Array ([name] => UserSettings_browser,[typeValue] => blob,[table] => piwik_archive_blob_2010_10,[db] => Piwik_Db_Adapter_Pdo_Mysql Object ([] => mysql,[] => Array ([0] => 0,[1] => 1,[2] => 2,[INT] => 0,[INTEGER] => 0,[MEDIUMINT] => 0,[SMALLINT] => 0,[TINYINT] => 0,[BIGINT] => 1,[SERIAL] => 1,[DEC] => 2,[DECIMAL] => 2,[DOUBLE] => 2,[DOUBLE PRECISION] => 2,[FIXED] => 2,[FLOAT] => 2),[] => Zend_Db_Statement_Pdo,[] => Array (),[] => 2,[] => Zend_Db_Profiler Object ([] => Array (),[] => ,[] => ,[] => ),[] => Zend_Db_Profiler,[] => PDO Object (),[] => 0,[] => 1,[] => 1,[] => ),[value] => ))
#1 gzuncompress() called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/Archive/Single.php:270]
#2 Piwik_Archive_Single->get(UserSettings_browser, blob) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/Archive/Single.php:443]
#3 Piwik_Archive_Single->getDataTable(UserSettings_browser) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/plugins/UserSettings/API.php:39]
#4 Piwik_UserSettings_API->getDataTable(UserSettings_browser, 1, day, 2010-10-21) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/plugins/UserSettings/API.php:70]
#5 Piwik_UserSettings_API->getBrowser(1, day, 2010-10-21)
#6 call_user_func_array(Array ([0] => Piwik_UserSettings_API Object (),[1] => getBrowser), Array ([0] => 1,[1] => day,[2] => 2010-10-21)) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/API/Proxy.php:151]
#7 Piwik_API_Proxy->call(Piwik_UserSettings_API, getBrowser, Array ([method] => UserSettings.getBrowser,[format] => original,[filter_limit] => 5,[filter_sort_column] => nb_uniq_visitors,[filter_sort_order] => desc,[module] => UserSettings,[action] => getBrowser,[idSite] => 1,[period] => day,[date] => 2010-10-21)) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/API/Request.php:117]
#8 Piwik_API_Request->process() called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/ViewDataTable.php:367]
#9 Piwik_ViewDataTable->loadDataTableFromAPI() called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/ViewDataTable/HtmlTable.php:75]
#10 Piwik_ViewDataTable_HtmlTable->main() called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/Controller.php:140]
#11 Piwik_Controller->renderView(Piwik_ViewDataTable_HtmlTable Object ([] => ,[arrayDataTable] => ,[] => CoreHome/templates/datatable.tpl,[] => 1,[] => Array ([enable_sort] => 1,[filter_sort_column] => nb_uniq_visitors,[filter_sort_order] => desc,[filter_limit] => 5),[] => Array ([show_goals] => ,[show_search] => ,[show_table] => 1,[show_table_all_columns] => 1,[show_all_views_icons] => 1,[show_export_as_image_icon] => ,[show_exclude_low_population] => ,[show_offset_information] => 1,[show_pagination_control] => 1,[show_footer] => 1,[show_footer_icons] => 1,[apiMethodToRequestDataTable] => UserSettings.getBrowser,[uniqueId] => UserSettingsgetBrowser),[] => 0,[] => ,[] => Array (),[] => getBrowser,[] => UserSettings,[] => ,[] => UserSettings.getBrowser,[] => ,[] => Array ([nb_visits] => Visits,[nb_uniq_visitors] => Unique visitors,[nb_actions] => Actions,[nb_actions_per_visit] => Actions per Visit,[avg_time_on_site] => Avg. Time on Website,[bounce_rate] => Bounce Rate,[conversion_rate] ...
#12 Piwik_UserSettings_Controller->getBrowser()
#13 call_user_func_array(Array ([0] => Piwik_UserSettings_Controller Object ([] => UserSettings,[] => 2010-10-21,[] => Piwik_Date Object ([] => 1287619200,[] => UTC),[] => 1,[] => Piwik_Site Object ([] => 1)),[1] => getBrowser), Array ()) called at [/data/multiserv/users/452235/projects/1039869/www/piwik/core/FrontController.php:126]
#14 Piwik_FrontController->dispatch() called at [/data/multiserv/users/452235/projects/1039869/www/piwik/index.php:60]

Attachments (4)

ZlibDecompress.php (25.8 KB) - added by vipsoft 4 years ago.
HuffmanTable.php (4.3 KB) - added by vipsoft 4 years ago.
1776.patch (591 bytes) - added by vipsoft 4 years ago.
1776-2.patch (3.4 KB) - added by vipsoft 3 years ago.

Download all attachments as: .zip

Change History (28)

comment:1 Changed 4 years ago by vipsoft (robocoder)

  • Milestone set to 1.1 - Piwik 1.1
  • Resolution set to answered
  • Status changed from new to closed

Edit config/config.ini.php, adding 'charset = utf8' to the database connection settings.

comment:2 Changed 4 years ago by N3trunn3r

It is already (Version 1.0)

[database]
host = "localhost"
username = "xxx
password = "xxx"
dbname = "xxx"
tables_prefix = "piwik_"
adapter = "MYSQLI"
port = 3306
charset = "utf8"

comment:3 Changed 4 years ago by vipsoft (robocoder)

Has it always been charset=utf8?

A mangled row was inserted. You'll have to delete the bad row in the archive table. Piwik should regenerate it.

comment:4 Changed 4 years ago by vipsoft (robocoder)

Are you sure you're looking at the right config? Your stacktrace shows PDO_MYSQL while comment:2 shows MYSQLI.

Changed 4 years ago by vipsoft (robocoder)

comment:5 Changed 4 years ago by vipsoft (robocoder)

If you haven't already deleted the affected row in your table...

You can also try the attached patch + .php files (put them in the core/Archive folder). If gzuncompress() fails, it'll try to use Emanuele Iannone's decompression class (based on the official Zlib code).

comment:6 Changed 4 years ago by N3trunn3r

I tried MYSQLI and PDO_MYSQL, each time I used a new database/new installation.
There are no installation errors either, everything is checked green.
charset = "utf8" is always set by default.

I applied the patch (in the old database, and later on new database)
but then it goes "...ZlibDecompress.php on line 174..." which is
"trigger_error("Out of input", E_USER_ERROR);"

"Last visitor graph" works, "Live visitors" works but not "List of keywords" or for example "Length of Visits".

Any more clues?

comment:7 Changed 3 years ago by vipsoft (robocoder)

What version of mysql server are you using?

comment:8 Changed 3 years ago by vipsoft (robocoder)

My only other thought is to use mysql's compress/uncompress functions ... this would any encoding errors between php and mysql server.

comment:9 Changed 3 years ago by N3trunn3r

MYSQL version is: 5.0.51a-24+lenny4-log

I think I just use go for another server.

Thanks for the great help!

comment:10 Changed 3 years ago by vipsoft (robocoder)

5.0.51a is old and buggy. Upgrading mysql generally won't hurt.

Can you check your my.cnf for max_allowed_packet? If this is set too low, I suspect the INSERT fails (eg blob is truncated), which would explain the data error when we SELECT and gzuncompress).

comment:11 Changed 3 years ago by N3trunn3r

max allowed packet = 16,776,192

Changed 3 years ago by vipsoft (robocoder)

comment:12 Changed 3 years ago by vipsoft (robocoder)

This second patch uses MySQL's native compress/uncompress functions per comment:8.

comment:13 Changed 3 years ago by N3trunn3r

Wahoo it works!

This is what I call service! Thanks again.
Who needs Google anyway? ;)

comment:14 Changed 3 years ago by vipsoft (robocoder)

  • Milestone changed from 1.1 - Piwik 1.1 to Features requests 1.x or 2.x
  • Resolution answered deleted
  • Status changed from closed to reopened
  • Summary changed from gzuncompress in Single.php on line 270 to MySQL: use built-in compress/uncompress functions to workaround encoding errors

We still don't know what the exact cause is, since it works "as-is" usually. This may not make it into Piwik 1.1as it needs changes to the Installer and adapters, and affects the db abstraction in #1368.

comment:15 Changed 3 years ago by vipsoft (robocoder)

  • Summary changed from MySQL: use built-in compress/uncompress functions to workaround encoding errors to MySQL: use built-in compress/uncompress functions to workaround disabled gzcompress/gzuncompress

I took another look at your phpinfo. Was gzcompress always disabled on your system?

comment:16 Changed 3 years ago by N3trunn3r

Yes it was.
My mistake, I didn't look into it.

A solution would be to expand the System Check in the installation.
At least until there is a better way.

comment:17 Changed 3 years ago by matt (mattab)

What should we test for in order to prevent this bug then? thx

comment:18 Changed 3 years ago by N3trunn3r

Check if gzcompress is enabled on the server.

comment:19 Changed 3 years ago by vipsoft (robocoder)

  • Milestone changed from Features requests 1.x or 2.x to 1.1 - Piwik 1.1

Ok. I was thinking of a custom adapter that would use the built-in MySQL functions, but let's go with the quick fix of detecting this at installation.

comment:20 Changed 3 years ago by vipsoft (robocoder)

  • Summary changed from MySQL: use built-in compress/uncompress functions to workaround disabled gzcompress/gzuncompress to Installation: detect disabled gzcompress/gzuncompress

comment:21 Changed 3 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [3321]) fixes #1776

comment:22 Changed 3 years ago by matt (mattab)

Looking at the error message "function.gzuncompress: data error", it makes me believe that the function was properly defined, but just didn't work as expected. Otherwise the error message is more like: 'Fatal error: Call to undefined function'

So I don't think the SVN commit would really fix this issue - thoughts?

comment:23 Changed 3 years ago by vipsoft (robocoder)

That's because gzcompress was disabled while gzuncompress was enabled.

We're good here.

comment:24 Changed 3 years ago by matt (mattab)

Thanks, good stuff vipsoft!

Note: See TracTickets for help on using tickets.