Fix length of keys

This commit is contained in:
Matthew Exon 2022-10-02 21:19:08 +02:00
parent c3d2ee3ef2
commit 83649f7784
2 changed files with 7 additions and 7 deletions

View file

@ -28,14 +28,14 @@ CREATE TABLE IF NOT EXISTS `retriever_resource` (
`contact-id` int(10) unsigned NOT NULL DEFAULT '0',
`type` char(255) NULL DEFAULT NULL,
`binary` int(1) NOT NULL DEFAULT 0,
`url` varbinary(800) NOT NULL,
`url` varbinary(700) NOT NULL,
`created` timestamp NOT NULL DEFAULT now(),
`completed` timestamp NULL DEFAULT NULL,
`last-try` timestamp NULL DEFAULT NULL,
`num-tries` int(11) NOT NULL DEFAULT 0,
`data` mediumblob NULL DEFAULT NULL,
`http-code` smallint(1) unsigned NULL DEFAULT NULL,
`redirect-url` varbinary(800) NOT NULL,
`redirect-url` varbinary(700) NOT NULL,
KEY `url` (`url`),
KEY `completed` (`completed`),
PRIMARY KEY (`id`)

View file

@ -38,8 +38,8 @@ function retriever_install() {
!DBA::e("ALTER TABLE `retriever_item` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci") ||
!DBA::e("ALTER TABLE `retriever_item` MODIFY `item-uri` varbinary(255) NOT NULL") ||
!DBA::e("ALTER TABLE `retriever_resource` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci") ||
!DBA::e("ALTER TABLE `retriever_resource` MODIFY `url` varbinary(800) NOT NULL") ||
!DBA::e("ALTER TABLE `retriever_resource` MODIFY `redirect-url` varbinary(800) NOT NULL")) {
!DBA::e("ALTER TABLE `retriever_resource` MODIFY `url` varbinary(700) NOT NULL") ||
!DBA::e("ALTER TABLE `retriever_resource` MODIFY `redirect-url` varbinary(700) NOT NULL")) {
Logger::warning('Unable to update database tables: ' . DBA::errorMessage());
return;
}
@ -479,9 +479,9 @@ function add_retriever_resource($url, $uid, $cid, $binary = false) {
return $resource;
}
// 800 characters is the size of this field in the database
if (strlen($url) > 800) {
Logger::warning('add_retriever_resource: URL is longer than 800 characters');
// 700 characters is the size of this field in the database
if (strlen($url) > 700) {
Logger::warning('add_retriever_resource: URL is longer than 700 characters');
}
$resource = DBA::selectFirst('retriever_resource', [], ['url' => $url, 'item-uid' => intval($uid), 'contact-id' => intval($cid)]);