luciorota wrote:
The bug is the result of an incorrect use of the function strtotime(), it must have a format in English to work...
BUGFIX
file: publisher\class\item.php, line 1061
replace$localTimestamp = strtotime($resDate['date']) + $resTime['time'];
with$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resDate['date']);
$dateTimeObj->setTime(0, 0, 0);
$localTimestamp = $dateTimeObj->getTimestamp() + $resTime['time'];
file: publisher\class\item.php, line 1088
replace$localTimestamp = strtotime($resExDate['date']) + $resExTime['time'];
with$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resExDate['date']);
$dateTimeObj->setTime(0, 0, 0);
$localTimestamp = $dateTimeObj->getTimestamp() + $resExTime['time'];
Good job! / Buon lavoro!
$localTimestamp = strtotime($resDate['date']) + $resTime['time']; $dateTimeObj = DateTime::createFromFormat(_SHORTDATESTRING, $resDate['date']);
$dateTimeObj->setTime(0, 0, 0);
$localTimestamp = $dateTimeObj->getTimestamp() + $resTime['time']; $localTimestamp = strtotime($resExDate['date']) + $resExTime['time']; $dateTimeObj = DateTime::createFromFormat(_SHORTDATESTRING, $resExDate['date']);
$dateTimeObj->setTime(0, 0, 0);
$localTimestamp = $dateTimeObj->getTimestamp() + $resExTime['time'];
define('_DBDATESTRING',"Y-m-d");
define('_DBTIMESTRING',"H:i:s");
define('_DBTIMESTAMPSTRING',"Y-m-d H:i:s");
One potential problem is that the XoopsObject has no internal knowledge of it's primary key, so while the object is marked new, it still has any auto-increment PK set. You can work around this issue by doing a $newObject->destroyVars('key-variable-name'); to clean up after a clone.

abstract class ModuleXoopsObject extends XoopsObject {
/**
* @var moduleHelper
* @access private
*/
private $moduleHelper = null;
/**
* constructor
*/
public function __construct()
{
$this->moduleHelper = XmfModuleHelper::getHelper('module');
$this->db = XoopsDatabaseFactory::getDatabaseConnection();
//
parent::__construct();
}
/**
* assign a value to a variable (also null is allowed)
*
* @access public
* @param string $key name of the variable to assign
* @param mixed $value value to assign
* @param bool $not_gpc
*/
public function setVar($key, $value, $not_gpc = false)
{
if (!empty($key) && isset($value) && isset($this->vars[$key])) {
$this->vars[$key]['value'] =& $value;
$this->vars[$key]['not_gpc'] = $not_gpc;
$this->vars[$key]['changed'] = true;
$this->setDirty();
}
if (!empty($key) && is_null($value) && isset($this->vars[$key])) {
$this->vars[$key]['value'] = null;
$this->vars[$key]['not_gpc'] = $not_gpc;
$this->vars[$key]['changed'] = false;
$this->setDirty();
}
}
}
abstract class ModuleXoopsObjectHandler extends XoopsPersistableObjectHandler
{
/**
* @var moduleHelper
* @access private
*/
private $moduleHelper = null;
/**
* @param null|object $db
*/
public function __construct($db = null, $table = '', $className = '', $keyName = '', $identifierName = '')
{
parent::__construct($db, $table, $className, $keyName, $identifierName);
$this->moduleHelper = XmfModuleHelper::getHelper('module');
}
/**
* insert an object into the database
*
* @param XoopsObject $object {@link XoopsObject} reference to object
* @param bool $force flag to force the query execution despite security settings
* @return mixed object ID
*/
public function insert(XoopsObject $object, $force = true)
{
$ret = parent::insert($object, $force);
// handle null values
$queryFunc = empty($force) ? 'query' : 'queryF';
$vars = $object->getVars();
foreach ($vars as $key => $value) {
if (is_null($value['value'])) {
$sql = "UPDATE `{$this->table}` SET `{$key}` = NULL WHERE `{$this->keyName}` = {$this->db->quote($object->getVar($this->keyName))}";
if (!$result = $this->db->{$queryFunc}($sql)) {
//return false;
}
}
}
return $ret;
}
}