From 79a2e017bbf5d4d634e890199e3267d9280f1db1 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Thu, 11 Jun 2026 14:24:09 +0100 Subject: [PATCH] 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 --- .forgejo/workflows/analyse-php.yml | 2 +- .forgejo/workflows/test-migrations.yml | 10 ++++- .forgejo/workflows/test-php.yml | 2 +- app/Sorting/BookSortMapItem.php | 39 ++++--------------- app/Sorting/BookSorter.php | 2 +- .../HtmlPurifier/ConfiguredHtmlPurifier.php | 1 - 6 files changed, 19 insertions(+), 37 deletions(-) diff --git a/.forgejo/workflows/analyse-php.yml b/.forgejo/workflows/analyse-php.yml index 8975d6e52..3a07d9bd5 100644 --- a/.forgejo/workflows/analyse-php.yml +++ b/.forgejo/workflows/analyse-php.yml @@ -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 diff --git a/.forgejo/workflows/test-migrations.yml b/.forgejo/workflows/test-migrations.yml index e969d3e47..5848f54d9 100644 --- a/.forgejo/workflows/test-migrations.yml +++ b/.forgejo/workflows/test-migrations.yml @@ -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 diff --git a/.forgejo/workflows/test-php.yml b/.forgejo/workflows/test-php.yml index 06a6de276..99e1af518 100644 --- a/.forgejo/workflows/test-php.yml +++ b/.forgejo/workflows/test-php.yml @@ -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 diff --git a/app/Sorting/BookSortMapItem.php b/app/Sorting/BookSortMapItem.php index 8f517edd6..40137fc49 100644 --- a/app/Sorting/BookSortMapItem.php +++ b/app/Sorting/BookSortMapItem.php @@ -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, + ) { } } diff --git a/app/Sorting/BookSorter.php b/app/Sorting/BookSorter.php index 0862aaa88..63c66b0fd 100644 --- a/app/Sorting/BookSorter.php +++ b/app/Sorting/BookSorter.php @@ -168,7 +168,7 @@ class BookSorter $model->priority = $sortMapItem->sort; } - if ($chapterChanged || $priorityChanged) { + if ($priorityChanged || $chapterChanged) { $model::withoutTimestamps(fn () => $model->save()); } } diff --git a/app/Util/HtmlPurifier/ConfiguredHtmlPurifier.php b/app/Util/HtmlPurifier/ConfiguredHtmlPurifier.php index 307cdb74f..87ed5add2 100644 --- a/app/Util/HtmlPurifier/ConfiguredHtmlPurifier.php +++ b/app/Util/HtmlPurifier/ConfiguredHtmlPurifier.php @@ -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);