winter icon indicating copy to clipboard operation
winter copied to clipboard

Support Laravel 12

Open LukeTowers opened this issue 6 months ago • 2 comments

All tests passing. Requires https://github.com/wintercms/storm/pull/207. Replaces #1094

Remaining Tasks:

  • [x] Test locally on own projects - passes!
  • [ ] Add Winter.Ignition to the core
  • [ ] Write upgrade guide
  • [ ] Create 1.3 docs branch
  • [ ] Create 1.3 manifest branch
  • [ ] Update wintercms.com to support 1.3 branches
  • [ ] Update base bootstrap & config files
  • [ ] Review unfinished tasks from Laravel 9 upgrade & Laravel 6 upgrade
  • [ ] DB::raw() change: https://laravel.com/docs/10.x/upgrade#database-expressions - TEST, broken on one of my sites

Breaking changes:

  • [ ] PHP 8.5 adds native array_first() and array_last() functions that do not match the signature provided by Winter's helper functions. If you are currently using either function in your code with two or three arguments (filter & default) you will need to switch to \Winter\Storm\Support\Arr::first() or \Winter\Storm\Support\Arr:last() instead.
  • The -s short flag for the --silent option on mix:compile, mix:create, mix:install, mix:watch, npm:install, npm:run, npm:update, npm:version, vite:compile, vite:create, vite:install, vite:watch has been removed as Symfony v7.2 added the --silent option to all commands by default which conflicted with our definition. You must use the full option --silent going forward.
  • [ ] static $defaultName in Console commands to support lazy loading is no longer used in Symfony\Console 7.2, use the AsCommand class attribute instead. We will need to update all first party plugins & modules to make use of that.
  • [ ]

Currently incompatible plugins:

  • [x] Winter.Builder https://github.com/wintercms/wn-builder-plugin/pull/71 @jaxwilko
  • [x] Winter.Docs https://github.com/wintercms/wn-docs-plugin/pull/24 @bennothommo
  • [x] Winter.Search https://github.com/wintercms/wn-search-plugin/pull/10 @bennothommo
  • [ ] Winter.Dusk https://github.com/wintercms/wn-dusk-plugin/pull/3 @bennothommo

All other Winter plugins have been tested and confirmed compatible (some with minor tweaks to their PHPUnit configs to remove deprecation warnings.

New Minimum Requirements:

  • PHP 8.2+
  • Composer 2.2+
  • curl 7.34.0+
  • SQLite 3.26.0+
  • PHPUnit 11.0 (when using the testing functionality)

Backwards Compatibility Fixes:

Upgrade Guides:

  • Laravel 10: https://laravel.com/docs/10.x/upgrade
  • Laravel 11: https://laravel.com/docs/11.x/upgrade
  • Laravel 12: https://laravel.com/docs/12.x/upgrade
  • PHPUnit 11: https://moodledev.io/general/development/tools/phpunit/upgrading-11

Summary by CodeRabbit

  • New Features

    • Support for multiple previous app encryption keys (key rotation).
    • Optional rehash-on-login setting for passwords.
  • Bug Fixes

    • SQLite minimum-version validation during updates to avoid incompatible migrations.
  • CLI Changes

    • Silent mode flags removed from asset/npm/vite commands; commands now show output.
    • Test runner options refined for targeted module/plugin runs.
  • Chores

    • Minimum PHP requirement raised to 8.2 and core framework upgraded.
  • Tests

    • PHPUnit and test infra modernized (schema, attributes, caching).

✏️ Tip: You can customize this high-level summary in your review settings.

LukeTowers avatar Jun 12 '25 22:06 LukeTowers

Tests passing! 🎉

mjauvin avatar Jul 26 '25 00:07 mjauvin

Walkthrough

Raise PHP/Laravel requirements, modernize CI and PHPUnit configs, remove many CLI --silent options, add an SQLite minimum-version check in UpdateManager::update, update test bootstrapping and many tests for newer PHPUnit/Laravel facades/attributes, and apply assorted import/signature and minor fixture/.gitignore changes.

Changes

Cohort / File(s) Summary of changes
CI workflows
​.github/workflows/manifest.yml, ​.github/workflows/tests.yml
Replace env/template indirection with explicit PHP versions/extensions and GITHUB_TOKEN; pin actions (actions/checkout@v4); adjust PHP matrix to 8.2–8.4; remove several cache steps and legacy steps; update workflow targets and settings.
Platform & dependencies
composer.json, modules/*/composer.json (modules/backend/..., modules/cms/..., modules/system/...)
Bump PHP constraint to ^8.2, Laravel to ^12.0, align Winter deps to dev-wip/1.3, upgrade PHPUnit/dev deps to PHPUnit 11, add VCS repo for phpunit-arraysubset-asserts, remove minimum-stability.
PHPUnit configs & stubs
phpunit.xml, modules/*/phpunit.xml, modules/system/console/scaffold/test/phpunit.stub
Migrate to PHPUnit 10.5 schema (xsi:noNamespaceSchemaLocation), add cacheDirectory, rename backupStaticAttributes→backupStaticProperties, remove convert* flags, simplify/bootstrap/formatting.
App / hashing config
config/app.php, config/hashing.php
Add previous_keys config parsed from APP_PREVIOUS_KEYS, cast debug to (bool), add rehash_on_login => false in hashing config.
Backend updates & tests
modules/backend/controllers/Index.php, modules/backend/tests/*
Replace array_first with Arr::first, adjust imports, call parent::tearDown() after instance cleanup, and refactor WidgetMaker test to use an anonymous class with Controller property/constructor.
CMS module & tests
modules/cms/classes/ComponentManager.php, modules/cms/tests/*
Rework imports/namespaces, swap to Winter/Illuminate facades, convert docblock @depends to PHPUnit attributes, replace Request mock with anonymous Request subclass, and adjust Cache usage.
Remove silent CLI options (Mix/NPM/Vite)
modules/system/console/asset/mix/*, modules/system/console/asset/npm/*, modules/system/console/asset/vite/*
Remove `{--s
Update flow guard
modules/system/classes/UpdateManager.php
Add SQLite runtime guard: when using sqlite driver, verify server version ≥ 3.35 and throw an exception if older before proceeding with updates/migrations.
Console/Test runner changes
modules/system/console/WinterTest.php, modules/system/tests/bootstrap/*
Update WinterTest signature and skip/target handling; delegate createApplication to parent; bind Kernel to suppress shell verbosity; add new assertion helper and remove deprecated compatibility shims.
System tests modernizations
modules/system/tests/... (many files; see diff)
Switch tests to Winter/Laravel facades (DB/Log/File/Schema), convert dataProviders/depends to PHPUnit attributes (make providers static), add parent::tearDown() calls, reposition node_modules skip checks, and update migration test assertions to SchemaBuilder-based checks.
Fixtures & minor files
modules/system/tests/fixtures/.../Comments.php, .gitignore
Reorder Comments constructor parameters to require Users $users first and make CodeBase nullable second; add .phpunit.cache and *.code-workspace to .gitignore.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin as Admin/CLI
  participant UM as UpdateManager
  participant DB as Database Connection

  Admin->>UM: update()
  UM->>DB: getDriverName()
  alt driver == sqlite
    UM->>DB: getServerVersion()
    UM->>UM: compare >= 3.35
    alt version < 3.35
      UM-->>Admin: throw Exception (SQLite too old)
    else version OK
      UM->>UM: continue update/migrations
    end
  else other driver
    UM->>UM: continue update/migrations
  end
  UM-->>Admin: result or exception
sequenceDiagram
  autonumber
  actor Dev as Developer/CLI
  participant WT as WinterTest Command

  Dev->>WT: winter:test --configuration=... --module=... --plugin=...
  WT->>WT: build types map (modules, plugins) and counts
  WT->>WT: skip processing for empty targets
  loop each non-empty type
    WT->>WT: run tests for specified items
  end
  WT-->>Dev: aggregated results

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Potential review focus areas:

  • PHPUnit config/schema migration and broad test attribute/provider conversions.
  • UpdateManager SQLite version check (correct exception class/message, unit tests).
  • Removal of --silent options where code still references the option (ensure no unexpected empty args or output changes).
  • Composer constraint bumps across root and modules (dependency resolution and compatibility).
  • CreateMigrationTest changes (SchemaBuilder assertions and type/index expectations).

Poem

A rabbit nudges the repo bright,
Bumps PHP, tunes CI overnight.
Silent flags hop far away,
Tests don attributes to play.
SQLite checked — the meadow’s right. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Support Laravel 12' directly and clearly describes the main objective of this pull request, which is to upgrade the codebase to support Laravel 12.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch wip/1.3

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63f2a3eb40bfe26ada0b3bc95efd58e866728cba and 58057d0c5060d1221ac39c232b517a2b4e1226bb.

📒 Files selected for processing (1)
  • modules/system/console/WinterTest.php (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/system/console/WinterTest.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: windows-latest / PHP 8.3
  • GitHub Check: windows-latest / PHP 8.4
  • GitHub Check: ubuntu-latest / PHP 8.3
  • GitHub Check: windows-latest / PHP 8.2
  • GitHub Check: ubuntu-latest / PHP 8.4
  • GitHub Check: ubuntu-latest / PHP 8.2
  • GitHub Check: windows-latest / JavaScript

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 15 '25 20:10 coderabbitai[bot]