Null datetimes and default values - PHP changes
This commit is contained in:
parent
28e7940f00
commit
a2669f6d0a
|
@ -18,6 +18,14 @@ defined('_JEXEC') or die;
|
|||
*/
|
||||
class WeblinkTable extends \JTable
|
||||
{
|
||||
/**
|
||||
* Indicates that columns fully support the NULL value in the database
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Ensure the params and metadata in json encoded in the bind method
|
||||
*
|
||||
|
@ -56,17 +64,16 @@ class WeblinkTable extends \JTable
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function store($updateNulls = false)
|
||||
public function store($updateNulls = true)
|
||||
{
|
||||
$date = \JFactory::getDate();
|
||||
$date = \JFactory::getDate()->toSql();
|
||||
$user = \JFactory::getUser();
|
||||
|
||||
$this->modified = $date->toSql();
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
// Existing item
|
||||
$this->modified_by = $user->id;
|
||||
$this->modified = $date;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -74,25 +81,35 @@ class WeblinkTable extends \JTable
|
|||
// so we don't touch either of these if they are set.
|
||||
if (!(int) $this->created)
|
||||
{
|
||||
$this->created = $date->toSql();
|
||||
$this->created = $date;
|
||||
}
|
||||
|
||||
if (empty($this->created_by))
|
||||
{
|
||||
$this->created_by = $user->id;
|
||||
}
|
||||
|
||||
if (!(int) $this->modified)
|
||||
{
|
||||
$this->modified = $date;
|
||||
}
|
||||
|
||||
if (empty($this->modified_by))
|
||||
{
|
||||
$this->modified_by = $user->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Set publish_up to null date if not set
|
||||
// Set publish_up to null if not set
|
||||
if (!$this->publish_up)
|
||||
{
|
||||
$this->publish_up = $this->getDbo()->getNullDate();
|
||||
$this->publish_up = null;
|
||||
}
|
||||
|
||||
// Set publish_down to null date if not set
|
||||
// Set publish_down to null if not set
|
||||
if (!$this->publish_down)
|
||||
{
|
||||
$this->publish_down = $this->getDbo()->getNullDate();
|
||||
$this->publish_down = null;
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
|
@ -168,7 +185,7 @@ class WeblinkTable extends \JTable
|
|||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up)
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
|
||||
{
|
||||
$this->setError(\JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Com_WeblinksInstallerScript
|
|||
$category->metadesc = '';
|
||||
$category->metakey = '';
|
||||
$category->language = '*';
|
||||
$category->checked_out_time = JFactory::getDbo()->getNullDate();
|
||||
$category->checked_out_time = null;
|
||||
$category->version = 1;
|
||||
$category->hits = 0;
|
||||
$category->modified_user_id = 0;
|
||||
|
|
|
@ -163,13 +163,12 @@ class WeblinksModelCategory extends JModelList
|
|||
$query->where('a.state != -2');
|
||||
|
||||
// Filter by start and end dates.
|
||||
$nullDate = $db->quote($db->getNullDate());
|
||||
$nowDate = $db->quote(JFactory::getDate()->toSql());
|
||||
|
||||
if ($this->getState('filter.publish_date'))
|
||||
{
|
||||
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
|
||||
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
|
||||
$query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')')
|
||||
->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')');
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
|
|
|
@ -110,13 +110,12 @@ class WeblinksModelWeblink extends JModelItem
|
|||
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
|
||||
{
|
||||
// Filter by start and end dates.
|
||||
$nullDate = $db->quote($db->getNullDate());
|
||||
$date = JFactory::getDate();
|
||||
|
||||
$nowDate = $db->quote($date->toSql());
|
||||
|
||||
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
|
||||
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
|
||||
$query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')')
|
||||
->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')');
|
||||
}
|
||||
|
||||
// Filter by published state.
|
||||
|
|
Loading…
Reference in New Issue