Skip to content

Remove dev-only DomCrawler from production /impress, /privacy, /grenzwerte path (#536)#549

Open
maltehuebner wants to merge 1 commit into
mainfrom
fix/dev-deps-prod-path-536
Open

Remove dev-only DomCrawler from production /impress, /privacy, /grenzwerte path (#536)#549
maltehuebner wants to merge 1 commit into
mainfrom
fix/dev-deps-prod-path-536

Conversation

@maltehuebner

Copy link
Copy Markdown
Contributor

Summary

TemplateController::staticAction (routes /privacy, /impress, /grenzwerte) derived the page title by rendering the template a second time and parsing its <h2> with Symfony\Component\DomCrawler\Crawler + ->filter() (which additionally needs symfony/css-selector). Both symfony/dom-crawler and symfony/css-selector are require-dev-only (pulled transitively via symfony/browser-kit), so a production build with composer install --no-dev fatals with Class Symfony\Component\DomCrawler\Crawler not found on all three routes.

Changes

  • Replaced the H2 parsing with an explicit title route default in config/routing/1_static.yaml (Datenschutzerklärung / Impressum / Übersicht über Schadstoffe und Grenzwerte), matching the exact previous H2 text. staticAction now takes a string $title argument bound from the route default.
  • Removed readH2Tag() and with it:
    • the double full render of every static template per request,
    • the EntrypointLookup reset workaround and the now-unused EntrypointLookupCollectionInterface constructor dependency (the constructor is gone; ManagerRegistry comes from the parent),
    • the always-true ternary $h2 ? $h2->text() : null and its phpstan-baseline.neon entry.
  • No production code references DomCrawler/CssSelector anymore; they remain dev-only (still used by browser-kit in the Integration test suite).

Deliberately not implemented

  • Caching the remote Impress JSON (optional item): out of scope for this fix; the double-render that amplified the external call is already removed.
  • A --no-dev smoke-build CI job (optional item): worth adding as a guard, but left as a follow-up to avoid coupling this focused fix to CI-pipeline changes.

Verification

  • grep confirms no DomCrawler/CssSelector/Crawler/EntrypointLookupCollection references remain in src/.
  • vendor/bin/phpstan analyse — No errors (baseline entry removed).
  • vendor/bin/phpunit --testsuite="Project Test Suite" — 121 tests green.
  • bin/console lint:container --env=prod — OK.
  • bin/console debug:router privacy --env=prod — shows title: Datenschutzerklärung default.

Note: the /impress and /privacy Integration tests assert on the template's own <h2> (not the SEO title), so behaviour is unchanged; they run in the DB/network-dependent Integration suite, not exercised here.

Closes #536

🤖 Generated with Claude Code

…r path

TemplateController::staticAction (routes /privacy, /impress, /grenzwerte)
extracted the page title by rendering the template a second time and
parsing its <h2> with Symfony\Component\DomCrawler\Crawler + ->filter()
(css-selector). Both symfony/dom-crawler and symfony/css-selector are only
require-dev dependencies (pulled via symfony/browser-kit), so a production
build with `composer install --no-dev` fatals with
"Class Symfony\Component\DomCrawler\Crawler not found" on those routes.

Replace the H2 parsing with an explicit `title` route default
(Datenschutzerklärung / Impressum / Übersicht über Schadstoffe und
Grenzwerte), matching the previous H2 text. This also removes:
- the double full render of every static template per request,
- the EntrypointLookup reset workaround (and the now-unused
  EntrypointLookupCollectionInterface constructor dependency),
- the always-true ternary (`$h2 ? $h2->text() : null`) and its
  phpstan-baseline entry.

dom-crawler/css-selector stay dev-only (still used by browser-kit in tests);
no production code references them anymore.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

[Hoch] Dev-only-Pakete im Produktionspfad: /impress, /privacy, /grenzwerte brechen bei composer install --no-dev

1 participant