Skip to content

Upgrade to Laravel 13 and PHP 8.5 (Ubuntu 26.04) - #149

Draft
TurnerCam wants to merge 77 commits into
kwartzlab:mainfrom
TurnerCam:shift-13
Draft

TurnerCam wants to merge 77 commits into
kwartzlab:mainfrom
TurnerCam:shift-13

Conversation

@TurnerCam

@TurnerCam TurnerCam commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Background, decisions and the review guide: kOS — Laravel 9 → 13 Upgrade

What and why

kOS moves from Laravel 9 to Laravel 13.43, PHPUnit 12, and PHP 8.5 (Ubuntu 26.04). Laravel 9 has been out of support since 2024, and every planned feature depends on a current framework. The upgrade was done one version at a time with Laravel Shift, like-for-like: no behaviour change and no new features in the upgrade steps.

This is well over the ~500-line guideline. Most of the diff is composer.lock and Shift's generated changes. Review it one step at a time with the table below.

  • One database change: Laravel 10 renames password_resets to password_reset_tokens. Pending tokens are kept, and deploy.sh runs the migration.
  • Members stay logged in: the old session cookie name and cache prefix are kept.
  • Requires PHP 8.3 or newer on the server. The target is PHP 8.5 on Ubuntu 26.04.

How to review: one step at a time

The branches stack, so each step has its own small diff:

Step Compare
Safety tests written before the upgrade (also open as #143) main...upgrade-safety-tests
Laravel 9 → 10 upgrade-safety-tests...shift-10
Laravel 10 → 11 (slim application structure) shift-10...shift-11
Laravel 11 → 12, PHPUnit 11 and 12 shift-11...shift-12
Laravel 12 → 13 shift-12...bc002bd
After the upgrade: fixes, environment panel, Ubuntu 26.04 / PHP 8.5 bc002bd...shift-13

In each step, Shift's own commits come first and the hand fixes come last, in a commit named "Finish the Laravel N upgrade".

Commits after the upgrade (not like-for-like):

  • Ubuntu 26.04 and PHP 8.5: the Docker image is built on ubuntu:26.04, and CI runs on PHP 8.5.
  • Environment info panel: a collapsible panel on the login page, outside production only, and the same details at /devinfo for superusers only. Tests are included. It replaces a temporary version badge that was added during the upgrade.
  • Fixes found while testing: a fresh migrate now builds production's schema and works on MySQL; an admin editing a member must fill in the address fields (a blank field gave a server error on MySQL).
  • CI uses the project's own PHPUnit. The lint (Pint) job is expected to fail: the existing code was never formatted with Pint. A Pint-only PR is proposed for later, so this diff stays readable.

Worth knowing as a developer

  • Laravel 11's slim structure: the Kernel.php files and several providers are gone. Middleware, CSRF exceptions and routing are in bootstrap/app.php, providers are in bootstrap/providers.php, and the schedule is in routes/console.php.
  • Carbon 3: diffIn*() now returns a signed float. Pass true for an absolute value, or handle negatives in any new call.

How I tested it

  • Automated: 277 tests, 679 assertions pass in CI on PHP 8.5.13. Locally the suite was green at every step on PHP 8.3.
  • By hand, every step: each Laravel version was tested against a Laravel 9 copy running side by side, with a written test plan for each step. For Laravel 13 the plan covered photos, forms and CSRF, logins and sessions, membership status and email, and a sweep of the other pages. A real POST /keys from a device, sent without a CSRF token, still returns 200.
  • Target platform: a VM running Ubuntu 26.04, PHP 8.5 and MySQL 8.4.13.

Checklist

  • I have read, understood, and agree to the terms in GOVERNANCE.md and COLLABORATION.md
  • I wrote this contribution, or have the right to submit it, and I license it under the GNU Affero General Public License v3.0 or later
  • I have tested locally in my Docker environment and am confident in this code
  • I have added or updated automated tests to cover this work
  • I have kept changes under ~500 lines (excluding lockfiles, generated files and tests), or explained why this isn't valid below
  • If AI-assisted: I used this AI tool or model: Laravel Automated Shift service (paid) validated by Claude Opus 5.5, and I have read, run and understood every single line
  • If this change touches a sensitive area (authentication, access control, private member data, privileged reports, audit logs, deploy pipeline, or backups): I am aware this will need two reviewers and a heads-up to the board
  • [NA] If this work needs a decision record (new framework, library or language, core refactor, infrastructure change, member-workflow change) I have created and included one.

The 500-line guideline is set aside for this bundle because 99% of it was generated by the automated Shift service, with Cam manually checking after each step. There is no decision record: the team already knows the Laravel Shift upgrade plan well. It touches authentication, CSRF and middleware, so it needs two reviewers.

This PR supersedes #143: its safety tests are the first step here.

Rollout notes

  • Auto-deploy is suspended for this bundle, so merging does not deploy. The board will be notified before it goes to production.
  • Production does not use Docker. The production server needs PHP 8.3 or newer (8.5 is the target) before this is deployed. The plan is a new Ubuntu 26.04 server that is tested first and then switched in. Details are in "kOS — Upgrade & Cutover".
  • On deploy: composer install, then php artisan migrate, which renames password_resets.
  • Revert: do not switch to the new server, or revert this PR and redeploy on the old server. The one migration has a down() that renames the table back.

Not in this PR

Bugs that testing found but that are older than the upgrade (they also happen on Laravel 9), and the proposed improvements. Both are listed in the upgrade doc.

AI use: the review, fixes, tests and docs were done with Claude Code.

🤖 Generated with Claude Code

TurnerCam and others added 30 commits November 16, 2026 09:32
Widens test coverage of kOS so each step of the Laravel upgrade can be
checked against current behaviour: permissions on admin pages and
actions, membership status changes and the nightly status job, the
gatekeeper device API, the token API, the membership application,
training requests, scheduled jobs, a page smoke test, schema and audit
log checks. The suite grows from 98 to 266 tests.

Also fixes small bugs the tests exposed: API outbox routes shadowed by
/form_submissions/{id}, server errors when recording or deleting status
changes with bad input, the nightly status job crashing on a member with
no status history, inactive-in-memoriam not setting the withdrawal date,
blank team admin pages for members without access, and an undefined
variable in UserStatusFactory.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ubuntu:lateslt installs PHP 8.5 as of August 2026 which the locked packages do not support. Fixes kwartzlab#137
Accessing Faker properties was deprecated in Faker 1.14.
In an effort to make upgrading the constantly changing config files easier, Shift defaulted them and merged your true customizations - where ENV variables may not be used.
Shift turned docblock types into real PHP types. Where the docblocks were wrong,
pages and commands crashed instead of behaving as they did on Laravel 9:

- User::roles() returns HasMany or BelongsToMany depending on its argument;
  declare both.
- Remove return types from 17 controller, mailable and console methods that
  can end without returning (old behaviour: blank page / no-op).
- Remove the int type from 32 controller $id parameters filled from the URL,
  so non-numeric segments such as /users/index no longer give a 500.
- HttpsProtocolTest: the stand-in next middleware now returns a response,
  as real middleware does.
- composer.lock for Laravel 10.50.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- composer.lock: phpunit 10.5.67, collision 7.12.
- phpunit.xml migrated with `phpunit --migrate-configuration`.
- Rename the private status() test helpers in ApiTest and StatusChangesTest
  to addStatus(); PHPUnit 10 has a final TestCase::status().
- UpdateStatusTest: accept the provider's $shouldSend argument (PHPUnit 10
  deprecation, an error in PHPUnit 11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions.

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
laravel-shift and others added 28 commits November 18, 2026 17:08
- Restore kOS's original storage disks. Laravel 12 moved the default
  local disk to storage/app/private and adds a /storage/{path} route for
  it, which overlapped the public photo URLs.
- Remove the int return type Shift re-added on three console commands
  that can end without returning.
- Drop the new "composer run dev" and "setup" scripts and the
  concurrently package: they assume Vite and a queue worker, which kOS
  does not use.
- composer.lock: Laravel 12.73.0, owen-it/laravel-auditing 14.

Full suite: 266 tests green on Laravel 12.73.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- composer.lock: PHPUnit 12.5.44.
- phpunit.xml migrated with --migrate-configuration (schema 12.5).
- PermissionsTest: the "ordinary member is refused" test now accepts all
  three values from its shared data provider. PHPUnit 12 warns when a
  provider passes more arguments than a test takes.

Full suite: 266 tests green, no PHPUnit deprecations or warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A small red label on the login page so testers can tell which server
(and which Laravel) they are on during the upgrade. Remove it once the
Laravel 13 upgrade is finished.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In an effort to make upgrading the constantly changing config files easier, Shift defaulted them and merged your true customizations - where ENV variables may not be used.
- Photos: call Intervention Image v2 directly (ImageManagerStatic).
  Laravel 13 binds its own image service to the "image" container key,
  which the old Image facade resolved to, so every photo upload failed.
  The now-unused Image alias and Intervention service provider are removed.
- Remove beyondcode/laravel-dump-server: it does not support Laravel 13
  and nothing in kOS uses it.
- Keep the old session cookie name and cache prefix defaults, which
  Laravel 13 changed (members stay logged in across the upgrade).
- Restore like-for-like where Shift added new defaults: no "serve" on the
  local disk (it re-adds the /storage/{path} route), no JSON error
  rendering for api/* requests, and no "composer run dev"/"setup" scripts
  or their npm packages.
- composer.lock: Laravel 13.43.0, Tinker 3.

Shift's rename of the CSRF middleware to PreventRequestForgery keeps the
/keys exemption; the device CSRF test passes and a real POST /keys
without a token returns 200.

Full suite: 266 tests green on Laravel 13.43.0 / PHPUnit 12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the temporary red version label on the login page. Outside production,
the login page shows a collapsible panel with the operating system, PHP, web
server, database, Laravel, environment, debug flag, git branch and commit, and
key package versions. Production never shows it.

Superusers can see the same details at /devinfo in every environment. The page
checks is_superuser() directly, so no role permission can open it.

Every probe is wrapped, so a failure shows "unavailable" and the login page
keeps working when the database is down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Laravel 13 needs PHP 8.3. The lint job installed PHP 8.1, and the test job used
whatever PHP and global phpunit the runner happened to have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since Laravel 11 (native column renames, no Doctrine DBAL) a column added in
the same Schema::table call as a rename is created first, so "after
submit_options" failed on MySQL: Unknown column 'submit_options'. Laravel 9 ran
the rename first. Doing the rename and the add in two steps gives the same
table as before. Existing databases already ran this migration and are not
affected; the tests use SQLite, which ignores column positions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fresh install differed from production (and from every copy of it) in ways
that already existed on Laravel 9:
- audits: auditable_id was a bigint placed after auditable_type, with the index
  in that order. Production's table was made by the morphs() of 2018: an
  unsigned integer id first, then the type, indexed (id, type).
- users first_name, last_name, address, city, province, postal,
  gatekeepers.type, form_submissions submitter_ip and submitter_agent were
  nullable; production has them required.

The original migrations now build production's tables. Production and other
existing databases already ran them and do not change. The required columns are
added nullable and then changed, because SQLite cannot add a required column
without a default.

Two tests stored rows production would refuse: the API test's form submissions
now carry the IP and browser the app always records, and the "edit a member"
action sends the address fields the edit form always sends.

Checked: a fresh migrate on MySQL 8.0 and 8.4 gives table definitions identical
to production's; migrate:reset and migrate again work; 272 tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The address, city, province and postal columns are NOT NULL, and blank form
fields arrive as null, so clearing one on the member edit page gave a server
error on MySQL. The edit now refuses a blank field with a message, as the
member's own profile page already did, and the form marks them as required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the db:seed guard (kwartzlab#140), the Ubuntu 24.04 pin (kwartzlab#138),
the CODEOWNERS update and the membership coordinator name (kwartzlab#145).
The Docker image is now built on ubuntu:26.04, whose default php package is
PHP 8.5, and CI runs the tests and lint on PHP 8.5 to match. The 24.04 pin
kept PHP 8.3 only while the Laravel 9 to 13 steps needed it.

Tested on a VM running Ubuntu 26.04 with PHP 8.5 and MySQL 8.4.13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants