id.tarzanych has created a 8.x-1.x branch in your repository with his D8 port from #2032001: Content Access Drupal 8 port.

Now please create a D8 snapshot release to make it visible.

Comments

salvis created an issue. See original summary.

id.tarzanych’s picture

Made also some optimizations, ported Rules-related code

andypost’s picture

Status: Active » Needs work

needs work at least for database usage

  1. +++ b/content_access.admin.inc
    @@ -32,20 +33,21 @@ function content_access_page_reset($form, FormStateInterface $form_state) {
    +  $query = Database::getConnection()->select('node', 'n')
    
    +++ b/content_access.module
    @@ -430,38 +468,40 @@ function content_access_per_node_setting($op, NodeInterface $node, $settings = N
    +  $query = Database::getConnection()->query("SELECT settings FROM {content_access} WHERE nid = :nid", [
    ...
    +  $connection = Database::getConnection();
    
    @@ -473,7 +513,7 @@ function content_access_save_per_node_settings(NodeInterface $node, $settings) {
    +  Database::getConnection()->delete('content_access')
    
    @@ -649,12 +704,11 @@ function content_access_get_acl_id(NodeInterface $node, $op) {
    +  $result = Database::getConnection()->query("SELECT n.nid FROM {node} n WHERE type = :type", [
    

    use \Drupal::database() for that

  2. +++ b/content_access.module
    @@ -137,9 +137,9 @@ function content_access_entity_operation(EntityInterface $entity) {
    -    $account = \Drupal::currentUser();
    +    $user = \Drupal::currentUser();
    

    core use $account in most of places

andypost’s picture

I'm pretty sure this patch should be splitted
1) code clean-up
2) rules integration

first one is a blocker for RC

salvis’s picture

 
 

fago: Please create a D8 snapshot release!!!

 
 
id.tarzanych has commit access, but apparently he cannot create a release node.

As long as we don't have a snapshot release, we don't have anything to stand on and patches don't make much sense, whether split or in one big chunk.

morbus iff’s picture

Random testing note: Create a new content type. Created three nodes. Installed Content Access 8.x-1.x branch.. Removed "view" perms for that content type for anonymous and authenticated users. Saved. Cleared cache. Anonymous can not view three nodes. Yay. Authenticated can view three nodes. Boo.

id.tarzanych’s picture

Thanks, I'll check that and complete tests.
There is still a lot of work to do, but 8.x-1.x-dev will provide us possibility to run automated tests on drupal.org

id.tarzanych’s picture

Morbus Iff,
I've tested Content Access for D8 too.
Module works for me, but it does not show message about node access permissions need to be rebuilt.

I'll try to fix that in my next patch.

morbus iff’s picture

@id.tarzanych:

Hrms. I had rebuilt permissions on my end prior to doing the test.

I'll do so again shortly and report back.

morbus iff’s picture

StatusFileSize
new34.6 KB

Using rc3, this is still broken for me. In fact, it's gotten worse: anonymous users can now see the content. I've attached a screen of my current permissions for a content type. After rebuilding permissions on the Status report page, anonymous and authenticated are able to view any nodes of that content type.

In rc3, viewing this content type's "Access" tab also seems to cause watchdog errors, but unknown know if it's related to CA or not: User error: Invalid placeholder: !permissions in Drupal\Component\Render\FormattableMarkup::placeholderFormat() (line 240 of core/lib/Drupal/Component/Render/FormattableMarkup.php).

EDIT: Actually, I should mention that I'm using JUST the 8.x-1.x that's currently in git, NOT one that's been patched with the attached. That's probably my problem, right?

EDIT 2: Applied patch. Rebuilt permissions. Same result in rc3.

id.tarzanych’s picture

StatusFileSize
new96.27 KB

Reworked module structure, made it more suitable to Drupal 8 standards, fixed FormattedMarkup compatibility and other minor bugs.

I've installed vanilla Drupal 8 from 8.0.x branch. Simpletest and manual tests went good for me

Morbus Iff,
If module still doesn't work for you, can you try to increase module's priority setting?

id.tarzanych’s picture

Status: Needs work » Active
andypost’s picture

Status: Active » Reviewed & tested by the community

I think it's ready now

  • id.tarzanych committed 790e43f on 8.x-1.x
    Issue #2596099 by id.tarzanych: Create a D8 snapshot release
    
id.tarzanych’s picture

Status: Reviewed & tested by the community » Active

Commited changes.
Marking task as Active because we still need to add 8.x-1.x-dev to the list

jhaskins’s picture

Here's some more info on the issue Morbus Iff is encountering. It seems that using the role based access control settings with more than 2 roles causes the access control to fail. I was able to duplicate this on a fresh install of D8 RC3 and the most recent Content Access code.

Steps to duplicate:

  1. Create at least 1 custom role.
  2. Choose a content type and restrict "View any" permissions to 3 or more roles leaving anonymous users without the permission. You can use admin, auth user, and 1 custom role, all custom roles, or any other combination. It doesn't seem to make a difference.
  3. Create a node using the restricted content type if you don't have one already.
  4. Logout (or use a different browser) and try viewing a node of the restricted type as an anonymous user. You'll be able to view the node even though anonymous users aren't supposed to be able to view content of that type.

If you only grant 1 or 2 roles the view any permission for the content type, it seems to work as expected. 3 or more seems to be causing problems.

jhaskins’s picture

StatusFileSize
new854 bytes

Alright, the cause of this whole mess seems to be that content_access_optimize_grants() is assuming that the keys of $grants are gids even though they are not. I've attached a patch the fixes that assumption. I've tested it with every possible combination of role permissions I could think of and everything seems to work as expected with the patch.

id.tarzanych’s picture

@jhaskins,

Thanks, Joe!
Commited your patch

But we still need Drupal 8 snapshot release....

francewhoa’s picture

fago’s picture

Status: Active » Fixed

I created the snapshot release + granted id.tarzanych access to roll releases also :) Thanks!

id.tarzanych’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
id.tarzanych’s picture

Thanks, fago!

Status: Fixed » Closed (fixed)

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