From 45d9f48580aeac0ada328199cd482815b303a43d Mon Sep 17 00:00:00 2001 From: camer0n Date: Tue, 29 Apr 2025 07:59:46 -0700 Subject: [PATCH] Fixes #5483 Extended User field not being restored when 'repair plugin' is activated. --- e107_handlers/plugin_class.php | 1 + e107_tests/tests/unit/pluginsTest.php | 44 ++++++++++++++++----------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 4917939b7..f925639b9 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -4222,6 +4222,7 @@ class e107plugin { case 'install': // Add all active extended fields case 'upgrade': + case 'refresh': if (!$remove) { diff --git a/e107_tests/tests/unit/pluginsTest.php b/e107_tests/tests/unit/pluginsTest.php index 87ed3c0cd..506babf80 100644 --- a/e107_tests/tests/unit/pluginsTest.php +++ b/e107_tests/tests/unit/pluginsTest.php @@ -468,6 +468,33 @@ $this->pluginUninstall('tagcloud'); } + + + public function testRefreshExtendedFields() + { + + $this->pluginInstall('_blank'); + $count = e107::getDb()->count('user_extended_struct', '(*)', "user_extended_struct_name LIKE 'plugin__blank_custom%'"); + $this::assertEquals(1, $count, 'Field was not installed'); + + $this->pluginRefresh('_blank'); + $count = e107::getDb()->count('user_extended_struct', '(*)', "user_extended_struct_name LIKE 'plugin__blank_custom%'"); + $this::assertEquals(1, $count, 'Field was duplicated or is missing'); + + e107::getDb()->delete('user_extended_struct', "user_extended_struct_name LIKE 'plugin__blank_custom%'"); + $count = e107::getDb()->count('user_extended_struct', '(*)', "user_extended_struct_name LIKE 'plugin__blank_custom%'"); + $this::assertEquals(0, $count, 'Field was not deleted'); + $this->pluginRefresh('_blank'); + + $count = e107::getDb()->count('user_extended_struct', '(*)', "user_extended_struct_name LIKE 'plugin__blank_custom%'"); + $this::assertEquals(1, $count, 'Field was not re-installed'); + + $this->pluginUninstall('_blank'); + + + + } + /* public function testThirdParty() { @@ -520,23 +547,6 @@ }*/ - public function testVstore() - { - if(!is_dir(e_PLUGIN."vstore")) - { - return ; - } - - $this->pluginInstall('vstore'); - $this->pluginRefresh('vstore'); - - $links = e107::getDb()->retrieve('links', '*', 'link_owner = "vstore"', true); - $this->assertNotEmpty($links); - $this->assertCount(2, $links); - - $this->pluginUninstall('vstore'); - - } public function testplugInstalledStatus() {