Problem/Motivation

When calling MediaLibraryState::fromRequest() on a request without any media library URL query argument, the following type error occurs:

Argument 2 passed to Drupal\media_library\MediaLibraryState::create() must be of the type array, null given

We overlooked this in #3038241: Implement a tamper-proof hash for the media library state.

Proposed resolution

Ensure that MediaLibraryState::fromRequest() always passes valid arguments into MediaLibraryState::create()

Remaining tasks

  1. Test coverage.
  2. Fix.
  3. RTBC.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.01 KB
Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Issue summary: View changes
FileSize
774 bytes
1.75 KB
seanB’s picture

Nice find. I guess you shouldn't do that, but fixing the type error and throwing a nice InvalidArgumentException is a lot better.
I think this is RTBC as soon as the tests are green.

The last submitted patch, 2: 3057370-2-test_only_FAIL.patch, failed testing. View results

seanB’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed d2792e13d7 to 8.8.x and 9fbc804e47 to 8.7.x. Thanks!

  • alexpott committed d2792e1 on 8.8.x
    Issue #3057370 by Wim Leers, seanB: MediaLibraryState::fromRequest() may...

  • alexpott committed 9fbc804 on 8.7.x
    Issue #3057370 by Wim Leers, seanB: MediaLibraryState::fromRequest() may...

Status: Fixed » Closed (fixed)

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