Maintenance: Fixed type and CI issues

- Fixed issues picked up by PHPStan updates.
  - Not sure why it was flagging the BookSorter issue, but swapping if
    statements made it go away.
- Updated BookSortMapItem with modern syntax.
- Attempted to fix CI issues by adding DOM extension.
- Attempted to make migration CI more efficient via tmpfs
This commit is contained in:
Dan Brown
2026-06-11 14:24:09 +01:00
parent c74df7e06b
commit 79a2e017bb
6 changed files with 19 additions and 37 deletions

View File

@@ -22,7 +22,7 @@ jobs:
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: 8.5
extensions: gd, mbstring, json, curl, xml, mysql, ldap
extensions: gd, mbstring, json, curl, xml, dom, mysql, ldap
- name: Get Composer Cache Directory
id: composer-cache

View File

@@ -23,6 +23,14 @@ jobs:
services:
mysql:
image: docker.io/library/mariadb:12.2.2-noble
options: --tmpfs /var/lib/mysql:rw
cmd:
- --innodb-flush-log-at-trx-commit=0
- --innodb-flush-method=O_DIRECT
- --innodb-doublewrite=0
- --innodb-buffer-pool-size=256M
- --skip-log-bin
- --sync-binlog=0
env:
MARIADB_USER: bookstack-test
MARIADB_PASSWORD: bookstack-test
@@ -35,7 +43,7 @@ jobs:
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, mbstring, json, curl, xml, mysql, ldap
extensions: gd, mbstring, json, curl, xml, dom, mysql, ldap
- name: Get Composer Cache Directory
id: composer-cache

View File

@@ -21,7 +21,7 @@ jobs:
matrix:
php: ['8.2', '8.3', '8.4', '8.5']
env:
phpextensions: gd, mbstring, json, curl, xml, mysql, ldap, gmp
phpextensions: gd, mbstring, json, curl, xml, dom, mysql, ldap, gmp
phpextensioncachekey: cache-v1
steps:
- uses: https://code.forgejo.org/actions/checkout@v6

View File

@@ -4,37 +4,12 @@ namespace BookStack\Sorting;
class BookSortMapItem
{
/**
* @var int
*/
public $id;
/**
* @var int
*/
public $sort;
/**
* @var ?int
*/
public $parentChapterId;
/**
* @var string
*/
public $type;
/**
* @var int
*/
public $parentBookId;
public function __construct(int $id, int $sort, ?int $parentChapterId, string $type, int $parentBookId)
{
$this->id = $id;
$this->sort = $sort;
$this->parentChapterId = $parentChapterId;
$this->type = $type;
$this->parentBookId = $parentBookId;
public function __construct(
public int $id,
public int $sort,
public int|null $parentChapterId,
public string $type,
public int $parentBookId,
) {
}
}

View File

@@ -168,7 +168,7 @@ class BookSorter
$model->priority = $sortMapItem->sort;
}
if ($chapterChanged || $priorityChanged) {
if ($priorityChanged || $chapterChanged) {
$model::withoutTimestamps(fn () => $model->save());
}
}

View File

@@ -38,7 +38,6 @@ class ConfiguredHtmlPurifier
$this->configureHtmlDefinition($htmlDef);
}
/** @var \HTMLPurifier_URIDefinition $uriDef */
$uriDef = $config->getDefinition('URI', true, true);
if ($uriDef instanceof HTMLPurifier_URIDefinition) {
$this->configureUriDefinition($uriDef);