AvPortalPhotoStreamWrapper incompatible with remote_stream_wrapper 2.1.1 strict typing

Created on 28 August 2025, 20 days ago

Problem/Motivation

After updating remote_stream_wrapper to version 2.1.1, the AvPortalPhotoStreamWrapper class throws fatal errors due to strict typing incompatibilities with the parent HttpStreamWrapper class.

Steps to reproduce

  1. Install media_avportal module
  2. Update remote_stream_wrapper to version 2.1.1 or later
  3. Clear cache with drush cr
  4. Observe fatal errors

Error examples:

Fatal error: Type of Drupal\media_avportal\StreamWrapper\AvPortalPhotoStreamWrapper::$uri must be string (as in class Drupal\remote_stream_wrapper\StreamWrapper\HttpStreamWrapper)

Fatal error: Declaration of Drupal\media_avportal\StreamWrapper\AvPortalPhotoStreamWrapper::unlink($path) must be compatible with Drupal\remote_stream_wrapper\StreamWrapper\HttpStreamWrapper::unlink($path): bool

Proposed resolution

Update AvPortalPhotoStreamWrapper to match the strict type declarations introduced in HttpStreamWrapper 2.1.1. The required changes include:

  1. Property typing: Change protected $uri; to protected string $uri;
  2. Method return types: Add return type declarations to all inherited methods:
    • getName(): string
    • getDescription(): string
    • getType(): int
    • setUri($uri): void
    • getUri(): string
    • getExternalUrl(): string
    • realpath(): string|bool
    • preventUnmanagedFileImageStyleGeneration(): bool
    • unlink($path): bool
  3. Return value compatibility: Change return NULL; to return ''; in getExternalUrl() method

Attached patch provides these fixes and maintains backward compatibility while ensuring strict type compliance.

Remaining tasks

  • Review and test the proposed patch
  • Ensure compatibility with both old and new versions of remote_stream_wrapper
🐛 Bug report
Status

Active

Version

1.11

Component

Code

Created by

🇧🇪Belgium Codex42

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024