Skip to content

Commit 20be779

Browse files
committed
fix: corrected check on permissions, additional some refactorings
1 parent d73b378 commit 20be779

File tree

27 files changed

+79
-69
lines changed

27 files changed

+79
-69
lines changed

phpmyfaq/src/phpMyFAQ/Administration/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function setUser(User $user): void
120120
// check user rights, set them TRUE
121121
$allUserRights = $user->perm->getAllUserRights($user->getUserId());
122122
foreach ($allRights as $allRight) {
123-
if (!in_array($allRight['right_id'], $allUserRights, true)) {
123+
if (!in_array((int) $allRight['right_id'], $allUserRights, true)) {
124124
continue;
125125
}
126126

phpmyfaq/src/phpMyFAQ/Attachment/AbstractAttachment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* Abstract attachment class.
75
*
@@ -17,6 +15,8 @@
1715
* @since 2009-08-21
1816
*/
1917

18+
declare(strict_types=1);
19+
2020
namespace phpMyFAQ\Attachment;
2121

2222
use phpMyFAQ\Database;
@@ -231,7 +231,7 @@ public function saveMeta(): int
231231
{
232232
$attachmentTableName = sprintf('%sfaqattachment', Database::getTablePrefix());
233233

234-
if (null == $this->id) {
234+
if (null === $this->id) {
235235
$this->id = $this->databaseDriver->nextId($attachmentTableName, 'id');
236236

237237
$sql = sprintf(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ public function updateCheck(): JsonResponse
108108
$installed = $versions['installed'];
109109
$available = $versions[$branch];
110110

111-
if (version_compare($installed, $available, '<')) {
111+
if (version_compare($installed, $available, operator: '<')) {
112112
return $this->json([
113113
'version' => $available,
114114
'message' => Translation::get(key: 'msgCurrentVersion') . $available,
115115
'dateLastChecked' => $dateLastChecked,
116116
], Response::HTTP_OK);
117117
}
118118

119-
if ($branch !== 'nightly' && version_compare($installed, $available, '>')) {
119+
if ($branch !== 'nightly' && version_compare($installed, $available, operator: '>')) {
120120
return $this->json([
121121
'version' => $available,
122122
'message' => Translation::get(key: 'msgInstalledNewerThanAvailable'),

phpmyfaq/src/phpMyFAQ/Instance/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* The main phpMyFAQ instances class for instance clients.
75
*
@@ -17,6 +15,8 @@
1715
* @since 2012-03-31
1816
*/
1917

18+
declare(strict_types=1);
19+
2020
namespace phpMyFAQ\Instance;
2121

2222
use phpMyFAQ\Configuration;

phpmyfaq/src/phpMyFAQ/Instance/Database.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
use phpMyFAQ\Configuration;
2323
use phpMyFAQ\Core\Exception;
24-
use phpMyFAQ\Instance\Database\Driver;
24+
use phpMyFAQ\Instance\Database\DriverInterface;
2525

2626
/**
2727
* Class Database
@@ -33,7 +33,7 @@ class Database
3333
/**
3434
* Instance.
3535
*/
36-
private static ?Driver $driver = null;
36+
private static ?DriverInterface $driver = null;
3737

3838
/**
3939
* DROP TABLE statements.
@@ -91,7 +91,7 @@ private function __construct(
9191
* @param string $type Database management system type
9292
* @throws Exception
9393
*/
94-
public static function factory(Configuration $configuration, string $type): ?Driver
94+
public static function factory(Configuration $configuration, string $type): ?DriverInterface
9595
{
9696
if (str_starts_with($type, 'pdo_')) {
9797
$class = 'phpMyFAQ\Instance\Database\Pdo' . ucfirst(substr($type, 4));
@@ -111,9 +111,9 @@ public static function factory(Configuration $configuration, string $type): ?Dri
111111
/**
112112
* Returns the single instance.
113113
*/
114-
public static function getInstance(): ?Driver
114+
public static function getInstance(): ?DriverInterface
115115
{
116-
if (!self::$driver instanceof Driver) {
116+
if (!self::$driver instanceof DriverInterface) {
117117
$className = self::class;
118118
self::$driver = new $className();
119119
}

phpmyfaq/src/phpMyFAQ/Instance/Database/Driver.php renamed to phpmyfaq/src/phpMyFAQ/Instance/Database/DriverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @package phpMyFAQ\Instance\Database
2626
*/
27-
interface Driver
27+
interface DriverInterface
2828
{
2929
/**
3030
* Executes all CREATE TABLE and CREATE INDEX statements.

phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @package phpMyFAQ\Instance\Database
3030
*/
31-
class Mysqli extends Database implements Driver
31+
class Mysqli extends Database implements DriverInterface
3232
{
3333
private array $createTableStatements = [
3434
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (

phpmyfaq/src/phpMyFAQ/Instance/Database/PdoMysql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @package phpMyFAQ\Instance\Database
3030
*/
31-
class PdoMysql extends Database implements Driver
31+
class PdoMysql extends Database implements DriverInterface
3232
{
3333
private array $createTableStatements = [
3434
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (

phpmyfaq/src/phpMyFAQ/Instance/Database/PdoPgsql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @package phpMyFAQ\Instance\Database
2929
*/
30-
class PdoPgsql extends Database implements Driver
30+
class PdoPgsql extends Database implements DriverInterface
3131
{
3232
private array $createTableStatements = [
3333
'faquser_user_id_seq' => 'CREATE SEQUENCE %sfaquser_user_id_seq START WITH 2',

phpmyfaq/src/phpMyFAQ/Instance/Database/PdoSqlite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @package phpMyFAQ\Instance\Database
2929
*/
30-
class PdoSqlite extends Database implements Driver
30+
class PdoSqlite extends Database implements DriverInterface
3131
{
3232
private array $createTableStatements = [
3333
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (

0 commit comments

Comments
 (0)