When I try to add "Role expiration date/time" as filter in a view I don't get the screen to set up the filter arguments and end up with "Broken/missing handler". In the Drupal log I see these error messages:

Undefined variable: items in Drupal\views\Plugin\views\filter\Broken->buildOptionsForm() (line 74 of /web/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php) #

and

Invalid argument supplied for foreach() in template_preprocess_item_list() (line 1099 of /web/core/includes/theme.inc) #0

Any help would be highly appreciated.

CommentFileSizeAuthor
#13 3096579-13.patch804 bytesnguerrier
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

futurmat created an issue. See original summary.

rcodina’s picture

Which version of Drupal core and module are you using? If you recently upgraded the module version, remove the fields and re add them.

rcodina’s picture

Status: Active » Postponed (maintainer needs more info)

I need more info to help you. Feel free to reopen.

rcodina’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
nchristensen’s picture

I am experiencing this issue using Drupal core 8.9.13 and Role Expire 2.0.0.

Encountering the Broken/missing handler views message and the same log message when I try to add "Role expiration date/time" as filter in a view.

Warning: Invalid argument supplied for foreach() in Drupal\views\Plugin\views\filter\Broken->buildOptionsForm() (line 56 of /code/web/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php)

Warning: Invalid argument supplied for foreach() in template_preprocess_item_list() (line 1107 of /code/web/core/includes/theme.inc)

rcodina’s picture

@nchristensen Have you tried to delete and then add again the Role Expire fields to the view?

nchristensen’s picture

@rcondina I have. I also attempted recreating from a fresh view and encountered the same error. I haven't tried disabling and enabling the module, but since we have so many users with role expirations already, Im afraid to do so and risk losing data or causing database errors.

nchristensen’s picture

For prosperity I disabled and re-enabled the module on a dev version. This did not fix the issue, unfortunately.

rcodina’s picture

Status: Closed (cannot reproduce) » Needs review

I'll check this problem when I have time.

rcodina’s picture

Version: 8.x-1.x-dev » 2.x-dev
rcodina’s picture

Sorry, but I can't reproduce the error. Could you update to Drupal 9 and test if the problem is solved?

rcodina’s picture

Status: Needs review » Postponed (maintainer needs more info)
nguerrier’s picture

StatusFileSize
new804 bytes

There were several errors in role_expire.views.inc, the sort & filters handlers were pointing to not existing handlers.

Attached patch fixes that.

nguerrier’s picture

Status: Postponed (maintainer needs more info) » Needs review
andypost’s picture

Status: Needs review » Needs work
Issue tags: -views integration +Needs tests, +Needs steps to reproduce
rcodina’s picture

Finally, I reproduced the error. It's my fault for not reading "as filter" in the title. Initially, filter and sort plugins were not taken into account when I developed the views integration of this module. However, at that moment, I defined the "sort" and "filter" values in the associative array and later I forgot to test sorting and filtering (I only needed to display expire data as fields).

In fact, what needs to be done here is to develop two custom filter plugins and two custom sort plugins given that "Role expire" information is stored in a custom database. Therefore, in this issue seems to be a lot of work to do. For this reasons, after patch on #13, filter may seem to work in some situations (but it's not) and sorting it's not working at all.

_tarik_’s picture

Assigned: Unassigned » _tarik_

I did some issue testing, so here is what I’ve found:

The problem, as @nguerrier mentioned in comment #13, comes from the missing filter and sorting plugins.
We can safely use the default date plugin from the views module to sort records, but the problem appears with the filter plugin.
The default date filter plugin from the Views module is useful for working with relative dates, but with the absolute ones, it doesn’t seem fine. Example:

1. A user with the role test_role has an expiration timestamp of 1758544121, which corresponds to 22 September 2025, 12:28:41.

2. A site administrator creates a view to show users with the test_role role expiring on 2025-09-22.

3. The view returns no results because the database query uses the = operator. The timestamp for 2025-09-22 is 1758499200, which does not equal 1758544121

I recommend continuing to use the default date plugin for sorting, since it works as expected. For filtering, however, we should implement custom plugins: one designed for relative dates and another for absolute dates.

_tarik_’s picture

Version: 2.x-dev » 4.x-dev

_tarik_’s picture

I’ve started work on this issue, but found that we can probably avoid providing any additional code. It seems we can delegate work with dates to the date_filter module.
If we do so, then in the scope of this issue, there are only 2 tasks:

1. Update the README and describe the recommended way to work with the dates with the date_filter module.
2. Provide unit tests.

@rcodina, please let me know what you think. Do we need to provide our own solution or use a solution from Drupal? I believe we don’t need to extend the code base if we can use other modules that fit our requirements.

PS. The current MR contains changes from comment #13. It works as a charm, thanks to @nguerrier.

_tarik_’s picture

Assigned: _tarik_ » Unassigned