Skip to content
This repository was archived by the owner on Jun 16, 2022. It is now read-only.

Do not use invalid date value '0000-00-00' #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions NeatlineTimePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function hookInstall()
`creator_id` INT UNSIGNED NOT NULL,
`public` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`featured` TINYINT(1) NOT NULL DEFAULT '0',
`center_date` date NOT NULL default '0000-00-00',
`added` timestamp NOT NULL default '0000-00-00 00:00:00',
`center_date` date NULL,
`added` timestamp NOT NULL default CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
Expand Down Expand Up @@ -124,6 +124,16 @@ public function hookUpgrade($args)
$this->_db->query($sqlNeatlineTimeline);
}
}

if (version_compare($oldversion, '2.1.1', '<')) {
$sql = "
ALTER TABLE `{$this->_db->prefix}neatline_time_timelines`
MODIFY COLUMN `center_date` date NULL,
MODIFY COLUMN `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
";

$this->_db->query($sql);
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions models/NeatlineTimeTimeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected function _validate()
{
$validator = new Zend_Validate_Date(array('format' => 'yyyy-MM-dd'));
if ($this->center_date == '') {
$this->center_date = '0000-00-00';
} elseif ($this->center_date !== '0000-00-00' && !$validator->isValid($this->center_date)) {
$this->center_date = null;
} elseif (isset($this->center_date) && !$validator->isValid($this->center_date)) {
$this->addError(null, __('The center date must be in the format YYYY-MM-DD.'));
}
}
}
}
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
link="http://neatline.org/"
omeka_minimum_version="2.0"
omeka_tested_up_to="2.3"
version="2.1.0"
version="2.1.1"
tags="timelines, chronology"
support_link="http://github.com/scholarslab/NeatlineTime/issues"
omeka_target_version="2.0"
Expand Down
2 changes: 1 addition & 1 deletion views/shared/timelines/_timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<script>
jQuery(document).ready(function($) {
var centerDate = '<?php echo $this->center_date; ?>';
var centerDate = <?php echo json_encode($this->center_date); ?>;

NeatlineTime.loadTimeline(
'<?php echo neatlinetime_timeline_id(); ?>',
Expand Down