Problem/Motivation
In order to know whether a Condition plugin has been configured, the submitted values are compared to its default state. If they match exactly, it is consider to be not configured, and is removed.
The Form API will submit Boolean values as 1 or 0 instead of TRUE or FALSE, which breaks this comparison.
Before #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms), there was a specific hack in BlockForm for the 'negate' property that all conditions share. This hack was not updated in that patch, and ceased to function.
Therefore, all condition plugins without valid schema would not be correctly removed, and would be consulted during access checks for blocks.
This caused any blocks configured (while a module like Rules was enabled) to stop displaying.
Furthermore, condition plugins with valid schemas were only correctly handled because BlockForm *saved the block twice*. Once explicitly in ::submitForm(), once in its parent ::save().
The flow was:
- condition is checked for default state, failed due to type mismatch
- saved in submitForm()
- values casted to correct type by Config::castValue
- condition is checked for default state, correctly removed
- saved in save()
In order to properly compare the values without saving the entity twice, the values must be cast before being compared.
Proposed resolution
Move some of the config system into a trait, and use it directly.
The hastily named \Drupal\Core\Config\ConfigValueCaster is now used by both \Drupal\Core\Config\StorableConfigBase and \Drupal\Core\Condition\ConditionPluginCollection.
Remaining tasks
N/A
User interface changes
Blocks will now work regardless of whether condition plugins have a valid schema or not.
API changes
N/A
Data model changes
N/A
Original report
Hi
I'm putting some blocks in my structure, but nothing comes out.
Please find joined a snapshot of the Structure/Blocks zone, showing the blocks I'd like to add ;
and a snapshot of the rendered page, with... nothing appearing.
Any idea ?
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | 2811519-50.patch | 7.03 KB | alexpott |
| #50 | 2811519-50.test-only.patch | 4.99 KB | alexpott |
| #50 | 37-50-interdiff.txt | 4.86 KB | alexpott |
| #37 | 2811519-block-37-PASS.patch | 1.51 KB | tim.plunkett |
| #37 | 2811519-block-37-FAIL.patch | 850 bytes | tim.plunkett |
Comments
Comment #2
cilefen commentedHi @dbourrion:
What is the enabled theme?
Are there any errors in Drupal's log or the PHP log?
Comment #3
alexd73 commentedI have the some problem.
syslog is empty. Old blocks (located before) displayed.
Comment #4
veleno commentedI have the same problem.
I'm not able anymore to see new placed blocks in the layout, I can move the existing ones but cannot see any new added one. I've just upgraded to Drupal 8.2 then I've enabled the new "Place Blocks" module and later uninstalled it. I do not know if it is related to "Place Blocks" or not.
I also noted that, after adding a new block in admin/structure/block and saving the block config, I'm redirected to admin/structure/block/library/mytheme and not back to admin/structure/block.
I have the same result when using Bartik as theme and I have no error in the drupal log and in the system php log.
Regards
Oto Tortorella
Comment #5
dbourrion commentedSame as previous
Comment #6
cilefen commentedThis qualifies as major.
Comment #7
futurmat commentedI have the same issue here.
Comment #8
cilefen commentedRegarding the redirect after placing a block, there is an issue on that: #2794559: [regression] After placing a block and saving, you are directed to the block library (example: admin/structure/block/library/bartik) rather than to the block layout.
Comment #9
cilefen commented@catch and I discussed this. More information is needed from the affected sites but we think this should be critical based on reports.
Comment #10
futurmat commentedHappy to provide further information and ready to test solutions!
Comment #11
alexd73 commented@cilefen it seems to me odd that in the appearance of a lot of weird themes http://i.imgur.com/U1QKDeg.png
and in visable section very match new tabs http://i.imgur.com/OjHT9Ke.png
I can give you access to the site and ssh. If need, my email alexd73@gmail.com
Comment #12
xjmDoes this only occur after installing the Place Block module? If the module is uninstalled, can the blocks be placed again?
Comment #13
futurmat commentedI just have the two themes that came with the installation. However, I also have a long list underneath "Visibility". Since this is the first time I used Drupal 8 I thought that's the way it's supposed to be?!

I don't have the Place Block module installed.
Comment #14
cilefen commented@alexd73 It seems you have
$settings['extension_discovery_scan_tests'] = TRUE.Comment #15
cilefen commentedRe #13: Those extended conditions are from the Rules module.
Comment #16
cilefen commentedDoes every affected site have Rules enabled?
Comment #17
cilefen commentedWith Rules installed, placed blocks do not appear, and pre-Rules placed blocks disappear after being saved with Rules enabled, as they take on Rules visibility conditions.
Comment #18
futurmat commentedIn fact - Rules seemed to cause this problem. I uninstalled rules and can place blocks now!
Comment #19
giuliovale commentedThe problem is still present also with Place Block Module uninstalled
Comment #20
cilefen commentedThis problem does not exist in 8.1.10 but does in 8.2.0.
Comment #21
tim.plunkettDebugging this.
Comment #22
tim.plunkettThis is due to #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms). Now just to find out why!
Comment #23
catchNot quite the same, but #2800951: EntityField block broken on 8.2 due to SubFormState changes and #2798261: Using $form_state->getValue() in BlockBase's blockForm throws "subform and parent form must contain the #parents property" exception also look like fallout from that change.
Comment #24
veleno commentedRules creates the problem, I confirm that uninstalling it solves.
Comment #25
tim.plunkettIn \Drupal\Core\Condition\ConditionPluginCollection::getConfiguration(), we compare the
$default_configto the$instance_config.This was failing for all rules conditions, for two reasons.
One, rules provides NO config schema for it's plugins. Core does for all its own, see node.schema.yml line 108, which corresponds to
\Drupal\node\Plugin\Condition\NodeType.Two,
\Drupal\block\BlockForm::validateVisibility()used to massage the 'negate' value the ensure the type is correct. This code was not updated in the SubFormState issue above.This still needs tests, and Rules should add schema, but this fix works and is correct.
Comment #26
tim.plunkettHere's an update path.
Comment #27
catchThis looks reasonable, but yeah let's add test coverage.
Also discussed this issue with @xjm and @alexpott and we think it's worth putting out an early 8.2.1 for, probably early next week.
Comment #28
tim.plunkettThis is only solving a single special case. Any other Boolean config values in conditions will cause this same problem.
Working on a general solution.
Comment #29
xjmComment #30
xjmComment #31
tim.plunkettThis is an entirely new approach, so no interdiff.
Comment #32
tim.plunkettLast PASS patch didn't actually include the test in the FAIL patch.
Comment #33
tim.plunkettComment #35
tim.plunkettWow, the specific browser test I added is completely unnecessary. Adding a schema-less condition plugin to block_test.module broke a ton of tests!
Comment #36
alexpottI'm not entirely suer about using sub pieces of schema in the way introduced in this patch.
If we pass name into here then we can get rid of the abstract getName() which will remove the oddity of getName on the condition plugin returning a config name.
Comment #37
tim.plunkettGoing back to the quick-fix in #25, plus tests. The config stuff was a bit heavy-handed.
Comment #38
alexpott@tim.plunkett - we can open a follow up to discuss further fall out and a better fix. Maybe the config changes are the right way but I wouldn't want to rush that. Or maybe a better way will occur to us.
Comment #40
tim.plunkettThe test failures in #2815829: Adding or editing a block through the UI saves the entity twice imply that a bigger fix is needed anyway, we can work on it there.
Comment #41
alexpottThe fix in #37 will resolve the immediate issues and #40 outlines the existing followup. I think we are good to go here.
Comment #44
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!
Comment #45
catchThat patch didn't include the upgrade path from #26.
Comment #48
alexpottAfter discussion with @catch, @cilefen and @xjm we decided to revert this and wait for upgrade path tests.
Comment #49
alexpottAlso sorry everyone for the premature rtbc in #41 I should have spotted the missing upgrade path.
Comment #50
alexpottThe patch adds the missing update path and provides a simple test that adds a block with missing schema and the incorrect config prior to running updates and runs them.
Comment #51
dbourrion commentedHi
Thanks for all that stuff
Disabling Rules fixed the prob for me for the moment.
D.
Comment #53
tim.plunkettThe fix may be mine, but the update path tests are all @alexpott, so I'm RTBCing the patch.
Comment #56
catchThanks for the update path test.
Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!
Comment #58
tim.plunkettComment #59
websiteworkspace commentedAs of D8.6.4, this problem still exists.
I installed and enabled the rules module.
I changed a block configuration to specify block display on additional pages.
That block no longer appeared anywhere and no amount of attempting to adjust the block settings fixed the problem that the block would not appear anyway. Changing the block settings to appear on every page did not fix the problem.
--
Attempting to uninstall the D8 rules module then demands that all blocks touched by the rules module be deleted by the D8 rules module uninstall. Thus, uninstalling the D8 rules module then creates catastrophic configuration and content loss for the affected D8 site.
--
This is a critical problem.
It seems that the D8 rules module is not only unusable, the D8 rules module causes catastrophic configuration and content loss.
--
p.s. this critical problem required a rollback to the D8 site's previous day's automated daily backup (a very bad scenario)
Comment #60
jonathan1055 commentedHi websiteworkspace,
If you do have this problem, you may need to create a new issue in the Rules issue queue, and reference it back to this one, because not many people will be seeing this issue now that it it closed.
Jonathan