Skip to content

Laravel 9 → 13 upgrade (draft for team review) - #8

Closed
TurnerCam wants to merge 81 commits into
mainfrom
shift-13
Closed

TurnerCam wants to merge 81 commits into
mainfrom
shift-13

Conversation

@TurnerCam

Copy link
Copy Markdown
Owner

Draft, for team review only. This PR is on Cam's fork and will not be merged here. Once the team has reviewed it, the work goes to kwartzlab/kos-base as a series of smaller PRs, one per step.

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

What this is

kOS upgraded from Laravel 9 to Laravel 13.43 / PHP 8.3 / PHPUnit 12, one version at a time with Laravel Shift, like-for-like (no behaviour change, no new features in the upgrade steps).

  • One database change: Laravel 10 renames password_resets to password_reset_tokens (pending tokens are kept; deploy.sh runs the migration).
  • Tests: 272 tests pass. Every step was also tested by hand against a Laravel 9 copy running side by side.
  • Requires PHP 8.3+ on the server.

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 upstream as kwartzlab#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
Extra commits after the upgrade 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". Most of the diff is composer.lock.

Extra commits (not like-for-like):

  • An environment info panel on the login page (outside production only) and at /devinfo (superusers only), with tests.
  • CI now uses PHP 8.3 and the project's PHPUnit. The lint job is expected to fail: the existing code was never formatted with Pint. A Pint-only PR is a proposed improvement, kept out of here so the diff stays readable.

Worth knowing as a developer

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

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 doc.

AI use: the review, fixes, tests and docs were done with Claude Code (per the kOS AI-use policy, this needs two human reviewers).

🤖 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 14 commits November 18, 2026 18:00
- 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>
@TurnerCam TurnerCam closed this Nov 19, 2026
@TurnerCam TurnerCam reopened this Nov 19, 2026
Fixes kwartzlab#139

## What
`docker-entrypoint.sh` now runs `php artisan db:seed` only when:
- the effective `APP_ENV` is `local`, and
- the seeded dev user `superuser-dev@kwartzlab.ca` is not already in
`users`.

An `APP_ENV` set in the container environment takes precedence over
`.env`,
as in Laravel; an unset value is treated as production. If the check
itself
fails, seeding is skipped with a message rather than guessed at.

## Why
The seeders are not idempotent, so every container restart duplicated
roles
and then failed on the unique user email, skipping the remaining
seeders.

## Testing
- `docker compose restart app` on a seeded dev DB: logs show "Database
already
  seeded; skipping db:seed.", row counts unchanged, app starts.
- Container run with `APP_ENV=production`: logs show "Skipping db:seed
outside
  the local environment."
- The unseeded path was checked by running the same query for a missing
user
(returns 0, which leads to `db:seed`); not run against an empty
database.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@TurnerCam TurnerCam closed this Nov 19, 2026
@TurnerCam TurnerCam reopened this Nov 19, 2026
TurnerCam and others added 9 commits November 20, 2026 13:05
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).
…artzlab#148)

## What and why

Closes kwartzlab#147.

In 2020, Cam and Ben drafted a "care and feeding of kOS" agreement in a
Google Doc, and over the years it went stale. Following the November 25
discussion in #project-kos-devs, this PR commits a refreshed draft to
the repository so that every future change to it is reviewed and tracked
here, like code.

This is a draft for discussion. It is documentation only, with no
application code changes.

| File | What it is |
| --- | --- |
| `GOVERNANCE.md` | The agreement itself: principles, roles, how a
change ships, sensitive areas, AI-assisted work, data and privacy,
technology baseline, decision sizes, licensing, and how this document
changes |
| `CONTRIBUTING.md` | The practical "start here" for new developers |
| `COLLABORATION.md` | The spirit of collaboration we work in. It is not
a code of conduct: it links kwartzlab's own, which still applies |
| `SECURITY.md` | How to report a vulnerability privately, and what to
expect |
| `CONTRIBUTORS.md` | Everyone who has contributed so far, taken from
the git history and listed in order of first contribution |
| `LICENSE-GRANT.md` | How existing contributors license their past work
under the AGPL-3.0. See below |
| `docs/decisions/README.md` | The decision record process and template
for larger changes |
| `.github/pull_request_template.md` | The PR checklist that
GOVERNANCE.md describes, including the licensing affirmation and AI
label |
| `CODEOWNERS` | Removes @everett-ripley for now (dormant, and welcome
back any time) and lists the first sensitive areas. Existing owners are
kept |

## Changes since the first review

Thank you to everyone who commented. The second commit:

- **Licensing.** Removes the AGPL-3.0 `LICENSE` file and README section,
and adds `LICENSE-GRANT.md` instead (see below).
- **No commit sign-off or `Assisted-by:` trailer.** A squash merge
discards commit trailers. The PR template now carries a licensing
affirmation and names any AI tool used. This repository's squash merges
use the PR description as the commit message, so both stay in git.
- **"Assume good intent" and "disagree, then commit" are gone.**
COLLABORATION.md now asks people to show good intent and give good faith
about the work, and links the kwartzlab Code of Conduct. Technical
issues go to the author, a maintainer or Slack; interpersonal issues
follow the Code of Conduct. GOVERNANCE.md now says "Be kind and
patient", and CONTRIBUTING.md says "Be kind and respectful".
- **Contact and response time.** Board notices and security reports go
to git-issues@kwartzlab.ca. Security reports are acknowledged within 7
days instead of 3.
- **Open contributing.** Anyone can open issues and PRs. The
kos-developers group is for regular developers and reviewers.
- **CODEOWNERS** notes that the owner lists should grow, and that
sensitive areas should move to smaller specialist teams over time.
- **Private member data.** Showing members anything beyond preferred
name, pronouns, photo, teams and training status needs board approval.
- The PR template checklist is now written in the first person.

The third commit:

- **Code of conduct.** GOVERNANCE.md now says contributors agree to
kwartzlab's code of conduct, which applies to all members and guests in
our spaces, including this virtual one (anne-decusatis's wording).
- **CI.** "CI preflight must pass" is now "All CI tests and checks must
pass". Making them required before merge is a branch protection setting,
listed below.
- Two typo fixes.

## Licensing: the MIT history and the grant

`composer.json` has declared `"license": "MIT"` since the very first
commit (2018-07-31), apparently inherited from the Laravel starter
project. It has been assumed since then that contributions were MIT. No
LICENSE file or other licence statement has ever existed in the
repository.

To make this explicit before moving to the AGPL-3.0, `LICENSE-GRANT.md`
asks each existing contributor to add a short statement, in their own PR
from their own GitHub account, licensing their contributions made before
December 1, 2026, and any they make until the project adopts the
AGPL-3.0, under the AGPL-3.0 or later. Once everyone has signed, the
AGPL-3.0 `LICENSE` file is added and `composer.json` changed to match.
Cam's own statement is included in this PR.

**Before merging:** the new PR template asks every contributor to
license their work under the AGPL-3.0 or later from the day this merges.
If the Society has not agreed by then, we should hold the merge or
soften that checkbox.

## Open questions

- **License.** AGPL-3.0 is proposed. It needs all existing contributors
and the Society.
- **Sensitive paths in CODEOWNERS.** The first five are listed
(`app/Http/Middleware/`, `config/auth.php`, `database/migrations/`,
`.github/`, `Dockerfile`). Others, such as the login and API
controllers, key fobs, Gatekeepers, deploy scripts and audit config, can
be added as we find them.
- **TODOs left visible on purpose:** an escalation path for small or
emergency changes (GOVERNANCE.md), generalizing COLLABORATION.md for
other makerspaces, and the licensing reminder in GOVERNANCE.md.
- **Ratification.** The proposal is approval by a board representative
and two maintainers.

## Repository settings (for an admin, outside this PR)

- Enable GitHub private vulnerability reporting, which `SECURITY.md`
points to.
- Branch protection that requires code-owner review and passing CI.
CODEOWNERS on its own requires one owner's approval per path, so "two
reviewers" stays a convention unless the required number of approvals is
raised.
- Keep the squash merge setting that uses the PR description as the
commit message, since the affirmation and AI label depend on it.
- Later: suggest the same files to other kwartzlab repositories.

## How I tested it

Documentation only, so there is nothing to run. I checked that every
relative link and anchor in the new files resolves, that each CODEOWNERS
path exists in the repository, and that the pre-commit hooks (trailing
whitespace, end of file) pass.

## Checklist

- [x] I have read, understood, and agree to the terms in GOVERNANCE.md
and COLLABORATION.md
- [x] 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
- [x] I have tested locally in my Docker environment and am confident in
this code: not applicable, documentation only
- [x] I have added or updated automated tests to cover this work: not
applicable
- [x] I have kept changes under ~500 lines (excluding lockfiles,
generated files and tests), or explained why this isn't valid below:
about 325 lines
- [x] If AI-assisted: I used this AI tool or model: Claude Code (Claude
Opus 5.5), and I have read, run and understood every single line
- [x] 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. It touches `.github/` and CODEOWNERS
- [x] 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: not applicable

## Rollout notes

Merging deploys to production, but nothing in this PR changes how the
application behaves. Revert the commit to undo it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Cam Turner <cam.turner@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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>
@TurnerCam

Copy link
Copy Markdown
Owner Author

Moved upstream as kwartzlab#149 (one bundle).

@TurnerCam TurnerCam closed this Dec 5, 2026
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.

3 participants