From 69a335713f7cbec6dd8610f794744620b95a130d Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 4 Aug 2021 22:06:35 +0530 Subject: [PATCH 1/8] Bug #173934 fix: Error com_tjvendors column not found in tj_regions table --- .../houseKeeping/1.5.1/tjVendorsColumn.php | 109 ++++++++++++++++++ administrator/sql/country.sql | 2 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 administrator/houseKeeping/1.5.1/tjVendorsColumn.php diff --git a/administrator/houseKeeping/1.5.1/tjVendorsColumn.php b/administrator/houseKeeping/1.5.1/tjVendorsColumn.php new file mode 100644 index 00000000..0b3516d4 --- /dev/null +++ b/administrator/houseKeeping/1.5.1/tjVendorsColumn.php @@ -0,0 +1,109 @@ + + * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ + +// No direct access +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; + +/** + * Migration file for TJ-Fields + * + * @since 1.0 + */ +class TjHouseKeepingTjVendorsColumn extends TjModelHouseKeeping +{ + public $title = "Country, Region, and City table fix for com_tjvendors"; + + public $description = "Add com_tjvendors column in Country, Region, and City table"; + + /** + * Add com_tjvendors column in Country, Region, and City table if not exists + * + * @return void + * + * @since 1.0 + */ + public function migrate() + { + $result = array(); + + try + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query = "SHOW COLUMNS FROM `#__tj_city`"; + $db->setQuery($query); + $columns = $db->loadobjectlist(); + + if (!in_array('com_tjvendors', $columns)) + { + $query = "ALTER TABLE `#__tj_city` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'"; + $db->setQuery($query); + + if (!$db->execute()) + { + $result['status'] = false; + $result['message'] = $db->getErrorMsg(); + + return $result; + } + } + + $query = $db->getQuery(true); + $query = "SHOW COLUMNS FROM `#__tj_region`"; + $db->setQuery($query); + $columns = $db->loadobjectlist(); + + if (!in_array('com_tjvendors', $columns)) + { + $query = "ALTER TABLE `#__tj_region` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'"; + $db->setQuery($query); + + if (!$db->execute()) + { + $result['status'] = false; + $result['message'] = $db->getErrorMsg(); + + return $result; + } + } + + $query = $db->getQuery(true); + $query = "SHOW COLUMNS FROM `#__tj_country`"; + $db->setQuery($query); + $columns = $db->loadobjectlist(); + + if (!in_array('com_tjvendors', $columns)) + { + $query = "ALTER TABLE `#__tj_country` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'"; + $db->setQuery($query); + + if (!$db->execute()) + { + $result['status'] = false; + $result['message'] = $db->getErrorMsg(); + + return $result; + } + } + + $result['status'] = true; + $result['message'] = "Migration successful"; + } + catch (Exception $e) + { + $result['err_code'] = ''; + $result['status'] = false; + $result['message'] = $e->getMessage(); + } + + return $result; + } +} diff --git a/administrator/sql/country.sql b/administrator/sql/country.sql index bf682156..c59f8d3f 100755 --- a/administrator/sql/country.sql +++ b/administrator/sql/country.sql @@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_country` ( `com_quick2cart` tinyint(1) NOT NULL DEFAULT '1', `com_socialads` tinyint(1) NOT NULL DEFAULT '1', `com_tjlms` tinyint(1) NOT NULL DEFAULT '1', - `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1', + `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; From e0d592b4ace5515b4791c0d77794f873e0e82c4e Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 4 Aug 2021 22:25:09 +0530 Subject: [PATCH 2/8] Bug #173934 fix: Error com_tjvendors column not found in tj_regions table --- administrator/houseKeeping/1.5.1/tjVendorsColumn.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/administrator/houseKeeping/1.5.1/tjVendorsColumn.php b/administrator/houseKeeping/1.5.1/tjVendorsColumn.php index 0b3516d4..ef1fc7b7 100644 --- a/administrator/houseKeeping/1.5.1/tjVendorsColumn.php +++ b/administrator/houseKeeping/1.5.1/tjVendorsColumn.php @@ -40,7 +40,9 @@ public function migrate() $query = $db->getQuery(true); $query = "SHOW COLUMNS FROM `#__tj_city`"; $db->setQuery($query); - $columns = $db->loadobjectlist(); + $columns = $db->loadAssoclist(); + + $columns = array_column($columns, "Field"); if (!in_array('com_tjvendors', $columns)) { @@ -61,6 +63,8 @@ public function migrate() $db->setQuery($query); $columns = $db->loadobjectlist(); + $columns = array_column($columns, "Field"); + if (!in_array('com_tjvendors', $columns)) { $query = "ALTER TABLE `#__tj_region` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'"; @@ -80,6 +84,8 @@ public function migrate() $db->setQuery($query); $columns = $db->loadobjectlist(); + $columns = array_column($columns, "Field"); + if (!in_array('com_tjvendors', $columns)) { $query = "ALTER TABLE `#__tj_country` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'"; From 7f099aaa3851f3211bcc0c1f074f2383cfa3e381 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 4 Aug 2021 22:28:41 +0530 Subject: [PATCH 3/8] Bug #173934 fix: Error com_tjvendors column not found in tj_regions table --- .../houseKeeping/{1.5.1 => 1.4.6}/tjVendorsColumn.php | 0 tjfields.xml | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename administrator/houseKeeping/{1.5.1 => 1.4.6}/tjVendorsColumn.php (100%) diff --git a/administrator/houseKeeping/1.5.1/tjVendorsColumn.php b/administrator/houseKeeping/1.4.6/tjVendorsColumn.php similarity index 100% rename from administrator/houseKeeping/1.5.1/tjVendorsColumn.php rename to administrator/houseKeeping/1.4.6/tjVendorsColumn.php diff --git a/tjfields.xml b/tjfields.xml index add331a1..589d788a 100644 --- a/tjfields.xml +++ b/tjfields.xml @@ -4,10 +4,10 @@ TechJoomla extensions@techjoomla.com www.techjoomla.com - Copyright(C)2012-20 TechJoomla + Copyright(C)2012-21 TechJoomla http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 15th Sep 2020 - 1.4.5 + 4th Aug 2021 + 1.4.6 TJFields - Common code for TJ Fields Manager and TJ Geo Manager! From 37de023cf644061b7e63fca77548c0089f1d1522 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 4 Aug 2021 22:30:00 +0530 Subject: [PATCH 4/8] Bug #173934 fix: Error com_tjvendors column not found in tj_regions table --- administrator/houseKeeping/1.4.6/tjVendorsColumn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/houseKeeping/1.4.6/tjVendorsColumn.php b/administrator/houseKeeping/1.4.6/tjVendorsColumn.php index ef1fc7b7..bb8df789 100644 --- a/administrator/houseKeeping/1.4.6/tjVendorsColumn.php +++ b/administrator/houseKeeping/1.4.6/tjVendorsColumn.php @@ -3,7 +3,7 @@ * @package TJ-Fields * * @author Techjoomla - * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. + * @copyright Copyright (c) 2009-2021 TechJoomla. All rights reserved. * @license GNU General Public License version 2 or later. */ @@ -15,7 +15,7 @@ /** * Migration file for TJ-Fields * - * @since 1.0 + * @since 1.4.6 */ class TjHouseKeepingTjVendorsColumn extends TjModelHouseKeeping { From 04e7623269030f7b97f3784c08e193023346885c Mon Sep 17 00:00:00 2001 From: kamalakanta Date: Tue, 3 Jan 2023 09:07:00 +0530 Subject: [PATCH 5/8] PHP 8.1 Test Issues --- site/helpers/tjfields.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 0ac16521..cc0970d1 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -62,7 +62,7 @@ public function FetchDatavalue($data) $query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' . $db->qn('f.id') . ' = ' . $db->qn('fv.field_id') . ')'); - $query->where('fv.content_id=' . $content_id); + $query->where('fv.content_id=' . (int) $content_id); $query->where('fv.client="' . $client . '" ' . $query_user_string); $query->where('f.state=' . $db->quote("1")); $db->setQuery($query); @@ -75,6 +75,7 @@ public function FetchDatavalue($data) { $fieldParams = json_decode($data->params); $multipleValueField = (isset($fieldParams->multiple) && !empty($fieldParams->multiple)) ? 1 : 0; + $fieldDataValue[$data->field_id] = new stdclass; if ($data->type == "radio" || $data->type == "single_select") { @@ -89,7 +90,7 @@ public function FetchDatavalue($data) } else { - $fieldDataValue[$data->field_id] = new stdclass; + $fieldDataValue[$data->field_id]->value = $data->value; $fieldDataValue[$data->field_id]->field_id = $data->field_id; } From 6b7d90bc1566ec3dd12cb95692c09f68d2012d78 Mon Sep 17 00:00:00 2001 From: kamalakanta Date: Tue, 3 Jan 2023 09:09:54 +0530 Subject: [PATCH 6/8] PHP 8.1 Test Issues --- administrator/sql/country.sql | 1 - tjfields.xml | 2 -- 2 files changed, 3 deletions(-) diff --git a/administrator/sql/country.sql b/administrator/sql/country.sql index 497167c8..53aa223e 100755 --- a/administrator/sql/country.sql +++ b/administrator/sql/country.sql @@ -8,7 +8,6 @@ CREATE TABLE IF NOT EXISTS `#__tj_country` ( `country_3_code` char(3) DEFAULT NULL, `country_code` char(2) DEFAULT NULL, `country_dial_code` char(7) DEFAULT NULL, - `country_jtext` varchar(255) NOT NULL DEFAULT '', `ordering` int(3) NOT NULL DEFAULT 0, `com_jgive` tinyint(1) NOT NULL DEFAULT 1, diff --git a/tjfields.xml b/tjfields.xml index 7b867e62..942d7820 100644 --- a/tjfields.xml +++ b/tjfields.xml @@ -4,12 +4,10 @@ TechJoomla extensions@techjoomla.com www.techjoomla.com - Copyright(C)2012-22 TechJoomla http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 7th Feb 2022 2.0.1 - TJFields - Common code for TJ Fields Manager and TJ Geo Manager! From 3789c5a1fa4a07d726a6b486a9517f594642529b Mon Sep 17 00:00:00 2001 From: kamalakanta Date: Fri, 3 Mar 2023 17:01:29 +0530 Subject: [PATCH 7/8] php 8 test --- site/helpers/tjfields.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index cc0970d1..9cd665f1 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -75,7 +75,11 @@ public function FetchDatavalue($data) { $fieldParams = json_decode($data->params); $multipleValueField = (isset($fieldParams->multiple) && !empty($fieldParams->multiple)) ? 1 : 0; - $fieldDataValue[$data->field_id] = new stdclass; + + // Initialize $fieldDataValue[$data->field_id] if needed + if (!isset($fieldDataValue[$data->field_id])) { + $fieldDataValue[$data->field_id] = new stdclass; + } if ($data->type == "radio" || $data->type == "single_select") { From eb8d063293da54602352b5b2c214dbb2a7ed18a2 Mon Sep 17 00:00:00 2001 From: kamalakanta Date: Fri, 3 Mar 2023 17:03:08 +0530 Subject: [PATCH 8/8] php 8 test --- site/helpers/tjfields.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 9511b6f4..49ba1bb3 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -77,7 +77,8 @@ public function FetchDatavalue($data) $multipleValueField = (isset($fieldParams->multiple) && !empty($fieldParams->multiple)) ? 1 : 0; // Initialize $fieldDataValue[$data->field_id] if needed - if (!isset($fieldDataValue[$data->field_id])) { + if (!isset($fieldDataValue[$data->field_id])) + { $fieldDataValue[$data->field_id] = new stdclass; }