Skip to content

Commit d495931

Browse files
committed
fix
1 parent ebf90bf commit d495931

File tree

7 files changed

+14
-25
lines changed

7 files changed

+14
-25
lines changed

docs/plugins.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MyPluginConfiguration implements PluginConfigurationInterface
3030
}
3131
}
3232
```
33-
These predefined values ​​in the file form the basis for the configuration options in the backend plugin overview. All future changes to these values ​​in the backend plugin settings will be saved in the database.
33+
These predefined values in the file form the basis for the configuration options in the backend plugin overview. All future changes to these values in the backend plugin settings will be saved in the database.
3434

3535
## 9.3 Plugin development
3636

@@ -91,11 +91,13 @@ class MyPlugin implements PluginInterface
9191
return 'phpMyFAQ Team';
9292
}
9393

94+
// Extended description of the plugin that will be displayed in the plugin settings
9495
public function getAdvDescription(): string
9596
{
9697
return 'A simple Hello World plugin that demonstrates event handling in phpMyFAQ and with Configuration options.';
9798
}
9899

100+
// Implementation of the plugin that will be displayed in the plugin settings
99101
public function getImplementation(): string
100102
{
101103
return '{{ phpMyFAQPlugin(\'hello.world\', \'Hello, World!\') | raw }} oder {{ phpMyFAQPlugin(\'user.login\', \'John Doe\') | raw }}';

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/PluginController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class PluginController extends AbstractAdministrationController
3232
public function toggleStatus(Request $request): JsonResponse
3333
{
3434
$csrfToken = $request->headers->get('X-CSRF-Token');
35-
if (!Token::getInstance($this->session)->verifyToken($csrfToken, 'admin-plugins')) {
35+
if (!Token::getInstance($this->session)->verifyToken('admin-plugins', $csrfToken)) {
3636
return new JsonResponse(['success' => false, 'message' => 'Invalid CSRF token'], 403);
3737
}
3838

@@ -79,8 +79,7 @@ public function saveConfig(Request $request): JsonResponse
7979
}
8080

8181
$csrfToken = $data['csrf'] ?? $request->headers->get('X-CSRF-Token');
82-
if (!Token::getInstance($this->session)->verifyToken($csrfToken, 'admin-plugins')) {
83-
return new JsonResponse(['success' => false, 'message' => 'Invalid CSRF token'], 403);
82+
if (!Token::getInstance($this->session)->verifyToken('admin-plugins', $csrfToken)) { return new JsonResponse(['success' => false, 'message' => 'Invalid CSRF token'], 403);
8483
}
8584

8685
$pluginManager = $this->container->get(id: 'phpmyfaq.plugin.plugin-manager');

phpmyfaq/src/phpMyFAQ/Database/Mysqli.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ public function fetchAll(mixed $result): ?array
170170
$result = $result->result;
171171
}
172172

173-
if ($result instanceof MysqliStatement) {
174-
$result = $result->result;
175-
}
176-
177173
$ret = [];
178174
if (false === $result) {
179175
throw new Exception('Error while fetching result: ' . $this->error());
@@ -287,7 +283,6 @@ public function getTableNames(string $prefix = ''): array
287283
$prefix . 'faqvisits',
288284
$prefix . 'faqvoting',
289285
$prefix . 'faqplugins',
290-
$prefix . 'faqplugins',
291286
];
292287
}
293288

@@ -399,9 +394,9 @@ public function execute(mixed $statement, array $params = []): bool
399394
$success = $statement->stmt->execute();
400395
if ($success) {
401396
$result = $statement->stmt->get_result();
402-
+ if ($result !== false) {
403-
+ $statement->result = $result;
404-
+ }
397+
if ($result !== false) {
398+
$statement->result = $result;
399+
}
405400
}
406401

407402
return $success;

phpmyfaq/src/phpMyFAQ/Database/Pgsql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PgsqlStatement
3434
{
3535
public function __construct(
3636
private string $name,
37-
public mixed $result = null
37+
public mixed $result = null,
3838
) {
3939
}
4040

phpmyfaq/src/phpMyFAQ/Database/Sqlite3.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ public function fetchAll(mixed $result): ?array
143143
$result = $result->result;
144144
}
145145

146-
if ($result instanceof Sqlite3Statement) {
147-
$result = $result->result;
148-
}
149-
150146
$ret = [];
151147
if (false === $result) {
152148
throw new Exception('Error while fetching result: ' . $this->error());
@@ -305,7 +301,6 @@ public function getTableNames(string $prefix = ''): array
305301
$prefix . 'faqvisits',
306302
$prefix . 'faqvoting',
307303
$prefix . 'faqplugins',
308-
$prefix . 'faqplugins',
309304
];
310305
}
311306

@@ -377,8 +372,8 @@ public function execute(mixed $statement, array $params = []): bool
377372
} elseif (is_null($param)) {
378373
$type = SQLITE3_NULL;
379374
} elseif (is_bool($param)) {
380-
+ $type = SQLITE3_INTEGER;
381-
+ $param = $param ? 1 : 0;
375+
$type = SQLITE3_INTEGER;
376+
$param = $param ? 1 : 0;
382377
}
383378
$statement->stmt->bindValue($index + 1, $param, $type);
384379
}

phpmyfaq/src/phpMyFAQ/Database/Sqlsrv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SqlsrvStatement
3131
{
3232
public function __construct(
3333
public mixed $statement,
34-
public mixed $result = null
34+
public mixed $result = null,
3535
) {
3636
}
3737

phpmyfaq/src/phpMyFAQ/Plugin/PluginManager.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function loadPlugins(): void
130130
$value = (int) $value;
131131
break;
132132
case 'bool':
133-
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
133+
$value = (bool) $value;
134134
break;
135135
case 'float':
136136
$value = (float) $value;
@@ -146,7 +146,6 @@ public function loadPlugins(): void
146146
}
147147
}
148148
} else {
149-
150149
// I will default to inactive (false) for new plugins found on disk but not in DB.
151150

152151
$isActive = false;
@@ -194,7 +193,6 @@ public function loadPlugins(): void
194193
$this->registerPluginScripts($plugin->getName(), $plugin->getScripts());
195194
}
196195
} elseif (!$this->areDependenciesMet($plugin)) {
197-
198196
$missingDeps = $this->getMissingDependencies($plugin);
199197
$this->incompatiblePlugins[$plugin->getName()] = [
200198
'plugin' => $plugin,
@@ -290,7 +288,7 @@ private function getPluginsFromDatabase(): array
290288
{
291289
$db = $this->configuration->getDb();
292290
$table = \phpMyFAQ\Database::getTablePrefix() . 'faqplugins';
293-
291+
294292
// Ensure table exists to avoid crashes during update/install if not yet run
295293
try {
296294
$result = $db->query("SELECT name, active, config FROM $table");

0 commit comments

Comments
 (0)