Skip to content

Commit 6b74e51

Browse files
authored
Revert "[BUGFIX] Add plugin-enabled check condition to CustomObjectPermission…"
This reverts commit 8a155c8.
1 parent 8a155c8 commit 6b74e51

File tree

3 files changed

+2
-32
lines changed

3 files changed

+2
-32
lines changed

Diff for: Config/config.php

-1
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@
10421042
'class' => ConfigProvider::class,
10431043
'arguments' => [
10441044
'mautic.helper.core_parameters',
1045-
'database_connection',
10461045
],
10471046
],
10481047
'custom_field.type.provider' => [

Diff for: Provider/ConfigProvider.php

+2-27
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44

55
namespace MauticPlugin\CustomObjectsBundle\Provider;
66

7-
use Doctrine\DBAL\Connection;
8-
use Doctrine\DBAL\Exception;
97
use Mautic\CoreBundle\Helper\CoreParametersHelper;
10-
use MauticPlugin\CustomObjectsBundle\Entity\CustomObject;
118

129
class ConfigProvider
1310
{
1411
/**
1512
* @var string
1613
*/
17-
public const CONFIG_PLUGIN_NAME = 'CustomObjectsBundle';
1814
public const CONFIG_PARAM_ENABLED = 'custom_objects_enabled';
1915
public const CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_LIMIT = 'custom_object_item_value_to_contact_relation_limit';
2016

@@ -25,38 +21,17 @@ class ConfigProvider
2521
*/
2622
private $coreParametersHelper;
2723

28-
/**
29-
* @var Connection
30-
*/
31-
private $connection;
32-
33-
public function __construct(CoreParametersHelper $coreParametersHelper, Connection $connection)
24+
public function __construct(CoreParametersHelper $coreParametersHelper)
3425
{
3526
$this->coreParametersHelper = $coreParametersHelper;
36-
$this->connection = $connection;
3727
}
3828

3929
/**
4030
* Returns true if the Custom Objects plugin is enabled.
4131
*/
4232
public function pluginIsEnabled(): bool
4333
{
44-
$pluginEnabled = (bool) $this->coreParametersHelper->get(self::CONFIG_PARAM_ENABLED, true);
45-
if (!$pluginEnabled) {
46-
return false;
47-
}
48-
49-
try {
50-
$pluginWasInstalledBefore = $this->connection
51-
->executeQuery('SELECT id FROM plugins WHERE bundle=:pluginName', ['pluginName' => self::CONFIG_PLUGIN_NAME])
52-
->rowCount();
53-
$customObjectsTableExists = $this->connection
54-
->executeQuery('SHOW TABLES LIKE :tableName', ['tableName' => CustomObject::TABLE_NAME])
55-
->rowCount();
56-
return $pluginWasInstalledBefore && $customObjectsTableExists;
57-
} catch (Exception $e) {
58-
return false;
59-
}
34+
return (bool) $this->coreParametersHelper->get(self::CONFIG_PARAM_ENABLED, true);
6035
}
6136

6237
public function isCustomObjectMergeFilterEnabled(): bool

Diff for: Security/Permissions/CustomObjectPermissions.php

-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ public function __construct(
5656
*/
5757
public function definePermissions(): void
5858
{
59-
if (!$this->isEnabled()) {
60-
return;
61-
}
62-
6359
$this->addExtendedPermissions(['custom_fields', self::NAME]);
6460

6561
$customObjects = $this->getCustomObjects();

0 commit comments

Comments
 (0)