From 386f976dcc57a5998958c738bc5d1df59dd6f4db Mon Sep 17 00:00:00 2001 From: BudsieBuds Date: Wed, 28 Oct 2026 12:58:14 +0100 Subject: [PATCH] feat(php): add PHP 8.5 support, resolve deprecations, and optimize CI workflows (#4776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extend composer.json and composer.lock PHP requirement to include PHP 8.5 - Add PHP 8.5 to test matrix in phpunit.yml and main.yml workflows - Modernize php-linter.yml to use setup-php@v2 with parallel matrix for PHP 8.2–8.5 - Propagate PHP 8.2 lint failures via shell loop in find -exec + while retaining batching for 8.3–8.5 - Add permissions: contents: read and cancel-in-progress concurrency to php-linter.yml - Remove obsolete Node.js and npm install steps from phpunit.yml - Update phpunit.yml runner to ubuntu-latest and composer cache action to v4 - Address PHP 8.5 deprecations and syntax: - Replace deprecated switch-case semicolon with standard colon in app/Config/Database.php - Replace non-standard (double) cast with (float) in app/Libraries/Token_lib.php - Remove obsolete curl_close() calls in app/Config/Validation/OSPOSRules.php and app/Libraries/Mailchimp_lib.php - Update INSTALL.md, workflows README, and bug report issue template to include PHP 8.5 --- .github/ISSUE_TEMPLATE/bug report.yml | 1 + .github/workflows/README.md | 4 +-- .github/workflows/main.yml | 1 + .github/workflows/php-linter.yml | 44 ++++++++++++++++++--------- .github/workflows/phpunit.yml | 24 ++------------- app/Config/Database.php | 2 +- app/Config/Validation/OSPOSRules.php | 2 -- app/Libraries/Mailchimp_lib.php | 2 -- app/Libraries/Token_lib.php | 2 +- composer.json | 2 +- composer.lock | 4 +-- docs/INSTALL.md | 2 +- 12 files changed, 43 insertions(+), 47 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug report.yml b/.github/ISSUE_TEMPLATE/bug report.yml index 571f7cc91..c23f5754d 100644 --- a/.github/ISSUE_TEMPLATE/bug report.yml +++ b/.github/ISSUE_TEMPLATE/bug report.yml @@ -81,6 +81,7 @@ body: label: 🔧 PHP Version description: What version of PHP are you running? options: + - PHP 8.5 - PHP 8.4 - PHP 8.3 - PHP 8.2 diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 8243c1eb8..2b5a1af1d 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -50,12 +50,12 @@ The `GITHUB_TOKEN` is automatically provided by GitHub Actions. This repository also has these workflows: - `.github/workflows/main.yml` - PHP linting with PHP-CS-Fixer -- `.github/workflows/phpunit.yml` - PHPUnit tests (runs on all PHP versions 8.1-8.4) +- `.github/workflows/phpunit.yml` - PHPUnit tests (runs on all PHP versions 8.2-8.5) - `.github/workflows/php-linter.yml` - PHP linting ## Testing -PHPUnit tests are run separately via `.github/workflows/phpunit.yml` on every push and pull request, testing against PHP 8.1, 8.2, 8.3, and 8.4. +PHPUnit tests are run separately via `.github/workflows/phpunit.yml` on every push and pull request, testing against PHP 8.2, 8.3, 8.4, and 8.5. To test the build workflow: 1. Add the required secrets diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ecdc4753..176e7fa9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' steps: - name: Checkout diff --git a/.github/workflows/php-linter.yml b/.github/workflows/php-linter.yml index e31d40304..46ba9556f 100644 --- a/.github/workflows/php-linter.yml +++ b/.github/workflows/php-linter.yml @@ -2,25 +2,41 @@ name: PHP Linting on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + jobs: phplint: - + name: PHP Lint ${{ matrix.php-version }} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: + - '8.2' + - '8.3' + - '8.4' + - '8.5' steps: - name: Checkout uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - fetch-depth: 0 - - name: PHP Lint 8.2 - uses: dbfx/github-phplint/8.2@master - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\"" - - name: PHP Lint 8.3 - uses: dbfx/github-phplint/8.3@master - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\"" - - name: PHP Lint 8.4 - uses: dbfx/github-phplint/8.4@master - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./folder/excluded/*\"" + php-version: ${{ matrix.php-version }} + coverage: none + + - name: Run PHP Lint + run: | + if [ "${{ matrix.php-version }}" = "8.2" ]; then + find . -type f -name "*.php" ! -path "./vendor/*" ! -path "./node_modules/*" -exec sh -c 'for file do php -l "$file" || exit 1; done' sh {} + + else + find . -type f -name "*.php" ! -path "./vendor/*" ! -path "./node_modules/*" -exec php -l {} + + fi + php -l spark diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b8fee39ea..00b51dd18 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -28,7 +28,7 @@ permissions: jobs: test: name: PHP ${{ matrix.php-version }} / ${{ matrix.db-image }} Tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: false @@ -37,6 +37,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' db-image: - 'mariadb:10.5' - 'mariadb:10.6' @@ -72,25 +73,6 @@ jobs: fi echo "PHP $ACTUAL meets minimum $MIN" - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Get npm cache directory - run: echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_ENV - - - name: Cache npm dependencies - uses: actions/cache@v3 - with: - path: ${{ env.NPM_CACHE_DIR }} - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Install npm dependencies - run: npm install - - name: Start database run: | docker run -d --name mysql \ @@ -124,7 +106,7 @@ jobs: run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.COMPOSER_CACHE_FILES_DIR }} key: ${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} diff --git a/app/Config/Database.php b/app/Config/Database.php index 5738ad62f..3a7565977 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -127,7 +127,7 @@ class Database extends Config case 'testing': $this->defaultGroup = 'tests'; break; - case 'development'; + case 'development': $this->defaultGroup = 'development'; break; } diff --git a/app/Config/Validation/OSPOSRules.php b/app/Config/Validation/OSPOSRules.php index 5276726b8..99a2ff318 100644 --- a/app/Config/Validation/OSPOSRules.php +++ b/app/Config/Validation/OSPOSRules.php @@ -86,8 +86,6 @@ class OSPOSRules $result = curl_exec($ch); - curl_close($ch); - $status = json_decode($result, true); if (!empty($status['success'])) { diff --git a/app/Libraries/Mailchimp_lib.php b/app/Libraries/Mailchimp_lib.php index a3b2b3937..4295a4610 100644 --- a/app/Libraries/Mailchimp_lib.php +++ b/app/Libraries/Mailchimp_lib.php @@ -117,8 +117,6 @@ class MailchimpConnector curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb); $result = curl_exec($ch); - - curl_close($ch); } return $result ? json_decode($result, true) : false; diff --git a/app/Libraries/Token_lib.php b/app/Libraries/Token_lib.php index e260240e1..6d3b670c8 100644 --- a/app/Libraries/Token_lib.php +++ b/app/Libraries/Token_lib.php @@ -178,7 +178,7 @@ class Token_lib $quantity = (isset($parsed_results['W'])) ? (int) $parsed_results['W'] / 1000 : 1; $item_id_or_number_or_item_kit_or_receipt = (isset($parsed_results['I'])) ? $parsed_results['I'] : $item_id_or_number_or_item_kit_or_receipt; - $price = (isset($parsed_results['P'])) ? (double) $parsed_results['P'] : null; + $price = (isset($parsed_results['P'])) ? (float) $parsed_results['P'] : null; } } else { $quantity = 1; diff --git a/composer.json b/composer.json index c74786a25..ba8c3dd1f 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "matrix": "https://matrix.to/#/#opensourcepos_Lobby:gitter.im" }, "require": { - "php": ">=8.2.35 <8.3 || >=8.3.36 <8.4 || >=8.4.27", + "php": ">=8.2.35 <8.3 || >=8.3.36 <8.4 || >=8.4.27 <8.5 || >=8.5.12 <8.6", "ext-intl": "*", "codeigniter4/framework": "4.7.4", "dompdf/dompdf": "^3.1.6", diff --git a/composer.lock b/composer.lock index 5b681415a..7069e2f88 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5b7bf691a189373a64ba0cd8c9b3e46a", + "content-hash": "13515c65b00fddcbe40933bd582f44f1", "packages": [ { "name": "codeigniter4/framework", @@ -5224,7 +5224,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.2.35 <8.3 || >=8.3.36 <8.4 || >=8.4.27", + "php": ">=8.2.35 <8.3 || >=8.3.36 <8.4 || >=8.4.27 <8.5 || >=8.5.12 <8.6", "ext-intl": "*" }, "platform-dev": {}, diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 8b41f5ed1..1bf8870d6 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -1,6 +1,6 @@ ## Server Requirements -- PHP version `8.2.35` to `8.4.27` are supported (minimum patch levels required for CVE-2026-109618 / CVE-2026-109619 security fixes). PHP version `≤ 8.1` is NOT supported. Please note that PHP needs to have the extensions `php-json`, `php-gd`, `php-bcmath`, `php-intl`, `php-openssl`, `php-mbstring`, `php-curl` and `php-xml` installed and enabled. An unstable master build can be downloaded in the releases section. +- PHP version `8.2` (>= `8.2.35`), `8.3` (>= `8.3.36`), `8.4` (>= `8.4.27`), and `8.5` (>= `8.5.12`) are supported (minimum patch levels required for CVE-2026-109618 / CVE-2026-109619 security fixes). PHP version `≤ 8.1` is NOT supported. Please note that PHP needs to have the extensions `php-json`, `php-gd`, `php-bcmath`, `php-intl`, `php-openssl`, `php-mbstring`, `php-curl` and `php-xml` installed and enabled. An unstable master build can be downloaded in the releases section. - MySQL `5.7` is supported, also MariaDB replacement `10.x` is supported and might offer better performance. - Apache `2.4` is supported. Nginx should work fine too, see [wiki page here](https://github.com/opensourcepos/opensourcepos/wiki/Local-Deployment-using-LEMP). - Raspberry PI based installations proved to work, see [wiki page here]().