Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be beneficial for sites with many features (e.g. built on Open Atrium) to have the list of features cached so that it doesn't have to be fetched for each reload of Manage Features page, as developers do not need to add/delete features as often as check their status or enable/disable them.
This patch provides simple caching for that list, with an option to turn this feature off on the features settings page and a button to rebuild the cache on the Manage Features page without flushing all caches on site.
Comment | File | Size | Author |
---|---|---|---|
#6 | features-caching-2466975-6.patch | 3.91 KB | m1n0 |
#1 | features-caching-2466975-1.diff | 5.86 KB | m1n0 |
Comments
Comment #1
m1n0 CreditAttribution: m1n0 commentedComment #2
mpotter CreditAttribution: mpotter commentedI'm interested in hearing other comments on this. My own comments are:
1) Need a different name for _features_get_features since it is too close to the public features_get_features function.
2) There should be a hook on module_enable/disable to clear this cache automatically.
3) Could also implement the hook called when Drupal cache is cleared. Not sure we need a separate settings option and button for clearing this if it integrates better with normal Drupal hooks and caching.
Comment #3
m1n0 CreditAttribution: m1n0 commentedThanks for the feedback, some thoughts here:
1) Will re-roll the patch with changed function name, thanks for noticing that.
2) Why exactly would we need that? Enabling/disabling a module does not change what appears on the Manage Features list - please note that this cache only stores the array of features - not their state.
3) This cache is automatically cleared when all Drupal cache is cleared as it is stored in the default cache bin (creating special bin for this one entry seemed an overkill to me - but that would make the button obsolete). My original thought was to have this button as an option of rebuilding that list without clearing all caches - e.g. new feature is not appearing in the list on production site after codebase update - that is actually the only scenario I can think of that requires rebuilding that list as everything else should be covered automatically.
Comment #4
mpotter CreditAttribution: mpotter commented2) Sorry, I've been in D8-land so much I had forgotten how the 7.x listing was working and the fact it needs to show disabled modules. I think you are correct and can ignore (2).
3) As long as it's cleared with a full cache clear then I'm fine without needing a separate button. I just want to reduce un-needed options and buttons as much as possible. When updating the codebase of a site you always need to do a full cache clear anyway, so even that scenario doesn't need a separate option.
Comment #5
m1n0 CreditAttribution: m1n0 commentedOk thanks for your input again, 3) makes sense, I will re-roll the patch with updated function name and deleted button asap.
Comment #6
m1n0 CreditAttribution: m1n0 commentedHere is a re-rolled patch with deleted rebuild button and setting to turn on/off the caching. The function to get the list of features has been renamed to _features_get_features_list().
Comment #7
m1n0 CreditAttribution: m1n0 as a volunteer commentedIs there something keeping this from being committed? I have been using this patch on a project built on Open Atrium for couple of months now with no issues, but I am happy to have another round of feedback/change/re-roll if necessary.
Comment #8
mpotter CreditAttribution: mpotter commentedThis this is good now.
Comment #9
mpotter CreditAttribution: mpotter commentedCommitted to d38181d.