Problem/Motivation

Under some circumstances $this->value['type'] is undefined, resulting in the warning

Warning: Undefined array key "type" in Drupal\search_api\Plugin\views\filter\SearchApiDate->opBetween() (line 103 of modules/contrib/search_api/src/Plugin/views/filter/SearchApiDate.php).

It should have the same sanity check as $this->value['max'] just above it.

Steps to reproduce

Unknown.

Proposed resolution

Add a sanity check that matches the one just above it.

Remaining tasks

Make a fork.

CommentFileSizeAuthor
#4 3398192-undefined-array-key.patch1.99 KBadmirlju

Issue fork search_api-3398192

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

BenStallings created an issue. See original summary.

benstallings’s picture

Status: Active » Needs review
admirlju’s picture

StatusFileSize
new1.99 KB

Quickly generate a patch file, from your repository. Since automated testing on the GitLab pipeline at the moment doesn't work correctly for Search API.

admirlju’s picture

Status: Needs review » Reviewed & tested by the community

The automated tests are passing and the sanity check works correctly. I think this can be merged. RTBC.

Anmol singh made their first commit to this issue’s fork.

drunken monkey’s picture

Version: 8.x-1.30 » 8.x-1.x-dev
Component: General code » Views integration
Status: Reviewed & tested by the community » Fixed

Thanks for reporting this problem!
We actually already guard against this a few lines further down, in opSimple(), but apparently forgot it there. Or maybe it occurs even rarer in opBetween(). Anyways, I think we should just use the same fix we used there: ($this->value['type'] ?? '') == 'offset'.

(I also don’t quite understand why we don’t just set $base_timestamp regardless, but probably out of scope here.)

Anyways, merged a simplified version of the MR. Thanks again, everyone!

  • drunken monkey committed a094dd61 on 8.x-1.x
    Issue #3398192 by drunken monkey, BenStallings, admirlju: Fixed warning...

Status: Fixed » Closed (fixed)

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