Skip to content

fix: use Application::addCommand() for Symfony Console 8 - #192

Merged
skjnldsv merged 3 commits into
masterfrom
fix/symfony-console-8-addcommand
Jul 23, 2026
Merged

fix: use Application::addCommand() for Symfony Console 8#192
skjnldsv merged 3 commits into
masterfrom
fix/symfony-console-8-addcommand

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Jul 23, 2026

Copy link
Copy Markdown
Member

What

changelog/index.php called Application::add(), removed in Symfony Console 8 in favor of addCommand(). Since composer.json requires symfony/console: ^8.1, release changelog generation crashed:

PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\Console\Application::add() in .../changelog/index.php:721

Failing release run: https://github.com/nextcloud-releases/server/actions/runs/30026045919

Why

Second Symfony Console 8 breakage after the dependabot bump (#189); #191 already fixed the configure()/execute() return types. Both reached a release run because nothing executed the tools in CI, while dependabot bumps composer deps weekly.

Commits

  1. fix: use Application::addCommand() for Symfony Console 8.
  2. test: add CI for the PHP tools. PHPUnit suite for the changelog generator (the key test runs the real php index.php generate:changelog --help and fails on non-zero exit, catching removed/renamed Console APIs in the bootstrap; others guard the configure()/execute() signatures). New .github/workflows/php-test.yml discovers every composer project, installs + lints each on any PR touching PHP/composer files (dependabot included), runs composer test only where a test script exists, and ends in a fixed-name php-test-summary check for branch protection. Drop a future Symfony tool in alongside and it's covered automatically.
  3. fix(sensitive-issue-searcher): modernise for PHP 8.4. The new workflow surfaced that this tool's deps (knplabs/github-api ^2.1, cache/redis-adapter ^0.5) required PHP ^5.6 || ^7.0 and failed to install. Bumped to knplabs v3 + guzzle7 (matching sibling tools), dropped the unused cache dep, adapted search.php to the v3 API (AuthMethod::ACCESS_TOKEN, ResultPager page size), and stopped tracking its committed vendor/.

Testing

cd changelog && composer install && composer test   # 4 tests, 12 assertions
php index.php generate:changelog --help             # boots, prints help

CI is green across all tools.

Symfony Console 8 removed the deprecated Application::add() method in
favor of addCommand(). This caused a PHP fatal error when generating
the release changelog:

  Call to undefined method Symfony\Component\Console\Application::add()

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv skjnldsv added bug php Pull requests that update php code labels Jul 23, 2026
@skjnldsv
skjnldsv force-pushed the fix/symfony-console-8-addcommand branch 2 times, most recently from 819ddcb to 766fd29 Compare July 23, 2026 17:22
skjnldsv added 2 commits July 23, 2026 19:26
The Symfony Console 8 breakages (this fix and #191) reached a release run
because nothing ever executed changelog/index.php in CI. Dependabot bumps
composer deps weekly, so an API-breaking upgrade was invisible until the
release workflow ran the tool.

Add a PHPUnit suite for the changelog generator plus a GitHub Actions
workflow that discovers every composer project in the repo and, on any PR
touching PHP or composer files (including dependabot's), installs deps and
lints them. It runs 'composer test' only for tools that define a test
script, so a future Symfony tool added alongside the changelog generator is
covered automatically just by shipping its own tests.

changelog tests:
- testEntrypointBootstrapsWithoutFatalError runs the real 'php index.php
  generate:changelog --help', catching removed/renamed Console APIs used in
  index.php's own bootstrap (e.g. Application::add()).
- The remaining tests assert the command class declares cleanly (catching
  configure()/execute() signature breaks) and that its definition matches
  configure().

index.php's bootstrap is guarded so requiring the file only declares the
command class instead of running the app.

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
The tool's dependencies were pinned to knplabs/github-api ^2.1 and
cache/redis-adapter ^0.5, both requiring PHP ^5.6 || ^7.0, so composer
install failed on PHP 8.4. The new php-test workflow surfaced this.

- Bump to knplabs/github-api ^3.16 with guzzlehttp/guzzle ^7.13 and
  http-interop/http-factory-guzzle, matching the other tools.
- Drop cache/redis-adapter: it was declared but never used by search.php.
- Adapt search.php to the github-api v3 API:
  - authenticate() no longer takes Client::AUTH_HTTP_TOKEN; use
    AuthMethod::ACCESS_TOKEN.
  - Issue::setPerPage() was removed; pass the page size to ResultPager
    instead.
- Stop tracking vendor/ (it was committed here unlike every other tool;
  .gitignore already ignores it).

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv
skjnldsv force-pushed the fix/symfony-console-8-addcommand branch from 766fd29 to 07481eb Compare July 23, 2026 17:28
@skjnldsv skjnldsv self-assigned this Jul 23, 2026
@skjnldsv
skjnldsv enabled auto-merge July 23, 2026 17:33
@skjnldsv
skjnldsv disabled auto-merge July 23, 2026 17:33
@skjnldsv
skjnldsv merged commit 6909bfe into master Jul 23, 2026
10 checks passed
@skjnldsv
skjnldsv deleted the fix/symfony-console-8-addcommand branch July 23, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug php Pull requests that update php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant