Problem/Motivation

HttpStatusCode condition plugin provided by context module checks if exception is not empty. While in most situations it is fine, in some situations exception could be an object with class different from HttpException, causing the following fatal error:

Error: Call to undefined method Drupal\Core\Form\EnforcedResponseException::getStatusCode() en Drupal\context\Plugin\Condition\HttpStatusCode->evaluate() (línea 109 de /path/to/docroot/modules/contrib/context/src/Plugin/Condition/HttpStatusCode.php)

Steps to reproduce

  • Create a content type FOO with media library
  • Create a context using http status code condition
  • Create a content with FOO content type
  • Use media library to select an existing media
  • Click on insert media
  • You with see the previous mentioned error on the logs

Proposed resolution

Check the $exception class.

Remaining tasks

Review and test.

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 context-3188463-2.patch1.36 KBakalam

Issue fork context-3188463

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

akalam created an issue. See original summary.

akalam’s picture

StatusFileSize
new1.36 KB

DeaOm made their first commit to this issue’s fork.

deaom’s picture

Status: Active » Needs review

I can confirm this issue as I got to it when writing automated tests #3190409: Add test for context http satus code. I created a fork with a slight change to the if statement, but please give the credit to @akalam. Marking this issue as needs review (so I do not set RTBC on my own commit).

Status: Needs review » Needs work

The last submitted patch, 2: context-3188463-2.patch, failed testing. View results

deaom’s picture

Status: Needs work » Needs review

Not actually failing, so setting it back to needs review.

nmatja’s picture

Status: Needs review » Reviewed & tested by the community

I was not able to reproduce the issue but after checking the fork update everything seems okay.

paulocs’s picture

  • paulocs committed 31a6c6d on 8.x-4.x authored by DeaOm
    Issue #3188463 by DeaOm, akalam, nmatja, paulocs: Error: Call to...
paulocs’s picture

Status: Reviewed & tested by the community » Fixed

Fixed! Thanks!

Status: Fixed » Closed (fixed)

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