Login!
Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#296 — Cannot modify header information error if visitor logging on

Attached to Project — MODx
Opened by doze (doze) - Sunday, 05 March 2006, 07:19PM
Last edited by Ryan Thrash (rthrash) - Saturday, 29 July 2006, 02:57PM
Task Type Bug Report
Category Core Distribution
Status Closed
Assigned To Jason Coward (opengeek)
Operating System All
Severity High
Priority Normal
Reported Version 0.9.1
Due in Version 0.9.5
Due Date Undecided
Percent Complete 100%

Details

In some server enviroments, if visitor logging is on, it will produce parse error on the first page load at every visit to the site (when user has a new session).

If the visitor logging is set to be off, there aren't any parse errors visible at front end. But if the visitor logging is on, there will be this error at the page footer at the first page load:

Error: Cannot modify header information - headers already sent
Error type/ Nr.: Warning - 2
File: /www/03/net/modx/manager/includes/document.parser.class.inc.php
Line: 416
Line 416 source: header($header);

There is probably an error somewhere in the visitor logging code that will produce the following error in some server enviroments:

MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - Duplicate entry '2147483647' for key 1 »
SQL: INSERT INTO `enDB`.modx_log_user_agents(id, data) VALUES('3767326138', 'Firefox/1.5.0.1')

And this is sent after the headers are allready out, so there will be the "headers allready sent" error visible..

My server specs:

MODx: 0.9.1 Out-of-the-Box, only installed
OS: Debian 3.1, Linux 2.6 (x86_64)
WWW: Apache 1.3
PHP: PHP 4.4.1 (+gd 2.0, curl, ctype, libxml)
SQL: MySQL 4.1.11

More information & discuss here: http://modxcms.com/forums/index.php/topic,2956.0.html
This task depends upon

This task blocks these from closing
Closed by  Ryan Thrash (rthrash)
Saturday, 30 December 2006, 11:28AM
Reason for closing:  Implemented
Additional comments about closing:  stats tracking removed so should be fixed
Comment by Stijn Gielis (Gust) - Sunday, 02 April 2006, 07:11AM
having the same problem on different sites... See also http://modxcms.com/forums/index.php/topic,2956.msg26657.html#msg26657 and messages below.

Comment by David Molliere (davidm) - Tuesday, 25 April 2006, 05:25AM
Also had the same problem, but after a transfer from one host to another so my guess is it's probably host related

Here is the config :
Apache 1.3
MySQL 3.23.43
PHP Version 4.4.2

If full phpinfo() is needed mail me

Comment by Jason Coward (opengeek) - Thursday, 27 April 2006, 08:13PM
We are removing the native visitor logging inherited from Etomite as of the 0.9.5 release, in favor of integration with slimstat.

Comment by Auzzie (Auz) - Saturday, 09 September 2006, 02:01PM
The problem happens because its inserting a numerical ID which can be too large for the field type.

In modx_log_hosts the id is of type int(11), which has a max value of 2147483647, and the crc32() of the host name can result in number larger. Both are number of 4bytes, but the db is signed, halfing the max value. This makes this error only intermittent, and depending on which host is viewing the page :) nasty.

The fix for this is to change the type to be unsigned (or just make it a mediumint)

So in setup.sql, line 85 should be changed from:

CREATE TABLE IF NOT EXISTS `{PREFIX}log_hosts` (
`id` int(11) NOT NULL default '0',
`data` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=InnoDB COMMENT='Contains visitor statistics.';

to:

CREATE TABLE IF NOT EXISTS `{PREFIX}log_hosts` (
`id` int UNSIGNED NOT NULL default '0',
`data` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=InnoDB COMMENT='Contains visitor statistics.';

of course this only helps on new installs... one would have to add an alter command to fix it on existing setups:

ALTER TABLE `modx_log_hosts` CHANGE `id` `id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';

assuming its got the modx prefix that is.

hope this helps
-auz


Comment by Auzzie (Auz) - Saturday, 09 September 2006, 07:26PM
Oops, well, it seems that the php crc32 function can return unsigned integers. So this fix will not work so well. I guess then one would have to use bigint or use a different crc32 function which converts the crc to an unsigned version. The latter one would be preferred since it used the database more efficiently (it would still need to be changed to unsigned) but does require altering the code and the db, instead of just the db.

I've also noticed this problem in a few other places in the logs section of the code, which is I guess why the suggested solution has been to turn it off.

-auz