It doesn't seem possible to export taxonomy_access data with the Features module. Is that true? If so, let's add that ability.

Comments

xjm’s picture

Status: Active » Postponed

This is on the road map for 7.x-2.x (some day...); however, a patch for 6.x is welcome.

KimNyholm’s picture

Version: 6.x-1.3 » 7.x-1.x-dev
Assigned: Unassigned » KimNyholm
Issue summary: View changes
Status: Postponed » Needs work
KimNyholm’s picture

Assigned: KimNyholm » Unassigned
Status: Needs work » Needs review
StatusFileSize
new10.19 KB

Please find attached a patch with features integration.

AliMartin’s picture

Hi!

Silly question, but I'm having problems applying this patch. I'm developing locally on OSX / MAMP Pro 4 and ordinarily drop the patch file into the relevant module folder and run "patch < filename.patch" at the command line.

I've tried running this patch within the 7.x-1.x-dev version of the Taxonomy Access Control module folder (plus the Features and Features/Includes folders out of desperation, and the release version of TAC) but nothing appears to be happening to my Features control panel - I can't see any options to package up TAC settings into Features.

When I run "patch < features_module-1154392-3.patch" and press return I don't get any error messages, just the next line in the command prompt.

Drupal: 7.51
Features: 7.x-2.10
Features Extras: 7.x-1.0

Any pointers?

KimNyholm’s picture

StatusFileSize
new242.5 KB

It should work for 7.x-1.x, see below.

Regards
Kim

vagrant@ubuntu:~$ git clone --branch 7.x-1.x https://git.drupal.org/project/taxonomy_access.git
Cloning into 'taxonomy_access'...
remote: Counting objects: 2220, done.
remote: Compressing objects: 100% (1457/1457), done.
Receiving objects: 100% (2220/2220), 783.70 KiB | 78.00 KiB/s, done.
remote: Total 2220 (delta 1453), reused 1197 (delta 761)
Resolving deltas: 100% (1453/1453), done.
Checking connectivity... done.
vagrant@ubuntu:~$ cd taxonomy_access/
vagrant@ubuntu:~/taxonomy_access$ cp /vagrant/features_module-1154392-3.patch .
vagrant@ubuntu:~/taxonomy_access$ git apply features_module-1154392-3.patch
vagrant@ubuntu:~/taxonomy_access$ git status
On branch 7.x-1.x
Your branch is up-to-date with 'origin/7.x-1.x'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   taxonomy_access.module

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        features_module-1154392-3.patch
        taxonomy_access.features.inc

no changes added to commit (use "git add" and/or "git commit -a")
vagrant@ubuntu:~/taxonomy_access$

After installing and clearing caches you should see Taxonomy Access Control in the features recreate panel, see attached.
Features panel.

AliMartin’s picture

Hi Kim

Many thanks for your detailed reply. I was able to recreate those steps to a successful conclusion :) Must be a "feature" of the OSX patching method...!

Ali

alison’s picture

Hi all! Love this, and thank you! Any guess wrt when it might be rolled-in? Thanks again!

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community
alison’s picture

I guess we've been getting errors from this file (taxonomy_access.features.inc) -- on Drupal 7.60/7.61, with PHP versions 5.6 and 7.1. (Possibly before 7.60, too, I'm not sure exactly when it started!)

We're getting a slew of log entries, each containing this message:
Notice: Trying to get property of non-object in _tac_features_getTerms() (line 88 of /path/to/sites/all/modules/contrib/taxonomy_access/taxonomy_access.features.inc).

I'm not 100% sure, but I think it happens when cron runs. I don't *think* it happens any other time.

alison’s picture

Hi y'all! Anything I or anyone else can do to help getting this rolled into the module? Thank you!

alison’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new10.27 KB
new553 bytes

I added an is_object() check, it seems to have stopped the errors I get on cron run -- I'm not positive but my guess is that the error happens when there are entities without the vocab or a term in the vocab.....?? So it's like, there's no term so it isn't an object? Anyway, I'm not sure if that's the cause, and also, if it were, I'm not sure why the error would happen on cron run. ANYWAY, regardless, idk if this patch is a good idea, y'all can let me know :)

KimNyholm’s picture

Status: Needs review » Needs work

The is_object() test is ok to add to handle the situation where the term has been deleted from the database.
However I would suggest to skip only the missing terms using the following logic and always return an array:

function _tac_features_getTerms($rid, $vid){
  $termGrants=_tac_features_dbGetTerms($rid, $vid);
  $terms = array();
  foreach($termGrants as $termGrant){
    $term = taxonomy_term_load($termGrant->tid);
    // We don't want to export the tid, its is internal.
    if (is_object($term)) {
      unset($termGrant->tid);
      $terms[$term->name]=$termGrant;
    }
  }
  return $terms;
}
alison’s picture

Status: Needs work » Needs review
StatusFileSize
new10.23 KB
new594 bytes

Gotcha, I think that sounds sensible? Updated patch attached.

Silly question: It's ok to return the $terms array empty like that?