mirror of
https://github.com/typecho/typecho.git
synced 2025-01-31 03:12:21 +01:00
fix #682
This commit is contained in:
parent
dd79918d2e
commit
f3dab3996d
@ -27,7 +27,7 @@ CREATE TABLE `typecho_comments` (
|
||||
`mail` varchar(150) default NULL,
|
||||
`url` varchar(150) default NULL,
|
||||
`ip` varchar(64) default NULL,
|
||||
`agent` varchar(150) default NULL,
|
||||
`agent` varchar(511) default NULL,
|
||||
`text` text,
|
||||
`type` varchar(16) default 'comment',
|
||||
`status` varchar(16) default 'approved',
|
||||
|
@ -12,7 +12,7 @@ CREATE TABLE "typecho_comments" ( "coid" INT NOT NULL DEFAULT nextval('typecho_
|
||||
"mail" VARCHAR(150) NULL DEFAULT NULL,
|
||||
"url" VARCHAR(150) NULL DEFAULT NULL,
|
||||
"ip" VARCHAR(64) NULL DEFAULT NULL,
|
||||
"agent" VARCHAR(150) NULL DEFAULT NULL,
|
||||
"agent" VARCHAR(511) NULL DEFAULT NULL,
|
||||
"text" TEXT NULL DEFAULT NULL,
|
||||
"type" VARCHAR(16) NULL DEFAULT 'comment',
|
||||
"status" VARCHAR(16) NULL DEFAULT 'approved',
|
||||
|
@ -7,7 +7,7 @@ CREATE TABLE typecho_comments ( "coid" INTEGER NOT NULL PRIMARY KEY,
|
||||
"mail" varchar(150) default NULL ,
|
||||
"url" varchar(150) default NULL ,
|
||||
"ip" varchar(64) default NULL ,
|
||||
"agent" varchar(150) default NULL ,
|
||||
"agent" varchar(511) default NULL ,
|
||||
"text" text ,
|
||||
"type" varchar(16) default 'comment' ,
|
||||
"status" varchar(16) default 'approved' ,
|
||||
|
@ -22,7 +22,7 @@ define('__TYPECHO_MB_SUPPORTED__', function_exists('mb_get_info') && function_ex
|
||||
class Typecho_Common
|
||||
{
|
||||
/** 程序版本 */
|
||||
const VERSION = '1.1/17.11.15';
|
||||
const VERSION = '1.1/17.12.8';
|
||||
|
||||
/**
|
||||
* 允许的属性
|
||||
|
@ -1264,5 +1264,69 @@ Typecho_Date::setTimezoneOffset($options->timezone);
|
||||
->rows(array('name' => 'allowXmlRpc', 'user' => 0, 'value' => 2)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级至17.12.8
|
||||
*
|
||||
* @param $db
|
||||
*/
|
||||
public static function v1_1r17_12_8($db)
|
||||
{
|
||||
/** 修改数据库字段 */
|
||||
$adapterName = $db->getAdapterName();
|
||||
$prefix = $db->getPrefix();
|
||||
|
||||
switch (true) {
|
||||
case false !== strpos($adapterName, 'Mysql'):
|
||||
$db->query("ALTER TABLE `" . $prefix . "comments` MODIFY COLUMN `agent` varchar(511)", Typecho_Db::WRITE);
|
||||
break;
|
||||
|
||||
case false !== strpos($adapterName, 'Pgsql'):
|
||||
$db->query('ALTER TABLE "' . $prefix . 'comments" ALTER COLUMN "agent" TYPE varchar(511)', Typecho_Db::WRITE);
|
||||
break;
|
||||
|
||||
case false !== strpos($adapterName, 'SQLite'):
|
||||
$uuid = uniqid();
|
||||
$db->query('CREATE TABLE ' . $prefix . 'comments' . $uuid . ' ( "coid" INTEGER NOT NULL PRIMARY KEY,
|
||||
"cid" int(10) default \'0\' ,
|
||||
"created" int(10) default \'0\' ,
|
||||
"author" varchar(150) default NULL ,
|
||||
"authorId" int(10) default \'0\' ,
|
||||
"ownerId" int(10) default \'0\' ,
|
||||
"mail" varchar(150) default NULL ,
|
||||
"url" varchar(150) default NULL ,
|
||||
"ip" varchar(64) default NULL ,
|
||||
"agent" varchar(511) default NULL ,
|
||||
"text" text ,
|
||||
"type" varchar(16) default \'comment\' ,
|
||||
"status" varchar(16) default \'approved\' ,
|
||||
"parent" int(10) default \'0\')', Typecho_Db::WRITE);
|
||||
$db->query('INSERT INTO ' . $prefix . 'comments' . $uuid . ' SELECT * FROM ' . $prefix . 'comments', Typecho_Db::WRITE);
|
||||
$db->query('DROP TABLE ' . $prefix . 'metas', Typecho_Db::WRITE);
|
||||
$db->query('CREATE TABLE ' . $prefix . 'comments ( "coid" INTEGER NOT NULL PRIMARY KEY,
|
||||
"cid" int(10) default \'0\' ,
|
||||
"created" int(10) default \'0\' ,
|
||||
"author" varchar(150) default NULL ,
|
||||
"authorId" int(10) default \'0\' ,
|
||||
"ownerId" int(10) default \'0\' ,
|
||||
"mail" varchar(150) default NULL ,
|
||||
"url" varchar(150) default NULL ,
|
||||
"ip" varchar(64) default NULL ,
|
||||
"agent" varchar(511) default NULL ,
|
||||
"text" text ,
|
||||
"type" varchar(16) default \'comment\' ,
|
||||
"status" varchar(16) default \'approved\' ,
|
||||
"parent" int(10) default \'0\')', Typecho_Db::WRITE);
|
||||
$db->query('INSERT INTO ' . $prefix . 'comments SELECT * FROM ' . $prefix . 'comments' . $uuid, Typecho_Db::WRITE);
|
||||
$db->query('DROP TABLE ' . $prefix . 'comments' . $uuid, Typecho_Db::WRITE);
|
||||
$db->query('CREATE INDEX ' . $prefix . 'comments_cid ON ' . $prefix . 'comments ("cid")', Typecho_Db::WRITE);
|
||||
$db->query('CREATE INDEX ' . $prefix . 'comments_created ON ' . $prefix . 'comments ("created")', Typecho_Db::WRITE);
|
||||
$db->flushPool();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,6 +185,11 @@ class Widget_Abstract_Comments extends Widget_Abstract
|
||||
$insertStruct['coid'] = $comment['coid'];
|
||||
}
|
||||
|
||||
/** 过长的客户端字符串要截断 */
|
||||
if (Typecho_Common::strLen($insertStruct['agent']) > 511) {
|
||||
$insertStruct['agent'] = Typecho_Common::subStr($insertStruct['agent'], 0, 511, '');
|
||||
}
|
||||
|
||||
/** 首先插入部分数据 */
|
||||
$insertId = $this->db->query($this->db->insert('table.comments')->rows($insertStruct));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user