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

  1. Install Drupal
  2. Disable overlay module(overlay seems to cause other problems related to blocks layout page that I am looking into)
  3. Goto admin/structure/block
  4. Click configure next to "footer" block.(affects all blocks)
  5. Under "Visibility settings->content types" select article
  6. Save the settings
  7. The configure link for the "footer" should be gone.

Apply the patch. Repeat the steps and the configure link should not disappear.

Comments

tedbow’s picture

Status: Active » Needs review

updating status

tedbow’s picture

Priority: Major » Normal

Sorry probably not "major"

berdir’s picture

Status: Needs review » Needs work

I 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.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new747 bytes

The function definition should be updated to match hook_block_access(), with type hints and all arguments. (e.g., like overlay_block_access())

Updated patch for this

tedbow’s picture

Status: Needs review » Needs work

The last submitted patch, add_op_to_node_block_access-2124599-4.patch, failed testing.

tedbow’s picture

So 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.

berdir’s picture

You're missing the use statements, which need to be added to the top of the file.

tedbow’s picture

Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#2124611: Block operations links don't show in Block Layout page when using Overlay.
StatusFileSize
new994 bytes

I 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!

olli’s picture

Component: node system » node.module
Issue tags: +Blocks-Layouts
StatusFileSize
new850 bytes
new1.8 KB

Added a small test.

Status: Needs review » Needs work

The last submitted patch, 10: drupal-2124599-10.patch, failed testing.

olli’s picture

Status: Needs work » Needs review

10: drupal-2124599-10.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 10: drupal-2124599-10.patch, failed testing.

olli’s picture

Status: Needs work » Needs review

10: 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()

Status: Needs review » Needs work

The last submitted patch, 10: drupal-2124599-10.patch, failed testing.

olli’s picture

Status: Needs work » Needs review

10: drupal-2124599-10.patch queued for re-testing.

tim.plunkett’s picture

xjm’s picture

Component: node.module » node system

(Merging "node system" and "node.module" components for 8.x; disregard.)

dawehner’s picture

Priority: Normal » Major
Status: Needs review » Needs work
Issue tags: +Needs reroll

This should be major at least. Sadly the patch does not apply anymore.

swentel’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.03 KB

Rerolled - also removed unused 'use' statement in node.module.

Status: Needs review » Needs work

The last submitted patch, 20: drupal-2124599-20.patch, failed testing.

The last submitted patch, 20: drupal-2124599-20.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new2.03 KB

Tiny update (end stop in comment)

olli’s picture

StatusFileSize
new2.05 KB
new885 bytes

Reroll.

Status: Needs review » Needs work

The last submitted patch, 24: drupal-2124599-24.patch, failed testing.

olli’s picture

24: drupal-2124599-24.patch queued for re-testing.

olli’s picture

Status: Needs work » Needs review
olli’s picture

StatusFileSize
new2.07 KB

reroll

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Verified 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 :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 6a4ba9d on 8.x by catch:
    Issue #2124599 by olli, tedbow, swentel: ode_block_access affects access...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.