v3.77 - Error Log Bug - no dateLogged

6 posts by 3 authors in: Forums > CMS Builder
Last Post: June 13   (RSS)

By runriot - June 11 - edited: June 11

Hey

Errors logged into _error_log are being inserted without a dateLogged, so they appear as "never" in the UI, as per attached screenshot.

Looking at

function errorDB_addErrorRecord($colsToValues):

and

function _errorlog_logErrorRecord

the dateLogged variable is not set anywhere within either of those.

Would likely make best sense to set it in the:

 //  create log record data
$colsToValues = [

errorlog_functions.php line 313

Cheers!

Rob

Attachments:

devlog.png 16K

Hello Rob,

The dateLogged field is a timestamp database field with a default of the current timestamp. You shouldn't need to set it in the code as MySQL will set it at time of insertion. Are you seeing this with all the error log entries or just certain log entries? Did it just start with your upgrade to v3.77?

Additional information may help us track down the reason. Perhaps somewhere a date is being inserted that is bad and so MySQL is setting it to null or some other value that equates to the UI showing "never". 

Note: If you have the developer console plugin enabled, you could query the error_logs table and see if there are bad values in the dateLogged table. Might offer a clue. :)

Tim Hurd
Senior Web Programmer
Interactivetools.com

Hey,

Yeah I wondered that.

The MySQL type for the dateLogged field is, as reported on admin.php?menu=database&action=editTable&tableName=_error_log is

datetime NOT NULL DEFAULT 0000-00-00 00:00:00

and in the schema file:

  'dateLogged' => [
    'customColumnType' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP',
    'label' => 'Date',
    'type' => 'date',
    'isSystemField' => 1,
    'defaultDate' => '',
    'defaultDateString' => '',
    'showTime' => 1,
    'showSeconds' => 1,
    'actualColumnType' => 'datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\'',
  ],

And all the entries in the MySQL table have dateLogged (and updatedDate) as 0000-00-00 00:00:00.

I see in other schema files, system date fields are:

  'updatedDate' => [
    'type' => 'none',
    'label' => 'Last Updated',
    'isSystemField' => '1',
  ],

So is there perhaps an issue with our schema config for _error_log.schema.php?

This install was recently upgraded from a very old verison (a good year + old) to 3.76 and then 3.77.

Cheers

Rob

Hey Dave

Thanks - and yup, this has fixed it.

Going from:

NULL DEFAULT \'0000-00-00 00:00:00\'

to:

NULL DEFAULT CURRENT_TIMESTAMP

Thanks :-)

Okay, great.  Thanks for the update!

Dave Edis - Senior Developer
interactivetools.com