Problem/Motivation

I noticed that some (possibly unreachable) code in Views (added in #2904847: Replace debug() statements in Views) tries to call trigger_error() with E_WARNING instead of E_USER_WARNING, which throws ValueError: trigger_error(): Argument #2 ($error_level) must be one of E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, or E_USER_DEPRECATED. So rather than logging a warning, an error is thrown.

Steps to reproduce

I'm not sure how to actually hit this code, maybe it's unreachable and could be removed?

Proposed resolution

Either patch the trigger_error() calls or remove the code if it's unreachable.

Remaining tasks

Review approach.

CommentFileSizeAuthor
#11 3266243.patch2.02 KBmfb
#11 interdiff-1-11.txt1.76 KBmfb
E_WARNING.patch1.98 KBmfb

Comments

mfb created an issue. See original summary.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alvarodemendoza’s picture

@mbf The patch works. Thank you,

alvarodemendoza’s picture

Status: Needs review » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Needs work

I think we should remove these checks, if they somehow turned out to be necessary, it seems unlikely the resulting error would be worse than the error that's already here, and we'd probably add either an exception or a better error message if we were adding back if so.

longwave’s picture

I traced the origin of this line back to 2008 and an extremely early version of Views:

https://git.drupalcode.org/project/views/-/commit/4fc76df7ca70395c9795a4...

It's not even clear then why the row plugin might be missing; I agree with @catch that we should just remove these checks instead.

quietone’s picture

Issue tags: +Bug Smash Initiative

This was discussed in bugsmash, adding tag.

mfb’s picture

I assume you mean remove the checks and don't return []; here, not just remove the trigger_error() calls?

Btw, to further clarify what I said in the issue summary, it seemed like if a plugin is missing what actually happens is you get a PluginNotFoundException, so that's why I thought this code might not be reachable.

longwave’s picture

Yes, remove the whole if statement; if it crashes later so be it, but as you say I suspect this will be caught by the plugin manager anyway and this is probably just dead code.

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.76 KB
new2.02 KB
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, this looks good to me.

  • catch committed f5b86d3 on 10.0.x
    Issue #3266243 by mfb, longwave, catch: Views tries to call...
  • catch committed 76c529a on 10.1.x
    Issue #3266243 by mfb, longwave, catch: Views tries to call...
  • catch committed b7ac282 on 9.5.x
    Issue #3266243 by mfb, longwave, catch: Views tries to call...
catch’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!

Status: Fixed » Closed (fixed)

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