If a block has been configured to show up in only show up on certain admin content pages then it will not show up on the admin Block Layout page after the settings have been made.
Reason:
node_block_access is called by \Drupal\Core\Entity\EntityListController::getOperations() when it calls $entity->access('update');
The function is defined
function node_block_access($block)
But the hook is also called with an operation argument.
It is invoked in \Drupal\Core\Entity\EntityAccessController::access()
$this->moduleHandler->invokeAll($entity->entityType() . '_access', array($entity, $operation, $account, $langcode))
It seems that the purpose of node_block_access is only affect access when $operation == 'view'.
I will attach a patch that fixes this by checking for $operation == 'view'
Steps to test
- Install Drupal
- Disable overlay module(overlay seems to cause other problems related to blocks layout page that I am looking into)
- Goto admin/structure/block
- Click configure next to "footer" block.(affects all blocks)
- Under "Visibility settings->content types" select article
- Save the settings
- The configure link for the "footer" should be gone.
Apply the patch. Repeat the steps and the configure link should not disappear.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | drupal-2124599-28.patch | 2.07 KB | olli |
Comments
Comment #1
tedbowupdating status
Comment #2
tedbowSorry probably not "major"
Comment #3
berdirI think the way hook_block_access() was changed when the generic entity access hooks were introduced (hook_entity_access() and hook_{$entity_type}_access()), and this implementation wasn't updated.
The function definition should be updated to match hook_block_access(), with type hints and all arguments. (e.g., like overlay_block_access())
I'd also like to get @timplunkett's feedback here, to see if there's something else that needs to be updated.
Comment #4
tedbowUpdated patch for this
Comment #5
tedbowRelated overlay issue: #2124611: Block operations links don't show in Block Layout page when using Overlay.
Comment #7
tedbowSo it looks updating the definition of the function in #4 causes a bunch of tests to break.
I guess I will wait until @timplunkett provides feedback to see if the function needs to be updated.
Comment #8
berdirYou're missing the use statements, which need to be added to the top of the file.
Comment #9
tedbowI have added the use statements.
My testing on my localhost version of Drupal 8 doesn't work for some reason so sorry for not testing before I upload.
** Also my first comment on the new D7 version of drupal.org, so I hope I am doing it right. I added the related issue in the "related issue" field. Yay!
Comment #10
olli commentedAdded a small test.
Comment #12
olli commented10: drupal-2124599-10.patch queued for re-testing.
Comment #14
olli commented10: drupal-2124599-10.patch queued for re-testing.
The test did not complete due to a fatal error. Completion check UrlTest.php 58 Drupal\system\Tests\Common\UrlTest->testLinkAttributes()
Comment #16
olli commented10: drupal-2124599-10.patch queued for re-testing.
Comment #17
tim.plunkettMarked #2147727: Restricting block visibility by content type prevents block from being configured or deleted. as a dupe
Comment #18
xjm(Merging "node system" and "node.module" components for 8.x; disregard.)
Comment #19
dawehnerThis should be major at least. Sadly the patch does not apply anymore.
Comment #20
swentel commentedRerolled - also removed unused 'use' statement in node.module.
Comment #23
swentel commentedTiny update (end stop in comment)
Comment #24
olli commentedReroll.
Comment #26
olli commented24: drupal-2124599-24.patch queued for re-testing.
Comment #27
olli commentedComment #28
olli commentedreroll
Comment #29
berdirVerified manually that this fixes the problem and that the test is failing without the fix. This is good to go, let's get it in :)
Comment #30
catchCommitted/pushed to 8.x, thanks!