Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
BUG: refs #1025. Fixing date formating and whatnot make MySQL happy.
Browse files Browse the repository at this point in the history
MySQL beyond 5.5 sets InnoDB as the default storage engine. This is great for
performance, but InnoDB is more picky about types, defaults and keys.
  • Loading branch information
cpatrick committed Aug 23, 2013
1 parent bea07a2 commit 94ce00b
Show file tree
Hide file tree
Showing 58 changed files with 111 additions and 112 deletions.
4 changes: 2 additions & 2 deletions core/AppController.php
Expand Up @@ -147,7 +147,7 @@ public function preDispatch()
$this->view->needUpgrade = true;
}
$errorlogModel = MidasLoader::loadModel('Errorlog');
$count = $errorlogModel->countSince(date('c', strtotime('-24 hour')), array(MIDAS_PRIORITY_CRITICAL, MIDAS_PRIORITY_WARNING));
$count = $errorlogModel->countSince(date("Y-m-d H:i:s", strtotime('-24 hour')), array(MIDAS_PRIORITY_CRITICAL, MIDAS_PRIORITY_WARNING));

if($count > 5)
{
Expand Down Expand Up @@ -372,7 +372,7 @@ private function _logRequest()
{
$fc = Zend_Controller_Front::getInstance();

$entry = date('c')."\n";
$entry = date("Y-m-d H:i:s")."\n";
if(isset($_SERVER['REMOTE_ADDR']))
{
$entry .= 'IP='.$_SERVER['REMOTE_ADDR']."\n";
Expand Down
8 changes: 4 additions & 4 deletions core/controllers/AdminController.php
Expand Up @@ -361,19 +361,19 @@ function showlogAction()
$offset = $this->_getParam('offset');
if(!isset($start) || empty($start))
{
$start = date('c', strtotime('-24 hour'));
$start = date("Y-m-d H:i:s", strtotime('-24 hour'));
}
else
{
$start = date('c', strtotime($start));
$start = date("Y-m-d H:i:s", strtotime($start));
}
if(!isset($end) || empty($end))
{
$end = date('c');
$end = date("Y-m-d H:i:s");
}
else
{
$end = date('c', strtotime($end));
$end = date("Y-m-d H:i:s", strtotime($end));
}
if(!isset($module) || empty($module))
{
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/ImportController.php
Expand Up @@ -179,7 +179,7 @@ private function _recursiveParseDirectory($path, $currentdir)
$child = new FolderDao;
$child->setName($fileInfo->getFilename());
$child->setParentId($currentdir->getFolderId());
$child->setDateCreation(date('c'));
$child->setDateCreation(date("Y-m-d H:i:s"));
$child->setDescription('');
$this->Folder->save($child);
$this->Folderpolicyuser->createPolicy($this->userSession->Dao,
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/components/ApisystemComponent.php
Expand Up @@ -316,7 +316,7 @@ function uploadGeneratetoken($args)
$revision = new ItemRevisionDao();
$revision->setChanges('Initial revision');
$revision->setUser_id($userDao->getKey());
$revision->setDate(date('c'));
$revision->setDate(date("Y-m-d H:i:s"));
$revision->setLicenseId(null);
$itemModel->addRevision($item, $revision);
}
Expand Down
6 changes: 3 additions & 3 deletions core/controllers/components/UploadComponent.php
Expand Up @@ -163,7 +163,7 @@ public function createLinkItem($userDao, $name, $url, $parent = null)
$itemRevisionDao = new ItemRevisionDao;
$itemRevisionDao->setChanges('Initial revision');
$itemRevisionDao->setUser_id($userDao->getKey());
$itemRevisionDao->setDate(date('c'));
$itemRevisionDao->setDate(date("Y-m-d H:i:s"));
$itemRevisionDao->setLicenseId(null);
$itemModel->addRevision($item, $itemRevisionDao);

Expand Down Expand Up @@ -257,7 +257,7 @@ public function createUploadedItem($userDao, $name, $path, $parent = null, $lice
$itemRevisionDao = new ItemRevisionDao;
$itemRevisionDao->setChanges($changes);
$itemRevisionDao->setUser_id($userDao->getKey());
$itemRevisionDao->setDate(date('c'));
$itemRevisionDao->setDate(date("Y-m-d H:i:s"));
$itemRevisionDao->setLicenseId($license);
$itemModel->addRevision($item, $itemRevisionDao);

Expand Down Expand Up @@ -344,7 +344,7 @@ public function createNewRevision($userDao, $name, $path, $changes, $itemId, $it
$itemRevisionDao = new ItemRevisionDao;
$itemRevisionDao->setChanges($changes);
$itemRevisionDao->setUser_id($userDao->getKey());
$itemRevisionDao->setDate(date('c'));
$itemRevisionDao->setDate(date("Y-m-d H:i:s"));
$itemRevisionDao->setLicenseId($license);
$itemModel->addRevision($item, $itemRevisionDao);

Expand Down
12 changes: 5 additions & 7 deletions core/database/mysql/3.2.0.sql
Expand Up @@ -43,7 +43,7 @@ CREATE TABLE IF NOT EXISTS `community` (
`privatefolder_id` bigint(20) DEFAULT NULL,
`admingroup_id` bigint(20) DEFAULT NULL,
`moderatorgroup_id` bigint(20) DEFAULT NULL,
`membergroup_id` bigint(20) NOT NULL,
`membergroup_id` bigint(20) NOT NULL DEFAULT 0,
`view` bigint(20) NOT NULL DEFAULT '0',
`can_join` int(11) DEFAULT '0',
`uuid` varchar(255) DEFAULT '',
Expand Down Expand Up @@ -75,7 +75,7 @@ CREATE TABLE IF NOT EXISTS `errorlog` (
`priority` tinyint(4) NOT NULL,
`module` varchar(255) NOT NULL,
`message` text NOT NULL,
`datetime` timestamp NULL DEFAULT NULL,
`datetime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`errorlog_id`)
) DEFAULT CHARSET=utf8;

Expand Down Expand Up @@ -152,7 +152,7 @@ CREATE TABLE IF NOT EXISTS `folder` (
`teaser` varchar(250) DEFAULT '',
`privacy_status` int(11) DEFAULT '0',
`uuid` varchar(255) DEFAULT '',
`date_creation` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`folder_id`),
KEY `parent_id` (`parent_id`)
) DEFAULT CHARSET=utf8 COMMENT='Describes a directory';
Expand Down Expand Up @@ -339,8 +339,7 @@ CREATE TABLE IF NOT EXISTS `metadatadocumentvalue` (
`metadatavalue_id` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`metadatavalue_id`),
KEY `metadata_id` (`metadata_id`),
KEY `itemrevision_id` (`itemrevision_id`),
KEY `value` (`value`(1000))
KEY `itemrevision_id` (`itemrevision_id`)
) DEFAULT CHARSET=utf8;

-- --------------------------------------------------------
Expand All @@ -355,8 +354,7 @@ CREATE TABLE IF NOT EXISTS `metadatavalue` (
`value` varchar(1024) NOT NULL,
`metadatavalue_id` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`metadatavalue_id`),
KEY `metadata_id` (`metadata_id`,`itemrevision_id`),
KEY `value` (`value`(1000))
KEY `metadata_id` (`metadata_id`,`itemrevision_id`)
) DEFAULT CHARSET=utf8;

-- --------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions core/database/upgrade/3.2.13.php
Expand Up @@ -19,7 +19,7 @@ public function mysql()
`apikey` varchar(40) NOT NULL,
`application_name` varchar(256) NOT NULL,
`token_expiration_time` int(11) NOT NULL,
`creation_date` timestamp NULL DEFAULT NULL,
`creation_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`userapi_id`)
)");
$this->db->query("RENAME TABLE `api_userapi` to `userapi`");
Expand All @@ -28,7 +28,7 @@ public function mysql()
`token_id` bigint(20) NOT NULL AUTO_INCREMENT,
`userapi_id` bigint(20) NOT NULL,
`token` varchar(40) NOT NULL,
`expiration_date` timestamp NULL DEFAULT NULL,
`expiration_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`token_id`)
)");
$this->db->query("RENAME TABLE `api_token` to `token`");
Expand All @@ -52,7 +52,7 @@ public function pgsql()
token_id serial PRIMARY KEY,
userapi_id bigint NOT NULL,
token character varying(40) NOT NULL,
expiration_date timestamp without time zone
expiration_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP
)");
$this->db->query("ALTER TABLE api_token_token_id_seq RENAME TO token_token_id_seq");
$this->db->query("ALTER TABLE api_token RENAME TO token");
Expand Down
4 changes: 2 additions & 2 deletions core/database/upgrade/3.2.2.php
Expand Up @@ -133,8 +133,8 @@ public function mysql()
// Create the license table
$this->db->query("CREATE TABLE `license` (
`license_id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` TEXT NOT NULL DEFAULT '',
`fulltext` TEXT NOT NULL DEFAULT '',
`name` TEXT NOT NULL,
`fulltext` TEXT NOT NULL,
PRIMARY KEY (`license_id`)
)");

Expand Down
4 changes: 2 additions & 2 deletions core/database/upgrade/3.2.7.php
Expand Up @@ -14,7 +14,7 @@ public function mysql()
{
$this->db->query("CREATE TABLE `progress` (
`progress_id` bigint(20) NOT NULL AUTO_INCREMENT,
`message` TEXT NOT NULL DEFAULT '',
`message` TEXT NOT NULL,
`current` bigint(20) NOT NULL,
`maximum` bigint(20) NOT NULL,
`date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -27,7 +27,7 @@ public function pgsql()
{
$this->db->query("CREATE TABLE progress (
progress_id serial PRIMARY KEY,
message TEXT NOT NULL DEFAULT '',
message TEXT NOT NULL,
current bigint NOT NULL,
maximum bigint NOT NULL,
date_creation timestamp without time zone NOT NULL DEFAULT now(),
Expand Down
6 changes: 3 additions & 3 deletions core/models/base/ActivedownloadModelBase.php
Expand Up @@ -71,8 +71,8 @@ public function acquireLock()
}

$activeDownload = MidasLoader::newDao('ActivedownloadDao');
$activeDownload->setDateCreation(date('c'));
$activeDownload->setLastUpdate(date('c'));
$activeDownload->setDateCreation(date("Y-m-d H:i:s"));
$activeDownload->setLastUpdate(date("Y-m-d H:i:s"));
$activeDownload->setIp($ip);
$this->save($activeDownload);

Expand All @@ -86,7 +86,7 @@ public function acquireLock()
*/
public function updateLock($lockDao)
{
$lockDao->setLastUpdate(date('c'));
$lockDao->setLastUpdate(date("Y-m-d H:i:s"));
$this->save($lockDao);
}

Expand Down
4 changes: 2 additions & 2 deletions core/models/base/BitstreamModelBase.php
Expand Up @@ -56,7 +56,7 @@ public function save($dao)
{
if(!isset($dao->date) || empty($dao->date))
{
$dao->setDate(date('c'));
$dao->setDate(date("Y-m-d H:i:s"));
}
parent::save($dao);
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public function createThumbnail($assetstore, $tempThumbnailFile)
$bitstreamDao->setItemrevisionId(-1); //-1 indicates this does not belong to any revision
$bitstreamDao->setMimetype('image/jpeg');
$bitstreamDao->setSizebytes(filesize($tempThumbnailFile));
$bitstreamDao->setDate(date('c'));
$bitstreamDao->setDate(date("Y-m-d H:i:s"));
$bitstreamDao->setChecksum($md5);

$existing = $this->getByChecksum($md5);
Expand Down
2 changes: 1 addition & 1 deletion core/models/base/CommunityModelBase.php
Expand Up @@ -133,7 +133,7 @@ function createCommunity($name, $description, $privacy, $user, $canJoin = null,
$communityDao->setName($name);
$communityDao->setDescription($description);
$communityDao->setPrivacy($privacy);
$communityDao->setCreation(date('c'));
$communityDao->setCreation(date("Y-m-d H:i:s"));
$communityDao->setCanJoin($canJoin);
$communityDao->setUuid($uuid);
$this->save($communityDao);
Expand Down
4 changes: 2 additions & 2 deletions core/models/base/FeedModelBase.php
Expand Up @@ -81,7 +81,7 @@ function createFeed($userDao, $type, $ressource, $communityDao = null)
$feed = MidasLoader::newDao('FeedDao');
$feed->setUserId($userDao->getKey());
$feed->setType($type);
$feed->setDate(date('c'));
$feed->setDate(date("Y-m-d H:i:s"));
switch($type)
{
case MIDAS_FEED_CREATE_COMMUNITY:
Expand Down Expand Up @@ -151,4 +151,4 @@ function createFeed($userDao, $type, $ressource, $communityDao = null)
return $feed;
} // end createFeed()

} // end class FeedModelBase
} // end class FeedModelBase
8 changes: 4 additions & 4 deletions core/models/base/ItemModelBase.php
Expand Up @@ -92,13 +92,13 @@ public function save($dao, $metadataChanged = true)
}
if(!isset($dao->date_creation) || empty($dao->date_creation))
{
$dao->setDateCreation(date('c'));
$dao->setDateCreation(date("Y-m-d H:i:s"));
}
if(!isset($dao->type) || empty($dao->type))
{
$dao->setType(0);
}
$dao->setDateUpdate(date('c'));
$dao->setDateUpdate(date("Y-m-d H:i:s"));
$dao->setDescription(UtilityComponent::filterHtmlTags($dao->getDescription()));
parent::save($dao);

Expand Down Expand Up @@ -215,8 +215,8 @@ function duplicateItem($itemDao, $userDao, $folderDao)
$newItem = $this->createItem($name, $description, $folderDao);
$newItem->setType($itemDao->getType());
$newItem->setSizebytes($itemDao->getSizebytes());
$newItem->setDateCreation(date('c'));
$newItem->setDateUpdate(date('c'));
$newItem->setDateCreation(date("Y-m-d H:i:s"));
$newItem->setDateUpdate(date("Y-m-d H:i:s"));

$thumbnailId = $itemDao->getThumbnailId();
if($thumbnailId !== null)
Expand Down
6 changes: 3 additions & 3 deletions core/models/base/ItemRevisionModelBase.php
Expand Up @@ -61,12 +61,12 @@ function addBitstream($itemRevisionDao, $bitstreamDao)
$bitstreamDao->setItemrevisionId($itemRevisionDao->getItemrevisionId());

// Save the bistream
$bitstreamDao->setDate(date('c'));
$bitstreamDao->setDate(date("Y-m-d H:i:s"));
$BitstreamModel->save($bitstreamDao);

$item = $itemRevisionDao->getItem($bitstreamDao);
$item->setSizebytes($this->getSize($itemRevisionDao));
$item->setDateUpdate(date('c'));
$item->setDateUpdate(date("Y-m-d H:i:s"));

Zend_Registry::get('notifier')->notifyEvent('EVENT_CORE_CREATE_THUMBNAIL', array($item));
$notifications = Zend_Registry::get('notifier')->getNotifications();
Expand Down Expand Up @@ -173,7 +173,7 @@ public function save($dao)
}
if(!isset($dao->date) || empty($dao->date))
{
$dao->setDate(date('c'));
$dao->setDate(date("Y-m-d H:i:s"));
}
parent::save($dao);
}
Expand Down
2 changes: 1 addition & 1 deletion core/models/base/NewUserInvitationModelBase.php
Expand Up @@ -69,7 +69,7 @@ public function createInvitation($email, $group, $inviter)
$newUserInvitation->setInviterId($inviter->getKey());
$newUserInvitation->setGroupId($group->getKey());
$newUserInvitation->setCommunityId($group->getCommunityId());
$newUserInvitation->setDateCreation(date('c'));
$newUserInvitation->setDateCreation(date("Y-m-d H:i:s"));

$userModel = MidasLoader::loadModel('User');
$existingUser = $userModel->getByEmail($email);
Expand Down
2 changes: 1 addition & 1 deletion core/models/base/PendingUserModelBase.php
Expand Up @@ -63,7 +63,7 @@ public function createPendingUser($email, $firstName, $lastName, $password)
$pendingUser->setFirstname($firstName);
$pendingUser->setLastname($lastName);
$pendingUser->setSalt($userSalt);
$pendingUser->setDateCreation(date('c'));
$pendingUser->setDateCreation(date("Y-m-d H:i:s"));

$userModel = MidasLoader::loadModel('User');
$existingUser = $userModel->getByEmail($email);
Expand Down
6 changes: 3 additions & 3 deletions core/models/base/ProgressModelBase.php
Expand Up @@ -62,8 +62,8 @@ public function createProgress($max = 0, $message = '')
$progress->setCurrent(0);
$progress->setMaximum($max);
$progress->setMessage($message);
$progress->setDateCreation(date('c'));
$progress->setLastUpdate(date('c'));
$progress->setDateCreation(date("Y-m-d H:i:s"));
$progress->setLastUpdate(date("Y-m-d H:i:s"));

$this->save($progress);
return $progress;
Expand All @@ -78,7 +78,7 @@ public function updateProgress($progressDao, $currentValue, $message = '')
{
$progressDao->setCurrent((int)$currentValue);
$progressDao->setMessage($message);
$progressDao->setLastUpdate(date('c'));
$progressDao->setLastUpdate(date("Y-m-d H:i:s"));

$this->save($progressDao);
}
Expand Down
2 changes: 1 addition & 1 deletion core/models/base/UserModelBase.php
Expand Up @@ -239,7 +239,7 @@ public function createUser($email, $password, $firstname, $lastname, $admin = 0,
$userDao->setFirstname(ucfirst($firstname));
$userDao->setLastname(ucfirst($lastname));
$userDao->setEmail(strtolower($email));
$userDao->setCreation(date('c'));
$userDao->setCreation(date("Y-m-d H:i:s"));
$userDao->setHashAlg('sha256');
$userDao->setAdmin($admin);
if($password)
Expand Down
4 changes: 2 additions & 2 deletions core/models/base/UserapiModelBase.php
Expand Up @@ -75,7 +75,7 @@ function createDefaultApiKey($userDao)
$userApiDao->setApplicationName('Default');
$userApiDao->setApikey($key);
$userApiDao->setTokenExpirationTime(100);
$userApiDao->setCreationDate(date('c'));
$userApiDao->setCreationDate(date("Y-m-d H:i:s"));
$this->save($userApiDao);
}

Expand All @@ -93,7 +93,7 @@ function createKey($userDao, $applicationname, $tokenexperiationtime)
{
return false;
}
$now = date("c");
$now = date("Y-m-d H:i:s");

$key = UtilityComponent::generateRandomString(40);

Expand Down
6 changes: 3 additions & 3 deletions core/models/pdo/FolderModel.php
Expand Up @@ -609,17 +609,17 @@ public function save($folder)
unset($data['folder_id']);
unset($data['left_indice']);
unset($data['right_indice']);
$data['date_update'] = date('c');
$data['date_update'] = date("Y-m-d H:i:s");
$this->database->update($data, array('folder_id = ?' => $key));
return $key;
}
else
{
if(!isset($data['date_creation']) || empty($data['date_creation']))
{
$data['date_creation'] = date('c');
$data['date_creation'] = date("Y-m-d H:i:s");
}
$data['date_update'] = date('c');
$data['date_update'] = date("Y-m-d H:i:s");

$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('2 + right_indice')),
array('right_indice >= ?' => $rightParent));
Expand Down
2 changes: 1 addition & 1 deletion core/models/pdo/TokenModel.php
Expand Up @@ -26,7 +26,7 @@ class TokenModel extends TokenModelBase
/** Remove all expired api tokens */
function cleanExpired()
{
$sql = $this->database->select()->where('expiration_date < ?', date("c"));
$sql = $this->database->select()->where('expiration_date < ?', date("Y-m-d H:i:s"));
$rowset = $this->database->fetchAll($sql);
foreach($rowset as $row)
{
Expand Down

0 comments on commit 94ce00b

Please sign in to comment.