After having upgraded OG to 2.7, the token which contains the group reference does not work. I am using this in the patterns for URL aliases:

[node:og-group-ref:0:title]/[node:title]

With 2.6 I got e.g.:

covs.nl/redactie/test

In 2.7 this is only:

covs.nl//test

*Edit* I added an extra slash above, which I forgot. This emphasizes the missing token.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shushu’s picture

Status: Active » Closed (cannot reproduce)

I tried this scenario:
1. Installed OG 2.6, created some content in group, and used Rules to print out the tokens you mentioned. I was able to see it properly.
2. Upgraded to 2.7, cleared cache, and tried to see the same tokens. I was able to see them properly.

If you have other scenario that can reproduce the problem, please let me know.

johnofjack’s picture

Status: Closed (cannot reproduce) » Needs review

We're having the same results as the original poster: the existing token no longer works, but fails silently (getting a null result?)

I set up a fresh install of Panopoly and found that you get an error message when attempting to use a token calling on og-group-ref: The Pattern for all Blog entry paths is using the following invalid tokens: [node:og-group-ref:0].

Steps to reproduce:

1. Install Panopoly (pathauto will be installed with it).
2. Install Organic Groups 2.7.
3. Go to /admin/config/search/path/patterns and attempt to save the token [node:og-group-ref:0] as part of a URL alias pattern.
4. Get the previous error message.

shushu’s picture

Status: Needs review » Closed (cannot reproduce)

Sorry, I failed to reproduce.
1. I installed panopoly.
2. I installed og.
3. (important) I configured OG fields for content types to make group and group content. Certainly, without it the token will be invalid.
4. I used [node:og-group-ref] on path pattern and on rules.

Please reopen if you have a valid scenario I can reproduce with.

miromarchi’s picture

I have the same problem.
That's my scenario:
I have 3 node types. "Organization" → og group; "Project" → og group content; "relation" → og group content.
I'm using rules to create a node of type "relation" after a new node of type "project" is created.
So basically when an "organization" (group) creates a new "project", a "relation" is created between the two.
"Relation" content type has two fields of type entityreference, "source" - pointing to the organization; and "target" - to the project.

The rule states: After saving new content of type "project"; create new entity of type "relation"; set data value for this entity's field "source" equal to [node:og-group-ref:0] and field "target" equal to [node].

This was working before the last og update. Now the field "source" is left empty.

For quick verification I created a dummy rule saying: After visiting content of type "project"; print a message on the site with token [node:og-group-ref:0:title].
This is working fine.

Maybe this can help?

I also have seen recent updates in rules module. I've tried this scenario with or without the last rules update.

miromarchi’s picture

Status: Closed (cannot reproduce) » Active

Reopen with a new scenario.

johnofjack’s picture

Sorry, I forgot to mention that I did create a group and make the "blog entry" content type group content.

The reason I'd reopened this with a followup was that this was working for us in OG 2.6 but after the update to 2.7 it was no longer working.

Does it matter that the fresh install I mentioned above was on Pantheon? (Is there some peculiarity of their implementation of the Panopoly distribution?)

miromarchi’s picture

Referring to #4, me too, I'm using Panopoly distribution.

jpcondon’s picture

I'm experiencing the same issue johnofjack is experiencing on a default drupal install. I was using OG 2.6 and I had URL aliases using the token [node:og-group-ref:0]. I upgraded to OG 2.7 and now I receive the same error stating it is an invalid token. I am presented with different options instead when I look at replacement patterns:

[node:og-group-ref] Field "og_group_ref".
[node:og-group-ref:1] The list item with delta 1. Delta values start from 0 and are incremented by one per list item.
[node:og-group-ref:2] The list item with delta 2. Delta values start from 0 and are incremented by one per list item.
[node:og-group-ref:3] The list item with delta 3. Delta values start from 0 and are incremented by one per list item.

None of these options and their respective tokens, for example [node:og-group-ref:1:title], work. When these options are used in the pattern it is ignored and removed from the alias on content creation/update. The default [node:og-group-ref] works fine, but since it appends each group to the alias it is important to have access to the delta values.

ultimike’s picture

I'm seeing this issue as well. The OG 7.x-2.7 update appears to have broken the [node:og-group-ref:1] tokens...

Then again, I upgraded Panopoly at the same time which brought Entity API from 7.x-1.3 to 7.x-1.5, so could this be an issue with Entity Token and not OG?

-mike

guillaumev’s picture

Same issue here... I've noticed however that if you use a single-valued groups audience field, the token works...

edvanleeuwen’s picture

This has only to do with OG. Reverting back to 2.6 solves this.

Please bear in mind that 2.7 is a security update, so if you are going back to 2.6 this will be reintroduced.

edvanleeuwen’s picture

Issue summary: View changes
edvanleeuwen’s picture

I did a fresh install with he following contributions:

  • Chaos tool 7.x-1.4
  • Entity Reference 7.x-1.1
  • File (Field) Paths 7.x-1.0-beta4
  • Organic groups 7.x-2.6
  • Organic groups access control 7.x-2.6
  • Organic groups context 7.x-2.6
  • Organic groups UI 7.x-2.6
  • Entity API 7.x-1.5
  • Entity tokens 7.x-1.5
  • Pathauto 7.x-1.2
  • Tokens 7.x-1.5
  • Views 7.x-3.8
  • Views Bulk Operations 7.x-3.2

Then I performed the following actions:

Shushu, if you need access to my test site, please let me know.

guillaumev’s picture

After some analysis it appears that the commit that caused this issue is this one: http://cgit.drupalcode.org/og/commit/og.module?id=d187c93aec30bc0b7629f9.... Reverting it solves this issue...

guillaumev’s picture

Here is a patch that fixes this temporarily, at least until both https://drupal.org/node/2220575 and this issue can be solved...

ultimike’s picture

Wouldn't another way to fix this be to keep the call to og_get_entity_groups(), but reset the $gids array once it is returned?

Patch attached.

Thanks,
-mike

paranojik’s picture

Title: Group reference token not working » "Group audience" field $delta values wrong upon saving group content
Version: 7.x-2.7 » 7.x-2.x-dev
Status: Active » Reviewed & tested by the community
Related issues: +#2220575: Avoid Entity's load() method when saving group reference values.
FileSize
562 bytes

Updating title as this is a much broader issue. Anything that is relying on the 0 delta value of the group audience field will fail. This only occurs upon saving the entity.

IMHO @ultimike's solution is OK (field delta values should follow the number of actual values - og_get_entity_groups() returns values keyed by group_membership ID).

I'm just proposing a shorter version of @ultimike's patch...

edvanleeuwen’s picture

Tested and verified #17. Please merge with dev.

shushu’s picture

Thanks all for the details and the work.
Patch seems to work as expected, and solves the problem.
@paranojik, when submitting a patch it is better to leave it in "needs review" so someone else will review it.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks.

  • Amitaibu committed 458945d on 7.x-2.x authored by ultimike
    Issue #2264759 by paranojik, ultimike, guillaumev | edvanleeuwen: Fixed...
miromarchi’s picture

Hi, thanks for the work. I've tested patch in #17 too, and I confirm it is solving the problem in my case. Thank you!

Status: Fixed » Closed (fixed)

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

brad.bulger’s picture

can anyone confirm, that, for instance, [node:og-group-ref:url:path] is wrong, and [node:og-group-ref:0:url:path] is correct? and that this is how it will continue to be? is it related at all to the cardinality of the og_group_ref field?

dureaghin’s picture

Issue still persist, patch in #17 doesn't work for me.

Yorgg’s picture

The issue remains the same even though #17 has been merged.