Inconsistency in Joomla logger - Joomla! Forum - community, help and support
hi guys,
in joomla 2.5 inconsestency between 2 files addentry(jlogentry $entry) function :
in first ( database ), can see :
it call function :
$entry->date should jdate object, sometime not !
because in second file (formattedtext), jdate object converted before gmt date :
so, choice required...
may should test if date object before try use tosql() on in ?
i hope it's you,
congratulation joomla.
have day !
tristan.
in joomla 2.5 inconsestency between 2 files addentry(jlogentry $entry) function :
- libraries/joomla/log/loggers/database.php
libraries/joomla/log/loggers/formattedtext.php
in first ( database ), can see :
code: select all
/**
* method add entry log.
*
* @param jlogentry $entry log entry object add log.
*
* @return void
*
* @since 11.1
*/
public function addentry(jlogentry $entry)
{
// connect database if not connected.
if (empty($this->dbo))
{
$this->connect();
}
// convert date.
$entry->date = $entry->date->tosql(); <=== problematic line
$this->dbo->insertobject($this->table, $entry);
}
it call function :
code: select all
/**
* gets date sql datetime string.
*
* @param boolean $local true return date string in local time zone, false return in gmt.
* @param jdatabase $dbo database driver or null use jfactory::getdbo()
*
* @return string the date string in sql datetime format.
*
* @link http://dev.mysql.com/doc/refman/5.0/en/datetime.html
* @since 11.4
*/
public function tosql($local = false, jdatabase $dbo = null)
{
if ($dbo === null)
{
$dbo = jfactory::getdbo();
}
return $this->format($dbo->getdateformat(), $local, false);
}
$entry->date should jdate object, sometime not !
because in second file (formattedtext), jdate object converted before gmt date :
code: select all
/**
* method add entry log.
*
* @param jlogentry $entry log entry object add log.
*
* @return boolean true on success.
*
* @since 11.1
* @throws logexception
*/
public function addentry(jlogentry $entry)
{
// initialise file if not done.
if (!is_resource($this->file))
{
$this->initfile();
}
// set default field values if not set.
if (!isset($entry->clientip))
{
// check proxies well.
if (isset($_server['remote_addr']))
{
$entry->clientip = $_server['remote_addr'];
}
elseif (isset($_server['http_x_forwarded_for']))
{
$entry->clientip = $_server['http_x_forwarded_for'];
}
elseif (isset($_server['http_client_ip']))
{
$entry->clientip = $_server['http_client_ip'];
}
}
// if time field missing or date field isn't date need rework it.
if ((strlen($entry->date) != 10) || !isset($entry->time))
{
// date , time strings in gmt.
$entry->datetime = $entry->date->toiso8601();
$entry->time = $entry->date->format('h:i:s', false);
$entry->date = $entry->date->format('y-m-d', false); <=== problematic line
}
// list of entry keys , make sure upper case.
$tmp = array_change_key_case(get_object_vars($entry), case_upper);
// decode entry priority english string.
$tmp['priority'] = $this->priorities[$entry->priority];
// fill in field data line.
$line = $this->format;
foreach ($this->fields $field)
{
$line = str_replace('{' . $field . '}', (isset($tmp[$field])) ? $tmp[$field] : '-', $line);
}
// write new entry file.
if (!fputs($this->file, $line . "\n"))
{
throw new logexception;
}
}
so, choice required...
may should test if date object before try use tosql() on in ?
code: select all
if( gettype($entry->date) == "jdate" )
$entry->date = $entry->date->tosql();
else
// nothing it's work because date still date !
i hope it's you,
congratulation joomla.
have day !
tristan.
Comments
Post a Comment