Closed (fixed)
Project:
Drupal core
Version:
8.5.x-dev
Component:
views.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Feb 2018 at 18:10 UTC
Updated:
21 Mar 2018 at 00:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottSomething like this.
Comment #4
alexpottSo yay as expected existing tests show that we have missing coverage.
If you look at core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display.yml this should depend on views_test_data because it links to a table provided by that module. It currently doesn't in HEAD. With this patch it does.
Comment #5
alexpottFrom \Drupal\views\ViewsData::getData():
So we're already ensuring that the provider is set which is really nice.
Comment #7
alexpottMissed one.
Comment #8
dawehnerShould we do some array_unique checking here?
Comment #9
alexpottre #8 That's all handled in \Drupal\Core\Plugin\PluginDependencyTrait::calculatePluginDependencies() already. Which is called by \Drupal\views\Entity\View::calculateDependencies() to add each plugin's dependencies.
Comment #10
lendudeI think we need an update path to recalculate the dependencies on existing Views, right?
Comment #11
alexpott@Lendude++ indeed that is missing. On it.
Comment #12
alexpottHere's an upgrade path with a test. The update-test-ony.patch is interdiff.
Comment #14
lendude+1 for the batching of the view updates, we should have done that for the other updates too.
But wouldn't it be easier to just do:
I don't really mind it being a little more verbose but this might get copy/pasted a lot in the future :)
Comment #15
alexpott@Lendude++ like it! I copied from system_post_update_recalculate_configuration_entity_dependencies() but your idea is nice.
Comment #16
lendudeThis looks great.
One thing I'm wondering, what happens after we recalculate the dependencies and it turns out the dependencies are no longer met? ie. the content lock views mentioned in the IS? Is there any way to detect that you now have orphaned/broken config floating around somewhere? Any way we can warn the user?
This is a much more generic question though, and goes for all dependency updates we do, so that shouldn't stop this from going in, I'm just wondering.
Comment #17
alexpott@Lendude good question! Views handles this already - it's the plugins use the Broken plugin and that won't add the dependency :) so this patch doesn't make any change to the view because no dependencies change.
All of this is to ensure that the field doesn't use the broken handler and therefore adds the dependency as expected.
Comment #19
lendudeneeded a reroll after #2932083: Views Table style plugin breaks dynamic cache landed
Comment #20
chr.fritschI checked the patch in combination with the content_lock module and can confirm that the dependencies are now correctly set.
Found one minor:
We could use $this->viewsData here
Comment #21
lendude@chr.fritsch $this->viewsData might not be set so we need to use $this->getViewsData(), but yeah that is an improvement.
Comment #22
chr.fritschLooks good to me. I think we are done here.
Comment #23
alexpottMissing dependencies is at least a major given how they impact data integrity.
Comment #24
alexpottThis is actually a critical bug at least for Thunder. This is because without this fix views that use content_lock fields don't depend on content_lock. Therefore if you uninstall content_lock you break your site.
Comment #25
larowlanDo these go via
array_uniqueat some stage? Is there a risk that we'd end up with the same module twice?feels like we could use array_splice here
foreach (array_splice($sandbox['views'], 0, 10) as $view_id)Comment #26
alexpott@larowlan re #1 kinda they all eventually get added to config via \Drupal\Core\Entity\DependencyTrait::addDependency() which ensures things only get added once.
Agree re point 2. In fact we can do something even better. Hopefully this will become the new way we do this. Batching and mutli-loading ftw.
Comment #27
chr.fritschChanges are looking good to me
Comment #28
alexpottI think we can generalise the update process see #2949351: Add a helper class to make updating configuration simple
Comment #29
catchI don't see any updates to dependencies for views shipped with core, should they be re-exported?
Apart from that the patch looks fine.
Comment #30
alexpott@catch they don't change because they are all have the dependencies by other means atm. If this did add a dependency we'd get an error in \Drupal\KernelTests\Config\DefaultConfigTest which explicitly re-saves configuration entities to ensure that the provided defaults match what would be there if you just re-save a configuration entity immediately after install.
Comment #31
plachLooks good to me as well and #30 addresses #29, so it should be ok to commit this.
Checking credits.
Comment #33
plachCommitted 2d503f7 and pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!
Comment #35
plachSorry, I didn't mean to credit myself, I was fairly sure I had unchecked my checkbox :(
Comment #36
plach