Problem/Motivation

When loading local pages that call stage file proxy a warning is thrown as NULL is being passed to a trim function.

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber->checkFileOrigin() (line 135 of modules/contrib/stage_file_proxy/src/EventSubscriber/StageFileProxySubscriber.php).
Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber->checkFileOrigin(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 142)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 70)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

First instance was fixed as part of https://www.drupal.org/project/stage_file_proxy/issues/3293275
However, there is another instance in StageFileProxySubscriber.php class as well.

I think we should address that as well.

Steps to reproduce

Use PHP 8.1
Use a version of the site connected via stage file proxy
Load a page with lots of files to get
Warnings are displayed

Proposed resolution

Similar changes to what we did in https://www.drupal.org/project/stage_file_proxy/issues/3293275

Remaining tasks

Uploading the patch.
Needs review for the patch.

User interface changes

N/A

API changes

N/A

Data model changes

N/a

CommentFileSizeAuthor
#2 3380483-2.patch814 bytesmohit_aghera
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mohit_aghera created an issue. See original summary.

mohit_aghera’s picture

Status: Active » Needs review
StatusFileSize
new814 bytes
keshavv’s picture

The default value for the configuration is already there. It will never be null.
https://git.drupalcode.org/project/stage_file_proxy/-/blob/2.1.x/config/install/stage_file_proxy.settings.yml

smustgrave’s picture

Parent issue: » #3373262: 2.1.2 Release

  • smustgrave committed 8c9424d8 on 2.1.x
    Issue #3380483: PHP 8.1 Deprecated function: trim(): Passing null to...
smustgrave’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.