Uninstalling Contextual Range Filter deletes the entire view

Created on 2 September 2024, 3 months ago

Problem/Motivation

As said in the title if you uninstall the module the view containing a block managed by Contextual Range Filter disappears. I lost dozens of hours of work with a view where I had several pages and blocks. One of the block was using Contextual Range Filter but as it was not giving the expected results and also I suspected it to interfere with the results of the other blocks (I have to do some more verifications to confirm this last one), I disabled this block, and finally uninstalled it. The entire view was deleted with all pages and blocks it contained.

Steps to reproduce

1 === Views preparation ===

  • Create a view of content and display the node's titles with a page (set a path like "my_view_page") and a block (mine was a list of names ordered alphabetically)
  • In Block's "Advanced settings" set "title" as a contextual filter for the block and Provide default value with Default: Content ID from URL
  • Save the view
  • Using "block layout" place the block on a page displaying the nodes in "full" view
  • Test by visiting the views's page (my_view_page) and the page where you placed the block

2 === Contextual Range Filter ===

composer require 'drupal/contextual_range_filter:^2.0'
drush en contextual_range_filter
  • Visit admin/config/content/contextual-range-filter
  • In "Select contextual filters to be converted to contextual range filters" scroll down to "Select which of the below contextual string filters should be converted to string range filters" and enable "String: title in view yous_view_name"

3 === Final settings ===

  • Go back to the view and in the block change the contextual filter from default value "Content ID from URL" to "PHP Code"
  • Set some code in the php code field, for example display some names close alphabetically to the one displayed in the main page
  • if (isset($entity['node'])) {</li>
        $value_min = substr($entity['node']->title->value, 0,2);</li>
        $value_max = substr($entity['node']->title->value, 0,4);</li>
        return "$value_min--$value_max"; </li>
      }</li>
      
  • Save the View
  • Visit/Verify the page where you placed the block

4 === Disaster ===
Let's say that we are not satisfied by the results

  • Go to View and set the block as disabled (under "Duplicate block" click the arrow and in the bottom of the menu you have "Disable block"

You think you're fine with that and later you decide to uninstall the module
drush pm:uninstall contextual_range_filter

5 === Report of damages ===

  • Visit the page of the view (my_view_page) => Page not found
  • Visit the page of a node with the block => The block is no more there (normal because we had deactivated it)
  • Go to see wat happens in the view => Visit the view => Page not found => The view disappeared

Configuration: Drupal 10.3 - Contextual Range Filter 8x-2.0 - PHP

Proposed resolution

=== WORST THAN THAT ===
As a temporary workaround, I thought that setting back 1) the contextual filter to default value: Content ID from URL and 2) disabling "String: title in view yous_view_name" in admin/config/content/contextual-range-filter would be sufficient to unlink the Contextual Range Filter from my View. Well no. After undoing these settings and uninstalling the module, my view was again deleted. It's like my View has been contaminated forever.

Maybe if we completely remove the block, it will allow to uninstall without destroying the View but I have no more tie to spend on testing and debugging. As it stands, this module cannot be used given the damage it can cause without any warning.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024