Skip to content

fix(OEmbedParser): prevent TypeError when HTTP_HOST is absent or domain is null#481

Merged
skerbis merged 4 commits into
mainfrom
copilot/fix-type-error-domain-argument
May 30, 2026
Merged

fix(OEmbedParser): prevent TypeError when HTTP_HOST is absent or domain is null#481
skerbis merged 4 commits into
mainfrom
copilot/fix-type-error-domain-argument

Conversation

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Sporadic TypeError in OEmbedParser::getDomainConfig() when HTTP_HOST is unavailable (e.g. proxy/CLI edge cases or alternative host setups).

Root cause

parse() and processOembed() could pass a nullable domain into domain-config resolution. In PHP 8 this can break on strict type expectations and in practice led to unstable behavior for edge deployments.

Changes

  • Hardened domain resolution in parse() with REDAXO-aware fallback via rex_request::server(..., rex::getServer()).
  • Added safe post-processing fallback in parse() so preg_replace_callback() can never leak a null return.
  • Kept getDomainConfig() defensively nullable and return default config for empty/null domain.
  • Simplified domain handover in processOembed() and removed redundant null-coalesce paths.
  • Decoupled optional Vidstack integration defensively (class_exists / method_exists) to avoid addon-coupling issues when Vidstack is missing or incompatible.

Quality / Best Practices

  • Rexstan check for lib/OEmbedParser.php: 0 errors.
  • Addon version bumped to 5.6.5 in package.yml.
  • Changelog updated with the new release notes in CHANGELOG.md.

Copilot AI changed the title [WIP] Fix TypeError for null domain argument in OEmbedParser fix(OEmbedParser): prevent TypeError when HTTP_HOST is absent or domain is null Apr 30, 2026
Copilot AI requested a review from skerbis April 30, 2026 18:14
@skerbis skerbis marked this pull request as ready for review May 30, 2026 17:09
Copilot AI review requested due to automatic review settings May 30, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a sporadic PHP 8 TypeError in the Consent Manager’s CKE5 oEmbed integration by ensuring domain resolution and domain-config loading remain safe when HTTP_HOST and/or rex::getServer() are unavailable (or evaluate to null), falling back to default config instead of crashing.

Changes:

  • Ensure parse() never passes null as a domain by using an explicit '' fallback for rex_request::server('HTTP_HOST', ...).
  • Ensure processOembed() can’t propagate null into domain config lookup by adding a final ?? '' fallback.
  • Make getDomainConfig() accept ?string and early-return the default config when the domain is null/empty.

Comment thread lib/OEmbedParser.php
skerbis added 2 commits May 30, 2026 19:53
- Rexstan-konforme Null- und Return-Guards in OEmbedParser

- Version auf 5.6.5 angehoben

- Changelog fuer PR-Änderungen ergänzt
@skerbis skerbis merged commit ed6054c into main May 30, 2026
3 checks passed
@skerbis skerbis deleted the copilot/fix-type-error-domain-argument branch May 30, 2026 18:09
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.

TypeError ($domain) must be of type string, null given

3 participants