Currently, the admin form submit handler updates nodes affected by permissions changes on a per-row basis. This adds a lot of unneeded overhead to admin form submissions, because the same nodes may be affected by multiple terms or vocabularies. It would be better to collect a list of affected node ids and then run _taxonomy_access_node_access_update() only once after all other processing has taken place.

CommentFileSizeAuthor
#5 tac_732844-5.patch4.41 KBxjm
#2 tac_732844-2.patch5.17 KBxjm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm’s picture

I looked through the code, and _taxonomy_access_node_access_update() is called in the following functions:

  1. taxonomy_access_admin_delete_role()
  2. taxonomy_access_admin_form_submit()
  3. taxonomy_access_grant_update()
  4. taxonomy_access_defaults_update()
  5. hook_taxonomy()

Numbers 3 and 4 are all called only by the submit handler itself (#2), or by other functions that are in turn called by the submit handler. Therefore, this is what I propose:

  1. Modify _taxonomy_access_cache_affected_nodes() to append more affected nodes to an existing list
  2. Replace calls to _taxonomy_access_node_access_update() in 3 and 4 above with _taxonomy_access_cache_affected_nodes().
  3. Place the following just before return in the submit handler for 'add' and 'save all' cases:
    _taxonomy_access_node_access_update(_taxonomy_access_cache_affected_nodes());
    
  4. Refactor the 'delete' case in the submit handler to use the cache where it currently calls _taxonomy_access_node_access_update() and then call that once with the cache as above.
xjm’s picture

Status: Active » Needs review
FileSize
5.17 KB

Attached patch implements the solution described in #1. This needs to be tested thoroughly once #739732: Nodes not updated on vocabulary default add and #739874: Some nodes not updated on role disable are fixed.

keve’s picture

The logic of this solution is ok, but it needs testing.

xjm’s picture

The patch needs to be rerolled against CVS; the first hunk fails. (The other 7 succeed with fuzz + offsets).

xjm’s picture

FileSize
4.41 KB

Here's the patch rerolled against CVS.

xjm’s picture

Tested adding, deleting, and changing both terms and defaults; the list of nodes updated seems appropriate in all three cases.

xjm’s picture

Status: Needs review » Fixed

Committed to 6.x-1.x-dev:
http://drupal.org/cvs?commit=341362

Status: Fixed » Closed (fixed)

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