From 9a977a38ba9f10307a8e2e4bf6654cce0f955c12 Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:19:46 -0500 Subject: [PATCH 1/6] log errors --- Controller/WikiController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Controller/WikiController.php b/Controller/WikiController.php index 24524d1..a253e40 100644 --- a/Controller/WikiController.php +++ b/Controller/WikiController.php @@ -17,6 +17,10 @@ class WikiController extends BaseController */ public function show() { + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); + $project = $this->getProject(); $this->response->html($this->helper->layout->project('wiki:wiki/show', array( From f47cda29c26bf8a9ae4e23e337bd360f9bb2a1a1 Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:25:14 -0500 Subject: [PATCH 2/6] fix order bug --- Model/Wiki.php | 2 +- Schema/Mysql.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Wiki.php b/Model/Wiki.php index f53e4d1..b2cbaa9 100644 --- a/Model/Wiki.php +++ b/Model/Wiki.php @@ -78,7 +78,7 @@ public function getWikipages($project_id) ->left(UserModel::TABLE, 'c', 'id', self::WIKITABLE, 'creator_id') ->left(UserModel::TABLE, 'mod', 'id', self::WIKITABLE, 'modifier_id') ->eq('project_id', $project_id) - ->asc('order')->findAll(); + ->asc('\'order\'')->findAll(); // return $this->db->table(self::TABLE) // ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') diff --git a/Schema/Mysql.php b/Schema/Mysql.php index 5768429..7d22a29 100644 --- a/Schema/Mysql.php +++ b/Schema/Mysql.php @@ -4,7 +4,7 @@ use PDO; -const VERSION = 5; +const VERSION = 6; function version_5(PDO $pdo){ // insert persistEditions into settings From dae1697ed5c76ed8dd742fc640603930b9980efe Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:38:17 -0500 Subject: [PATCH 3/6] rename order column --- Model/Wiki.php | 8 +++---- Schema/Mysql.php | 5 +++++ Schema/Postgres.php | 55 ++++++++++++++++++++++++++++++++++++++++++++- Schema/Sqlite.php | 45 ++++++++++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 6 deletions(-) diff --git a/Model/Wiki.php b/Model/Wiki.php index b2cbaa9..c47447e 100644 --- a/Model/Wiki.php +++ b/Model/Wiki.php @@ -65,7 +65,7 @@ public function getWikipages($project_id) self::WIKITABLE . '.content', self::WIKITABLE . '.project_id', self::WIKITABLE . '.is_active', - self::WIKITABLE . '.order', + self::WIKITABLE . '.ordercolumn', self::WIKITABLE . '.creator_id', self::WIKITABLE . '.date_creation', self::WIKITABLE . '.date_modification', @@ -78,7 +78,7 @@ public function getWikipages($project_id) ->left(UserModel::TABLE, 'c', 'id', self::WIKITABLE, 'creator_id') ->left(UserModel::TABLE, 'mod', 'id', self::WIKITABLE, 'modifier_id') ->eq('project_id', $project_id) - ->asc('\'order\'')->findAll(); + ->asc('ordercolumn')->findAll(); // return $this->db->table(self::TABLE) // ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') @@ -110,7 +110,7 @@ public function getWikipage($wiki_id) self::WIKITABLE . '.title', self::WIKITABLE . '.content', self::WIKITABLE . '.project_id', - self::WIKITABLE . '.order', + self::WIKITABLE . '.ordercolumn', self::WIKITABLE . '.is_active', self::WIKITABLE . '.creator_id', self::WIKITABLE . '.date_creation', @@ -202,7 +202,7 @@ public function createpage($project_id, $title, $content, $date = '', $order = n 'title' => $title, 'content' => $content, 'date_creation' => $date ?: date('Y-m-d'), - 'order' => $order ?: time(), + 'ordercolumn' => $order ?: time(), ); $this->prepare($values); diff --git a/Schema/Mysql.php b/Schema/Mysql.php index 7d22a29..20b83d6 100644 --- a/Schema/Mysql.php +++ b/Schema/Mysql.php @@ -6,6 +6,11 @@ const VERSION = 6; +function version_5(PDO $pdo){ + // insert persistEditions into settings + $pdo->exec("ALTER TABLE `wikipage` CHANGE COLUMN `order` `ordercolumn` int(11) NOT NULL;"); +} + function version_5(PDO $pdo){ // insert persistEditions into settings $pdo->exec("INSERT INTO `settings` (`option`, `value`) VALUES ('persistEditions', '1');"); diff --git a/Schema/Postgres.php b/Schema/Postgres.php index 4e6d732..70bb4f5 100644 --- a/Schema/Postgres.php +++ b/Schema/Postgres.php @@ -4,7 +4,60 @@ use PDO; -const VERSION = 1; +const VERSION = 2; + +function version_2(PDO $pdo) +{ + $pdo->exec('ALTER TABLE wikipage RENAME COLUMN "order" TO "ordercolumn"'); + +} + +function version_2(PDO $pdo) +{ + + // drop all tables + $pdo->exec('drop table wikipage; drop table wikipage_has_files; drop table wikipage_editions; '); + + // recreate + $pdo->exec('CREATE TABLE IF NOT EXISTS wikipage ( + id SERIAL PRIMARY KEY, + project_id INTEGER NOT NULL, + title varchar(255) NOT NULL, + content TEXT, + is_active smallint DEFAULT 1, + creator_id INTEGER DEFAULT 0, + modifier_id INTEGER DEFAULT 0, + date_creation VARCHAR(10) DEFAULT NULL, + date_modification VARCHAR(10) DEFAULT NULL, + ordercolumn INTEGER DEFAULT 1, + editions INTEGER default 1, + current_edition INTEGER default 1, + FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE + );'); + + $pdo->exec('CREATE TABLE wikipage_has_files ( + "id" SERIAL PRIMARY KEY, + name VARCHAR(50), + path VARCHAR(255), + is_image smallint DEFAULT 0, + wikipage_id INTEGER, + FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE + )'); + + $pdo->exec('CREATE TABLE wikipage_editions ( + "edition" INT NOT NULL, + "title" varchar(255) NOT NULL, + "content" TEXT, + "creator_id" INTEGER DEFAULT 0, + "date_creation" VARCHAR(10) DEFAULT NULL, + wikipage_id INTEGER NOT NULL, + PRIMARY KEY ("edition","wikipage_id"), + FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE + )'); + + $pdo->exec("INSERT INTO settings (option, value) VALUES ('persistEditions', '1');"); + +} function version_1(PDO $pdo) { diff --git a/Schema/Sqlite.php b/Schema/Sqlite.php index 051823f..534b18e 100644 --- a/Schema/Sqlite.php +++ b/Schema/Sqlite.php @@ -4,7 +4,50 @@ use PDO; -const VERSION = 1; +const VERSION = 2; + +function version_2(PDO $pdo) +{ + + // drop all tables + $pdo->exec('drop table wikipage; drop table wikipage_has_files; drop table wikipage_editions; '); + + $pdo->exec("CREATE TABLE `wikipage` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + `project_id` INTEGER NOT NULL, + `title` varchar(255) NOT NULL, + `content` TEXT DEFAULT 1, + `is_active` int(4) DEFAULT 1, + `creator_id` int(11) DEFAULT 0, + `modifier_id` int(11), + `date_creation` INTEGER, + `date_modification` INTEGER, + `ordercolumn` INTEGER DEFAULT 1, + `editions` INTEGER DEFAULT 1, + `current_edition` INTEGER DEFAULT 1, + FOREIGN KEY(`project_id`) REFERENCES `projects`(`id`) + );"); + + $pdo->exec('CREATE TABLE wikipage_has_files ( + "id" INTEGER PRIMARY KEY, + name VARCHAR(50), + path VARCHAR(255), + is_image INTEGER DEFAULT 0, + wikipage_id INT, + FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE + )'); + + $pdo->exec('CREATE TABLE wikipage_editions ( + `edition` INT NOT NULL, + `title` varchar(255) NOT NULL, + `content` TEXT, + `creator_id` int(11) DEFAULT 0, + `date_creation` VARCHAR(10) DEFAULT NULL, + wikipage_id INT NOT NULL, + PRIMARY KEY (`edition`,`wikipage_id`), + FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE + )'); +} function version_1(PDO $pdo) { From a8e88a7185507718718c5451912a51aeff7227a4 Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:39:18 -0500 Subject: [PATCH 4/6] new bug version --- ChangeLog | 6 ++++++ Makefile | 2 +- Plugin.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97d650c..cba4b17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Version 0.2.3-alpha + +Bug fixes: + +* fixed order column bug for sqlite + Version 0.2.2-alpha New features: diff --git a/Makefile b/Makefile index bd38faa..76de3d8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ plugin=Wiki -version=0.2.2 +version=0.2.3 all: @ echo "Build archive for plugin ${plugin} version=${version}" @ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip diff --git a/Plugin.php b/Plugin.php index 1749621..de5d141 100644 --- a/Plugin.php +++ b/Plugin.php @@ -77,7 +77,7 @@ public function getPluginAuthor() public function getPluginVersion() { - return '0.2.2'; + return '0.2.3'; } public function getPluginHomepage() From e64cd6a10c739990ff833552a04c52566dac32f4 Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:45:21 -0500 Subject: [PATCH 5/6] fix postgress typo --- Schema/Postgres.php | 47 --------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/Schema/Postgres.php b/Schema/Postgres.php index 70bb4f5..8704a09 100644 --- a/Schema/Postgres.php +++ b/Schema/Postgres.php @@ -12,53 +12,6 @@ function version_2(PDO $pdo) } -function version_2(PDO $pdo) -{ - - // drop all tables - $pdo->exec('drop table wikipage; drop table wikipage_has_files; drop table wikipage_editions; '); - - // recreate - $pdo->exec('CREATE TABLE IF NOT EXISTS wikipage ( - id SERIAL PRIMARY KEY, - project_id INTEGER NOT NULL, - title varchar(255) NOT NULL, - content TEXT, - is_active smallint DEFAULT 1, - creator_id INTEGER DEFAULT 0, - modifier_id INTEGER DEFAULT 0, - date_creation VARCHAR(10) DEFAULT NULL, - date_modification VARCHAR(10) DEFAULT NULL, - ordercolumn INTEGER DEFAULT 1, - editions INTEGER default 1, - current_edition INTEGER default 1, - FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE - );'); - - $pdo->exec('CREATE TABLE wikipage_has_files ( - "id" SERIAL PRIMARY KEY, - name VARCHAR(50), - path VARCHAR(255), - is_image smallint DEFAULT 0, - wikipage_id INTEGER, - FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE - )'); - - $pdo->exec('CREATE TABLE wikipage_editions ( - "edition" INT NOT NULL, - "title" varchar(255) NOT NULL, - "content" TEXT, - "creator_id" INTEGER DEFAULT 0, - "date_creation" VARCHAR(10) DEFAULT NULL, - wikipage_id INTEGER NOT NULL, - PRIMARY KEY ("edition","wikipage_id"), - FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE - )'); - - $pdo->exec("INSERT INTO settings (option, value) VALUES ('persistEditions', '1');"); - -} - function version_1(PDO $pdo) { $pdo->exec('CREATE TABLE IF NOT EXISTS wikipage ( From 103e49b84187b3605280ed10393d0b271c8e602b Mon Sep 17 00:00:00 2001 From: lastlink Date: Tue, 20 Feb 2018 23:47:37 -0500 Subject: [PATCH 6/6] fix mysql typo --- Schema/Mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Schema/Mysql.php b/Schema/Mysql.php index 20b83d6..f6e1aef 100644 --- a/Schema/Mysql.php +++ b/Schema/Mysql.php @@ -6,7 +6,7 @@ const VERSION = 6; -function version_5(PDO $pdo){ +function version_6(PDO $pdo){ // insert persistEditions into settings $pdo->exec("ALTER TABLE `wikipage` CHANGE COLUMN `order` `ordercolumn` int(11) NOT NULL;"); }