Skip to content

Commit 4cd5268

Browse files
lscharmermjansenDatabay
authored andcommitted
Database: Simplify ildbpdo inheritance structure
1 parent 170e094 commit 4cd5268

10 files changed

Lines changed: 291 additions & 353 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Database\PDO;
22+
23+
use ilDBInterface;
24+
use ilAtomQuery;
25+
26+
interface Details
27+
{
28+
public function supportsTransactions(): bool;
29+
public function atomQuery(ilDBInterface $db): ilAtomQuery;
30+
}

components/ILIAS/Database/classes/PDO/ilDBPdoMySQLGalera.php renamed to components/ILIAS/Database/classes/PDO/GaleraDetails.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
*********************************************************************/
1818

1919
declare(strict_types=1);
20-
/**
21-
* Class ilDBPdoMySQLInnoDB
22-
*
23-
* @author Fabian Schmid <fs@studer-raimann.ch>
24-
*/
25-
class ilDBPdoMySQLGalera extends ilDBPdoMySQLInnoDB
20+
21+
namespace ILIAS\Database\PDO;
22+
23+
use ilAtomQuery;
24+
use ilAtomQueryTransaction;
25+
use ilDBInterface;
26+
27+
class GaleraDetails implements Details
2628
{
2729
#[\Override]
2830
public function supportsTransactions(): bool
@@ -31,8 +33,8 @@ public function supportsTransactions(): bool
3133
}
3234

3335
#[\Override]
34-
public function buildAtomQuery(): ilAtomQuery
36+
public function atomQuery(ilDBInterface $db): ilAtomQuery
3537
{
36-
return new ilAtomQueryTransaction($this);
38+
return new ilAtomQueryTransaction($db);
3739
}
3840
}

components/ILIAS/Database/classes/PDO/ilDBPdoMySQLInnoDB.php renamed to components/ILIAS/Database/classes/PDO/InnoDBDetails.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,38 @@
1717
*********************************************************************/
1818

1919
declare(strict_types=1);
20+
21+
namespace ILIAS\Database\PDO;
22+
23+
use ILIAS\Database\FieldDefinition;
24+
use PDO;
25+
use ilDBConstants;
26+
use ilDBInterface;
27+
use ilDBManager;
28+
use ilDBReverse;
29+
use ilDBPdoManager;
30+
use ilDBPdoReverse;
31+
use ilDBPdoMySQLFieldDefinition;
32+
use PDOException;
33+
use ilDatabaseException;
34+
use Exception;
35+
use ilAtomQuery;
36+
use ilAtomQueryLock;
37+
2038
/**
21-
* Class ilDBPdoMySQLInnoDB
22-
*
2339
* @author Fabian Schmid <fs@studer-raimann.ch>
2440
*/
25-
class ilDBPdoMySQLInnoDB extends ilDBPdoMySQL
41+
class InnoDBDetails implements Details
2642
{
27-
protected string $storage_engine = 'InnoDB';
28-
29-
#[\Override]
30-
public function supportsFulltext(): bool
31-
{
32-
return false;
33-
}
34-
35-
3643
#[\Override]
3744
public function supportsTransactions(): bool
3845
{
3946
return false;
4047
}
4148

42-
4349
#[\Override]
44-
public function addFulltextIndex(string $table_name, array $fields, string $name = 'in'): bool
50+
public function atomQuery(ilDBInterface $db): ilAtomQuery
4551
{
46-
return false; // NOT SUPPORTED
52+
return new ilAtomQueryLock($db);
4753
}
4854
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Database\PDO;
22+
23+
use ilDBInterface;
24+
use ilDBPdoInterface;
25+
26+
interface Internal extends ilDBInterface, ilDBPdoInterface
27+
{
28+
public function getFieldDefinition(): ?\ilDBPdoFieldDefinition;
29+
public function getIndexName(string $index_name_base): string;
30+
}

components/ILIAS/Database/classes/PDO/Manager/ilDBPdoManager.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
declare(strict_types=1);
2020

2121
use ILIAS\Database\PDO\FieldDefinition\ForeignKeyConstraints;
22+
use ILIAS\Database\PDO\Internal;
2223

2324
/**
2425
* Class ilDBPdoManager
@@ -28,10 +29,7 @@ class ilDBPdoManager implements ilDBManager, ilDBPdoManagerInterface
2829
{
2930
protected ?\ilQueryUtils $query_utils = null;
3031

31-
/**
32-
* ilDBPdoManager constructor.
33-
*/
34-
public function __construct(protected \PDO $pdo, protected \ilDBPdo $db_instance)
32+
public function __construct(protected \PDO $pdo, protected Internal $db_instance)
3533
{
3634
}
3735

@@ -44,7 +42,7 @@ public function getQueryUtils(): \ilQueryUtils
4442
return $this->query_utils;
4543
}
4644

47-
public function getDBInstance(): \ilDBPdo
45+
public function getDBInstance(): Internal
4846
{
4947
return $this->db_instance;
5048
}

components/ILIAS/Database/classes/PDO/Reverse/ilDBPdoReverse.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
declare(strict_types=1);
2020

21+
use ILIAS\Database\PDO\Internal;
22+
2123
/**
2224
* Class ilDBPdoReverse
2325
* @author Fabian Schmid <fs@studer-raimann.ch>
@@ -26,10 +28,7 @@ class ilDBPdoReverse implements ilDBReverse
2628
{
2729
protected ?\ilMySQLQueryUtils $query_utils = null;
2830

29-
/**
30-
* ilDBPdoReverse constructor.
31-
*/
32-
public function __construct(protected \PDO $pdo, protected \ilDBPdo $db_instance)
31+
public function __construct(protected \PDO $pdo, protected Internal $db_instance)
3332
{
3433
}
3534

0 commit comments

Comments
 (0)