From e2a81935e90ce4ea07be5b552b857f8e497014b4 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Wed, 17 May 2017 13:49:50 -0400 Subject: [PATCH 1/9] Fix compatibility warnings for PHP7 --- lib/class.systemdate.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/class.systemdate.php b/lib/class.systemdate.php index eb657fe..a3c877c 100644 --- a/lib/class.systemdate.php +++ b/lib/class.systemdate.php @@ -37,8 +37,8 @@ private function dateFromEntryID($entry_id) { return Symphony::Database()->fetchRow(0, sprintf(" SELECT %s - FROM `tbl_entries` - WHERE `id` = %d + FROM `tbl_entries` + WHERE `id` = %d LIMIT 1 ", $this->getFieldName(), $entry_id)); } @@ -102,7 +102,7 @@ public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWit { $label = new XMLElement('label'); $wrapper->appendChild($label); - + $row = $this->dateFromEntryID($entry_id); $date = $this->parseDate($row); $value = $this->formatDate($date); @@ -189,7 +189,7 @@ public function prepareTextValue($data, $entry_id = null) Filtering: -------------------------------------------------------------------------*/ - public function buildSortingSQL(&$joins, &$where, &$sort, $order = 'ASC') + public function buildSortingSQL(&$joins, &$where, &$sort, $order = 'ASC', &$select = NULL) { $fieldname = $this->getFieldName(); $sort = 'ORDER BY ' . (in_array(strtolower($order), array('random', 'rand')) ? 'RAND()' : "`e`.`$fieldname` $order"); From 67288d17f1f69e922ec0285a6bb6b22495262822 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 23 May 2017 11:03:19 -0400 Subject: [PATCH 2/9] PHP7 Compatibility release --- extension.meta.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index 77e1fd3..66e73d5 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -15,12 +15,13 @@ + + - Update for Symphony 4.x + - PHP7 compatibility + - Symphony 2.7.0 compatibility - - - PHP7 compatibility - - Unify Styling of readonly values From 4a64a8fc049d8a13bc4cccf9d2ba69ce9aedd276 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 30 May 2017 14:28:32 -0400 Subject: [PATCH 3/9] Remove deprecated param from buildSortingSQL --- lib/class.systemdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class.systemdate.php b/lib/class.systemdate.php index a3c877c..c04fe1a 100644 --- a/lib/class.systemdate.php +++ b/lib/class.systemdate.php @@ -189,7 +189,7 @@ public function prepareTextValue($data, $entry_id = null) Filtering: -------------------------------------------------------------------------*/ - public function buildSortingSQL(&$joins, &$where, &$sort, $order = 'ASC', &$select = NULL) + public function buildSortingSQL(&$joins, &$where, &$sort, $order = 'ASC') { $fieldname = $this->getFieldName(); $sort = 'ORDER BY ' . (in_array(strtolower($order), array('random', 'rand')) ? 'RAND()' : "`e`.`$fieldname` $order"); From 62dd617fdcb138dd3bcaa9ff7d2451165e92b891 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Thu, 24 Aug 2017 16:08:17 -0400 Subject: [PATCH 4/9] SQL and PHP cases PHP true,false,null in lowercase SQL keywords uppercase --- extension.driver.php | 24 ++++++++++++------------ lib/class.systemdate.php | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/extension.driver.php b/extension.driver.php index b41b009..0abe307 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -51,13 +51,13 @@ public function update($previousVersion = false) if ($ret && version_compare($previousVersion,'1.1.0') == -1) { $ret1 = Symphony::Database()->query(" ALTER TABLE `tbl_fields_systemcreateddate` - ADD COLUMN `show_time` enum('yes','no') NOT NULL DEFAULT 'no', - ADD COLUMN `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no' + ADD COLUMN `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', + ADD COLUMN `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no' "); $ret2 = Symphony::Database()->query(" ALTER TABLE `tbl_fields_systemmodifieddate` - ADD COLUMN `show_time` enum('yes','no') NOT NULL DEFAULT 'no', - ADD COLUMN `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no' + ADD COLUMN `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', + ADD COLUMN `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no' "); $ret = $ret1 && $ret2; } @@ -76,20 +76,20 @@ public function install() { $ret1 = Symphony::Database()->query(" CREATE TABLE `tbl_fields_systemcreateddate` ( - `id` int(11) unsigned NOT NULL auto_increment, - `field_id` int(11) unsigned NOT NULL, - `show_time` enum('yes','no') NOT NULL DEFAULT 'no', - `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no', + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `field_id` INT(11) UNSIGNED NOT NULL, + `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', + `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no', PRIMARY KEY (`id`), KEY `field_id` (`field_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci "); $ret2 = Symphony::Database()->query(" CREATE TABLE `tbl_fields_systemmodifieddate` ( - `id` int(11) unsigned NOT NULL auto_increment, - `field_id` int(11) unsigned NOT NULL, - `show_time` enum('yes','no') NOT NULL DEFAULT 'no', - `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no', + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `field_id` INT(11) UNSIGNED NOT NULL, + `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', + `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no', PRIMARY KEY (`id`), KEY `field_id` (`field_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci diff --git a/lib/class.systemdate.php b/lib/class.systemdate.php index c04fe1a..784f3ac 100644 --- a/lib/class.systemdate.php +++ b/lib/class.systemdate.php @@ -125,10 +125,10 @@ public function checkPostFieldData($data, &$message, $entry_id = null) return self::__OK__; } - public function processRawFieldData($data, &$status, &$message = NULL, $simulate = false, $entry_id = null) + public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null) { $status = self::__OK__; - return NULL; + return null; } public function commit() From 71dde4ef78117e42f1d6dad9e2b93f1f120ae85f Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Fri, 25 Aug 2017 11:28:01 -0400 Subject: [PATCH 5/9] Relase infos .. Again --- extension.meta.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.meta.xml b/extension.meta.xml index 66e73d5..643ce91 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -15,7 +15,7 @@ - + - Update for Symphony 4.x - PHP7 compatibility From 321c3ceca7292d07dc015b6cdb971f14b671d665 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Thu, 31 May 2018 10:40:18 -0400 Subject: [PATCH 6/9] Code refactoring for Database --- extension.driver.php | 136 +++++++++++++++++++++++++++++++++---------- extension.meta.xml | 1 + 2 files changed, 105 insertions(+), 32 deletions(-) diff --git a/extension.driver.php b/extension.driver.php index 0abe307..0d9b531 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -49,16 +49,40 @@ public function update($previousVersion = false) $ret = true; if ($ret && version_compare($previousVersion,'1.1.0') == -1) { - $ret1 = Symphony::Database()->query(" - ALTER TABLE `tbl_fields_systemcreateddate` - ADD COLUMN `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', - ADD COLUMN `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no' - "); - $ret2 = Symphony::Database()->query(" - ALTER TABLE `tbl_fields_systemmodifieddate` - ADD COLUMN `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', - ADD COLUMN `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no' - "); + $ret1 = Symphonmy::Database() + ->alter('tbl_fields_systemcreateddate') + ->add([ + 'show_time' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'use_timeago' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->execute() + ->success(); + + $ret2 = Symphonmy::Database() + ->alter('tbl_fields_systemmodifieddate') + ->add([ + 'show_time' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'use_timeago' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->execute() + ->success(); + $ret = $ret1 && $ret2; } @@ -67,33 +91,81 @@ public function update($previousVersion = false) public function uninstall() { - $ret1 = Symphony::Database()->query("DROP TABLE `tbl_fields_systemcreateddate`"); - $ret2 = Symphony::Database()->query("DROP TABLE `tbl_fields_systemmodifieddate`"); + $ret1 = Symphony::Database() + ->drop('tbl_fields_systemcreateddate') + ->ifExists() + ->execute() + ->success(); + + $ret2 = Symphony::Database() + ->drop('tbl_fields_systemmodifieddate') + ->ifExists() + ->execute() + ->success(); + return $ret1 && $ret2; } public function install() { - $ret1 = Symphony::Database()->query(" - CREATE TABLE `tbl_fields_systemcreateddate` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `field_id` INT(11) UNSIGNED NOT NULL, - `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', - `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no', - PRIMARY KEY (`id`), - KEY `field_id` (`field_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci - "); - $ret2 = Symphony::Database()->query(" - CREATE TABLE `tbl_fields_systemmodifieddate` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `field_id` INT(11) UNSIGNED NOT NULL, - `show_time` ENUM('yes','no') NOT NULL DEFAULT 'no', - `use_timeago` ENUM('yes','no') NOT NULL DEFAULT 'no', - PRIMARY KEY (`id`), - KEY `field_id` (`field_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci - "); + $ret1 = Symphony::Database() + ->create('tbl_fields_systemcreateddate') + ->ifNotExists() + ->charset('utf8') + ->collate('utf8_unicode_ci') + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'field_id' => 'int(11)', + 'show_time' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'use_timeago' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->keys([ + 'id' => 'primary', + 'field_id' => 'key', + ]) + ->execute() + ->success(); + + $ret2 = Symphony::Database() + ->create('tbl_fields_systemmodifieddate') + ->ifNotExists() + ->charset('utf8') + ->collate('utf8_unicode_ci') + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'field_id' => 'int(11)', + 'show_time' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'use_timeago' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->keys([ + 'id' => 'primary', + 'field_id' => 'key', + ]) + ->execute() + ->success(); + return $ret1 && $ret2; } } diff --git a/extension.meta.xml b/extension.meta.xml index 643ce91..91ac6f0 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -18,6 +18,7 @@ - Update for Symphony 4.x - PHP7 compatibility + - Code refactoring for Database and EQFA - Symphony 2.7.0 compatibility From c10ae6ee93414d99b5e19084dc029c5a7c9902c4 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Thu, 31 May 2018 13:29:12 -0400 Subject: [PATCH 7/9] Refactor class.systemdate.php with new Database methods --- lib/class.systemdate.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/class.systemdate.php b/lib/class.systemdate.php index 784f3ac..d48cfe6 100644 --- a/lib/class.systemdate.php +++ b/lib/class.systemdate.php @@ -35,12 +35,13 @@ protected abstract function getFieldName(); private function dateFromEntryID($entry_id) { - return Symphony::Database()->fetchRow(0, sprintf(" - SELECT %s - FROM `tbl_entries` - WHERE `id` = %d - LIMIT 1 - ", $this->getFieldName(), $entry_id)); + return Symphony::Database() + ->select([$this->getFieldName()]) + ->from('tbl_entries') + ->where(['id' => $entry_id]) + ->limit(1) + ->execute() + ->rows()[0]; } private function getDateFormat() From 457471b4d6cb62fea66f1dfa0ac0749380186d60 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 19 Jun 2018 14:09:10 -0400 Subject: [PATCH 8/9] Replace rows()[0] with proper next() --- lib/class.systemdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class.systemdate.php b/lib/class.systemdate.php index d48cfe6..34374ad 100644 --- a/lib/class.systemdate.php +++ b/lib/class.systemdate.php @@ -41,7 +41,7 @@ private function dateFromEntryID($entry_id) ->where(['id' => $entry_id]) ->limit(1) ->execute() - ->rows()[0]; + ->next(); } private function getDateFormat() From f5f7731a02a5334fff1bcc8995797fb419826aae Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 18 Dec 2018 09:48:20 -0500 Subject: [PATCH 9/9] Remote SQL collate and charset definitions. --- extension.driver.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/extension.driver.php b/extension.driver.php index 0d9b531..3b77436 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -111,8 +111,6 @@ public function install() $ret1 = Symphony::Database() ->create('tbl_fields_systemcreateddate') ->ifNotExists() - ->charset('utf8') - ->collate('utf8_unicode_ci') ->fields([ 'id' => [ 'type' => 'int(11)', @@ -140,8 +138,6 @@ public function install() $ret2 = Symphony::Database() ->create('tbl_fields_systemmodifieddate') ->ifNotExists() - ->charset('utf8') - ->collate('utf8_unicode_ci') ->fields([ 'id' => [ 'type' => 'int(11)',