fix: Rename Plugin_config methods to avoid conflict with CodeIgniter Model::set()

The PluginConfig class extends CodeIgniter\Model which has its own set() method
for query building. Renaming get()/set() to getValue()/setValue() avoids this conflict.

Also fixed:
- batchSave() to use setValue() instead of set()
- Updated all callers in PluginManager and BasePlugin to use renamed methods
This commit is contained in:
Ollama
2026-03-24 08:07:18 +00:00
parent 896ed87797
commit 0ea3ced674
3 changed files with 12 additions and 12 deletions

View File

@@ -25,13 +25,13 @@ abstract class BasePlugin implements PluginInterface
public function isEnabled(): bool
{
$enabled = $this->configModel->get("{$this->getPluginId()}_enabled");
$enabled = $this->configModel->getValue("{$this->getPluginId()}_enabled");
return $enabled === '1' || $enabled === 'true';
}
protected function getSetting(string $key, mixed $default = null): mixed
{
$value = $this->configModel->get("{$this->getPluginId()}_{$key}");
$value = $this->configModel->getValue("{$this->getPluginId()}_{$key}");
return $value ?? $default;
}
@@ -41,7 +41,7 @@ abstract class BasePlugin implements PluginInterface
? json_encode($value)
: (string)$value;
return $this->configModel->set("{$this->getPluginId()}_{$key}", $stringValue);
return $this->configModel->setValue("{$this->getPluginId()}_{$key}", $stringValue);
}
public function getSettings(): array

View File

@@ -95,7 +95,7 @@ class PluginManager
public function isPluginEnabled(string $pluginId): bool
{
$enabled = $this->configModel->get($this->getEnabledKey($pluginId));
$enabled = $this->configModel->getValue($this->getEnabledKey($pluginId));
return $enabled === '1' || $enabled === 'true';
}
@@ -112,10 +112,10 @@ class PluginManager
log_message('error', "Failed to install plugin: {$pluginId}");
return false;
}
$this->configModel->set($this->getInstalledKey($pluginId), '1');
$this->configModel->setValue($this->getInstalledKey($pluginId), '1');
}
$this->configModel->set($this->getEnabledKey($pluginId), '1');
$this->configModel->setValue($this->getEnabledKey($pluginId), '1');
log_message('info', "Plugin enabled: {$pluginId}");
return true;
@@ -128,7 +128,7 @@ class PluginManager
return false;
}
$this->configModel->set($this->getEnabledKey($pluginId), '0');
$this->configModel->setValue($this->getEnabledKey($pluginId), '0');
log_message('info', "Plugin disabled: {$pluginId}");
return true;
@@ -154,12 +154,12 @@ class PluginManager
public function getSetting(string $pluginId, string $key, mixed $default = null): mixed
{
return $this->configModel->get("{$pluginId}_{$key}") ?? $default;
return $this->configModel->getValue("{$pluginId}_{$key}") ?? $default;
}
public function setSetting(string $pluginId, string $key, mixed $value): bool
{
return $this->configModel->set("{$pluginId}_{$key}", $value);
return $this->configModel->setValue("{$pluginId}_{$key}", $value);
}
private function getEnabledKey(string $pluginId): string

View File

@@ -23,7 +23,7 @@ class PluginConfig extends Model
return ($builder->get()->getNumRows() === 1);
}
public function get(string $key): ?string
public function getValue(string $key): ?string
{
$builder = $this->db->table('plugin_config');
$query = $builder->getWhere(['key' => $key], 1);
@@ -35,7 +35,7 @@ class PluginConfig extends Model
return null;
}
public function set(string $key, string $value): bool
public function setValue(string $key, string $value): bool
{
$builder = $this->db->table('plugin_config');
@@ -84,7 +84,7 @@ class PluginConfig extends Model
$this->db->transStart();
foreach ($data as $key => $value) {
$success &= $this->set($key, $value);
$success &= $this->setValue($key, $value);
}
$this->db->transComplete();