Please check my port to Drupal 8 (beta 10)
I have tested it with my port of Content Access module (https://www.drupal.org/node/2032001)

Tests won't pass because issue version is 7.x, you can run them manually to ensure that they are working

I see that you are seeking for co-maintainers. Can I also ask you for permissions to maintain 8.x branch?

CommentFileSizeAuthor
#68 2495027-acl-drupal8-port-68.patch71.09 KBid.tarzanych
#65 2495027-acl-drupal8-port-65.patch71.21 KBid.tarzanych
#61 2495027-acl-drupal8-port-61.patch63.76 KBid.tarzanych
#59 2495027-acl-drupal8-port-59.patch63.78 KBid.tarzanych
#53 2495027-acl-drupal8-port-53.patch46.84 KBid.tarzanych
#43 2495027-acl-drupal8-port-43.patch47.03 KBid.tarzanych
#34 2495027-acl-drupal8-port-34.patch46.99 KBid.tarzanych
#20 2495027-acl-drupal8-port-20.patch45.84 KBid.tarzanych
#1 2495027-acl-drupal8-port.patch31.17 KBid.tarzanych
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

id.tarzanych’s picture

Issue summary: View changes
FileSize
31.17 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2495027-acl-drupal8-port.patch, failed testing.

id.tarzanych’s picture

Status: Needs work » Needs review
salvis’s picture

Priority: Normal » Major

Thank you for your work, id.tarzanych!

I need to create a D7 release and from that a D8 branch, but I'd like #2385183: Oracle Support to go into the D7 release first.

Also, for D8, we need to rename the 'number' column because 'number' is a reserved word. The closest we can get is probably 'figure', but I'd use that only for the database table and keep the parameters unchanged.

Thank you for offering co-maintainership. Please stick around and see this through to release. You're very new to Drupal and I can't give you commit access right away, but I'm very interested to have you on board!

id.tarzanych’s picture

Thanks for review, salvis!

I've analyzed #2385183: Oracle Support
metallized used number_acl for field name.
Should I proceed with that, or use figure table field name?

salvis’s picture

Re: #2385183: Oracle Support

Both names are weird in their own way, but number_acl could more easily be misinterpreted (as having a meaning that it doesn't), so I'd prefer figure.

The trouble is I don't have an Oracle installation to investigate/test this and I don't know whether it's just that column name that causes problems or if there's more...

We'll need a D7 release and a D8 branch so that you can create a patch against 8.x-1.x-dev before I can really look at it and commit it.

id.tarzanych’s picture

Thanks, waiting for D8 branch

id.tarzanych’s picture

Patch tested with Drupal 8 beta11, works correctly

toamit’s picture

Please open D8-dev branch, rather than making interested contributor wait.

Status: Needs review » Needs work

The last submitted patch, 1: 2495027-acl-drupal8-port.patch, failed testing.

wwedding’s picture

What exactly does "a d7 release" mean. With my understanding of the terms, a "d7" release happened back in 2011 when 1.0 was made live. Do you mean "1.1" is overdue and you want that done, first?

Could one of the maintainers create a task with "release blockers" attached, describing what the goals are and why they're preventing any progress in d8.

salvis’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Category: Feature request » Task
Status: Needs work » Needs review

It's good practice to create a tag and release before branching, so that we have a well-defined base for D8.

8.x-1.x-dev is ready now.

salvis’s picture

Wow, green at the first try!

id.tarzanych’s picture

That's good
I'll update patch according to your requirements

salvis’s picture

There are some things that we should do, going from D7 to D8:

  1. Update the version number in README.txt.
  2. Feel free to add a line for yourself under Acknowledgements in README.txt.
  3. Replace the upgrade information for D7 with upgrade information from D6 and D7 to D8 in README.txt.
  4. Take the opportunity to rename the 'number' column to 'figure' as per #2385183-6: Oracle Support and #4 above. Or some other column name, if you can think of a better one that is not a reserved word.

    I wonder whether we can get away with writing an acl_update_8001() function to change the database schema (or whether we really need the Migrate API). Accroding to Upgrade API, hook_upgrade_NNN() is not run during major upgrades, but Migrate API is overkill just for renaming a column...

  5. I see that you've turned a number of db_query() calls into DBTNG format, which has more overhead. We need to check whether any of these are ever executed in a loop (e.g. from Views), which could result in a severe performance loss. Node Access is a notorious performance killer, and we must be very careful that we don't make things worse!

There'll probably be more.

And we'll need testing by everyone!

id.tarzanych’s picture

Seems that we'll have to use Migrate API and create mapping.
Other things are done. Tested on Beta15

salvis’s picture

Seems that we'll have to use Migrate API and create mapping.

Hmm, if I understand https://www.drupal.org/node/2186315 correctly, then every contrib needs to implement the Migrate path...

The 'number' column wasn't introduced until acl_update_7000(), and direct upgrading from D6 needs to add (not just rename) the column.

id.tarzanych’s picture

Please review a new patch.
I've added migration template, source, destination plugins, covered migration process with Simpletest.

By the way, ACL for Drupal 6 has `number` column in `acl` table. It is introduced in acl_update_6002().

I couldn't find detailed documentation about that, so please tell me if you have any suggestions

Status: Needs review » Needs work

The last submitted patch, 20: 2495027-acl-drupal8-port-20.patch, failed testing.

id.tarzanych’s picture

Hm, PHP 7 test doesn't want to pass... Will install it tomorrow

UPD: I am a bit confused. It's green, but patch failed testing

id.tarzanych’s picture

According to #2454439: [META] Support PHP 7 Drupal 8 currently is not fully compatible with PHP 7

I've installed PHP 7 on my machine and I get
Error: Cannot access protected property Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::$storage in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->getSchemaFromStorageDefinition() (line 212 of /var/www/drupal8/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
fatal error even in vanilla Drupal 8 beta 15 on some of configuration pages

id.tarzanych’s picture

Status: Needs work » Needs review

salvis’s picture

Thank you for the updated patch, id.tarzanych!

Any reviewers/testers out there?

Are there any client modules for ACL yet?

id.tarzanych’s picture

I've also ported Content Access module to Drupal 8. This module consists Simpletest cases for ACL.
https://www.drupal.org/node/144819/git-instructions/8.x-1.x

I received co-maintainer access 3 months ago, but without ability to create releases #2504653: Co-maintainer access to Content Access module (D8 version).
I need to develop Migrate mappings there as well, going to request dev-8.x-1.x release create after that.
Can I ask you for feedback in the future drupal.org issue?

Status: Needs review » Needs work

The last submitted patch, 20: 2495027-acl-drupal8-port-20.patch, failed testing.

The last submitted patch, 20: 2495027-acl-drupal8-port-20.patch, failed testing.

salvis’s picture

Now that CI seems to work for contribs, I've enabled the non-MySQL databases as well, and apparently they're still causing issues.

Can I ask you for feedback in the future drupal.org issue?

I'm not sure I understand -- I'll be happy to help where I can, but you're ahead of me as far as D8 is concerned...

id.tarzanych’s picture

I'll work on non-MySQL databases support

However I am not sure that

11:01:31 PHP Notice:  Undefined index: user in /opt/drupalci_testbot/src/DrupalCI/Plugin/BuildSteps/publish/JunitXMLFormat.php on line 43
11:01:31 PHP Notice:  Undefined index: pass in /opt/drupalci_testbot/src/DrupalCI/Plugin/BuildSteps/publish/JunitXMLFormat.php on line 44
11:01:31 PHP Fatal error:  Call to a member function fetch() on a non-object in /opt/drupalci_testbot/src/DrupalCI/Plugin/BuildSteps/publish/JunitXMLFormat.php on line 116

is caused by ACL code

salvis’s picture

Where did you see that?

I think the errors for pgsql and sqlite are in the database layer. The db_insert()->from($subselect) should create a parenthesis around the SELECT but apparently doesn't.

id.tarzanych’s picture

Found that in Drupal CI Jenkins log.

I haven't checked Drupal 8 on PostgreSQL yet, will try to do that tomorrow or on Saturday

Status: Needs review » Needs work

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 34: 2495027-acl-drupal8-port-34.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 43: 2495027-acl-drupal8-port-43.patch, failed testing.

The last submitted patch, 20: 2495027-acl-drupal8-port-20.patch, failed testing.

id.tarzanych’s picture

DrupalDumpBase was removed a day ago.
Thanks to chx for pointing at that

id.tarzanych’s picture

id.tarzanych’s picture

Green :)
At last

salvis’s picture

Status: Needs review » Needs work

Fantastic -- this is really great!

Here are a some comments from looking through the code, in no particular order:

1. CHANGELOG.txt: Please add periods at the end of the items.

2. README.txt line 65: Change to 8.x

3. acl.install:

    'indexes'         => array(
      'module_name_figure' => array(
        array('module', 64),
        array('name', 64),
        'figure',
      ),
      'module_figure' => array(
        array('module', 64),
        'figure',
      ),

I wonder whether it would make sense to take the opportunity and reverse the indexes, i.e. have 'module_figure_name' and 'module_name', because an int index is probably more efficient than a varchar index. What do you think?

4. acl_create_acl() was somewhat permissive by allowing calls with the same arguments and returning the matching $acl_id if the record already existed. This was not documented but still a potentially useful feature. You've changed drupal_write_record() to db_insert() which would cause an error in this case. Can we use db_merge(), write a test, and document the feature?

5. Let's remove acl_create_new_acl().

6. acl_add_nodes(): We should keep the db_insert()->from($subselect) for MySQL. If the others need a clumsy work-around that should not go at the expense of MySQL.

7. _acl_module_load_include() is not used anymore, remove.

8. acl_node_access_explain() and acl_node_test_node_grants(): I like functional programming. Unless there's a clear benefit to having a variable I like avoiding one-time-use variables, especially if they lead to odd naming such as foreach ($users as $account).

9. AclWebTestCase.php: Why is this class called AclWebTestCase and not AclTest?

10. AclWebTestCase: We don't really need $web_user to be a property. I made an exception to my rule to not define one-time-use variables, because I wanted to show the familiar pattern and use the familiar name. Making it a local variable implies that we won't use any other users.

11. AclWebTestCase::setUp(): entity_create() is deprecated.

12. AclWebTestCase::setUp(): Please fix 'succesfully' to have one more 's' (wrong in the D7 version).

13. d6_d7_table.php: D6 does not have a 'number' column.

14. It seems we're only migrating the {acl} table at this point. What about the other tables?

I've added migration template, source, destination plugins, covered migration process with Simpletest.

15. The migration tests don't test anything yet, do they?

16. acl.install: It makes no sense to keep the old hook_update_NNN() implementations, does it? Please remove them.

I haven't done any actual testing yet.

id.tarzanych’s picture

3. I'll analyze that
4. Sure
6. I've changed insert from subselect to db_insert, because it causes errors in PostgreSQL and SQLite despite their syntax supports that. I'll check what can I do here
13. Drupal 6 version DOES have number column (https://www.drupal.org/node/936682)
14. Will check that
15. They test number to figure property migration

salvis’s picture

Re 6.: We should be able to do something like

  if (Database::getConnection()->databaseType() == 'mysql') {
    // use db_insert()->from($subselect)
  } else {
    // The PostgreSQL and SQLite drivers currently fail to
    // generate the required parentheses around the subselect and
    // cause an error in their respective database systems.

    // use ugly and inefficient fallback
  }

Re 13.: Ah, yes, you're right. I was confused because I saw acl_update_7000() adding the 'number' column. But it was also added in acl_update_6002().

15. They test number to figure property migration

Yes, but that still leaves a lot of room for things to go wrong. We're really missing devel_node_access.module in D8 at this point.

id.tarzanych’s picture

Re 6: Good point. Will do that

id.tarzanych’s picture

Let's try this patch
I've completed Migrate mappings and covered them with tests.
I've put testMigration() class into a trait, because test cases are equal for Drupal 6 and Drupal 7.

Most of all I am concerned about acl_create_acl.
merge() method returns us only STATUS_INSERT or STATUS_UPDATE, but seems that there is no other mechanism to get acl_id than add an extra query. What do you think about that?

Status: Needs review » Needs work

The last submitted patch, 59: 2495027-acl-drupal8-port-59.patch, failed testing.

id.tarzanych’s picture

id.tarzanych’s picture

Passed tests.
salvis, please check this patch

salvis’s picture

You're right with your concern about db_merge(), and it's deprecated, too!

Also, the code in Merge::execute() is not what I was counting on. I was hoping for an SQL MERGE query, but apparently that's not what we're getting.

So I agree with going with db_insert(). Those who need the old undocumented functionality can do their own query.

id.tarzanych’s picture

Is everything else affirmative for you?

I hope I'll be able to change db_merge to db_insert shortly.

id.tarzanych’s picture

Changed db_merge() to db_insert() in acl_create_acl() function.

After that I decided to get rid of deprecated functions and classes in ACL module code (db_select(), db_insert(), db_delete(), db_update(), SafeMarkup) and replaced them with latest Drupal 8 core functions. Then I improved code styling where it was possible.

salvis’s picture

Status: Needs review » Needs work

This looks very good, thank you!

  1. +++ b/acl.admin.inc
    @@ -5,32 +5,50 @@
    -  if (!isset($label)) {
    -    $label = (isset($record['name']) ? $record['name'] : (isset($record['number']) ? $record['number'] : $acl_id));
    +
    +  if (!empty($label)) {
    

    !empty() is wrong. empty() would be much closer, but still not the same as !isset(). We need !isset() here, so that the caller can pass '' (an empty string).

    The ultimate guide to these functions (actually they're language constructs and not functions) is http://php.net/manual/en/types.comparisons.php .

  2. +++ b/acl.module
    @@ -196,38 +241,42 @@ function acl_get_id_by_number($module, $number) {
    -  ))->fetchField();
    +  return Database::getConnection()
    +    ->query("SELECT COUNT(uid) FROM {acl_user} WHERE acl_id = :acl_id", [
    +      'acl_id' => $acl_id,
    +    ])->fetchField();
     }
     
     /**
      * Determine whether an ACL has a specific assigned user.
      */
     function acl_has_user($acl_id, $uid) {
    -  return db_query("SELECT COUNT(uid) FROM {acl_user} WHERE acl_id = :acl_id AND uid = :uid", array(
    -    'acl_id' => $acl_id,
    -    'uid' => $uid,
    -  ))->fetchField();
    +  return Database::getConnection()
    +    ->query("SELECT COUNT(uid) FROM {acl_user} WHERE acl_id = :acl_id AND uid = :uid", [
    +      'acl_id' => $acl_id,
    +      'uid' => $uid,
    +    ])
    +    ->fetchField();
    

    Inconsistent formatting for fetchField() (just to show that I'm paying attention :-)). Core is inconsistent, too, but putting the arrow operator is the way to go, as you've put it everywhere else.

    (This is really a tiny nit that I wouldn't have mentioned if we didn't have #1 above.)

  3. +++ b/migration_templates/d6_d7_acl.yml
    @@ -0,0 +1,14 @@
    \ No newline at end of file
    
    +++ b/migration_templates/d6_d7_acl_node.yml
    @@ -0,0 +1,42 @@
    \ No newline at end of file
    
    +++ b/migration_templates/d6_d7_acl_user.yml
    @@ -0,0 +1,30 @@
    \ No newline at end of file
    
    +++ b/tests/fixtures/d6_d7_table.php
    @@ -0,0 +1,195 @@
    \ No newline at end of file
    

    Dreditor does not like having no newline at the end of text files.

I've been wrestling with enabling OPCache in my WAMPP installation, without success so far, and I'll be offline on a business trip for the rest of the week, but I promise I'll do actual testing on Saturday.

id.tarzanych’s picture

Re 1: Ah, yes, my mistake, sorry. I should be more concentrated

Will fix others today

id.tarzanych’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

id.tarzanych’s picture

Probably core was updated again... I fixed styling only

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

salvis’s picture

Status: Needs work » Needs review

It looks like the result list just keeps getting longer when you retest, rather than just showing the last result for each test. At this point we only have the "PHP 7 & MySQL 5.5" test failing, which we ignore for now.

Status: Needs review » Needs work

The last submitted patch, 68: 2495027-acl-drupal8-port-68.patch, failed testing.

salvis’s picture

Argh, whenever we set to NR, it requeues the five tests that are functional (the PHP 5.4 tests aren't), and adds five results.

So, if anyone has an interest here, this is Needs Review and testing.

Mixologic’s picture

You probably do not want to set every single environment to issues and commit then.
https://www.drupal.org/node/87985/qa

Ideally you have just mysql5.5 and php5.5 set to issues and commit, and the rest set to just branch on commit. That way every patch doesnt spin up five testbots to over validate potential work in progress, and when that work gets comitted, it can warn of any other outstanding regressions.

id.tarzanych’s picture

Status: Needs work » Needs review

  • salvis committed e5acef0 on 8.x-1.x authored by id.tarzanych
    Issue #2495027 by id.tarzanych, salvis: Initial port to D8.
    * Developed...
salvis’s picture

Status: Needs review » Fixed
Issue tags: -Drupal 8

I put the empty lines back into README.txt and CHANGELOG.txt and updated the latter. No other changes to #68.

Thank you for all your work and your perseverance, id.tarzanych!

We have a great baseline with your patch — I've tagged it as 8.x-1.x-alpha1.

Testing continues in #2596089: ACL for D8 — ALPHA1.

(Mixologic: Thanks for your hints in #80.)

id.tarzanych’s picture

Thank you too, salvis!

I am currently working on Content Access port
It doesn't work with the latest core release.
Can I ask you for your review and feedback in the future?

salvis’s picture

Can I ask you for your review and feedback in the future?

Yes, sure. I can't guarantee fast follow-up though...

Also, as far as CA is concerned, I don't know its internals and I'm not sure whether the D7 version is really working, which makes things pretty difficult... I've posted #2596099: Create a D8 snapshot release to nudge fago -- hope it helps...

You asked for co-maintaining ACL for D8 -- I'd be happy to have you on board and I've added your ID to the list. Please take a look at Best practices for co-maintaining projects.

Do you know Devel Node Access? I consider it pretty much indispensable for working on a node access module, but unfortunately I haven't had time to work on the D8 version. Would you be interested to give it a try?

id.tarzanych’s picture

Do you know Devel Node Access? I consider it pretty much indispensable for working on a node access module, but unfortunately I haven't had time to work on the D8 version. Would you be interested to give it a try?

Yes, for sure. But I see that it is already ported, at least partly.
I'll test that.

Please take a look at Best practices for co-maintaining projects.

Done

salvis’s picture

But I see that it is already ported, at least partly.

Yes, somewhat, but it's not working at all right now:
#2380335: Devel Node Access block is broken
#2208875: Fix fatal errors in devel_node_access following hook_menu removal

id.tarzanych’s picture

Okay, I'll see what I can do

Status: Fixed » Closed (fixed)

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