If the patch at http://drupal.org/node/362493#comment-1365582 ever gets committed, subdomain will no longer be able to build the [subdomain] token for organic group posts.

This is due to the keys in $object->og_groups no longer starting from 0, thus breaking the following lines in subdomain.module:

if ($groupname = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $object->og_groups[0]))) {
  $values['subdomain'] = subdomain_build_token($groupname, $object->og_groups[0]);

I'm no expert but I believe $object->og_groups[0] could be replaced with reset($object->og_groups) to cover that potential problem without breaking current functionality. See attached patch.

Comments

rsvelko’s picture

After having read the php.net docs for "reset", I doubt that this would work. "reset" resets only the internal array pointer.

Instead we need to build a second object with normalized keys. There should be some func to do this... When the time comes somebody will give the newer patch ...

cheers

rsvelko’s picture

I've just found this http://drupal.org/node/483334 - see comment #1 - it has some php code that might be the desired php function...

morbiD’s picture

Sorry if I'm being stupid but I don't follow your comment amount reset(). The php.net docs state that it returns the value of the first element in the array, which is all $object->og_groups[0] was doing when it worked.

rsvelko’s picture

No - you are right - I missed the fact that reset RETURNS the value of the 1st element. I thought that it just rewinds the internal pointer...

One way or another your point makes sense. I suggest that it is not a good practice to do anything onto the $object if all we need to read sth from it. So please if this is important to anybody - find a way to take(=read) what we need from $objct without touching it. Maybe with the help of a dummy copy object or with the right php-statement or function..

Personally I think reset will work but it is not the best...

morbiD’s picture

Title: RTBC organic groups patch will break subdomain » subdomain can't build token for OG posts with latest og-6.x-2.x-dev
Version: 6.x-1.5 » 6.x-1.7
Status: Active » Needs review

Just an update - the Organic Groups patch which causes this issue has now been committed which kind of makes it fairly urgent. Anyone using og-6.x-2.x-dev to fix issues with the release version is going to find subdomain no longer works with it.

Changing status to "needs review" to get some attention. Using reset() was a quick fix so if anyone can improve on it, be my guest.

ZyanKLee’s picture

hi,

any chance getting this bug solved soon?
Sadly I can't help much - not a developer myself.

setvik’s picture

committed. Should be in tomorrow's dev release.

Thanks for the patch!

rsvelko’s picture

anybody test this? morbiD?

ZyanKLee’s picture

StatusFileSize
new52.01 KB
new29.55 KB

Sorry, can't confirm this working. But please have a look:

http://test2.laender-ohne-ruhe.de/v2/gruppe => "SubdomainGruppe" has been created after I installed the new dev version and configured it.

creating some screenshots of my configuration as attachments. (while creating the screenies I switched to english, but all else is in german, so the website will now be in german again)

Perhaps I did something wrong?

Versions are:

* Drupal			6.15
* MySQL			5.0.70
* PHP 			5.2.12-pl0-gentoo
* Organic groups	6.x-2.0
* OG forum		6.x-2.2
* Subdomain		6.x-1.x-dev
morbiD’s picture

@ZyanKLee: You should really be opening a new support request, since this thread is a bug report relating specifically to posts within a group. Anyway, from what I can see in your test site it looks like the tilde character (~) might be getting stripped from your subdomain token. Have you definately set the behaviour for the tilde character to "No action" under the "Punctuation Settings" in Pathauto, as the Subdomain readme describes?

@rsvelko: Personally, I've only tested it on my dev site, which is why I set the status to needs review. I guess setvik was happy enough with it as a quick fix ;)

Brian@brianpuccio.net’s picture

Just chiming in, I did test this out and it does fix the problem. Thanks!

progga’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

I am having this problem on 6.x-1.7 that I downloaded only yesterday! That means the stable version is broken :-( Using current() or reset(), as described above, fixes the problem though :-) And yes, I am using the stable version of OG (6.x-2.1).

3rdLOF’s picture

Version: 6.x-1.7 » 6.x-1.x-dev

So far I have not seen this module build the proper tokens in any of the following combinations:

OG 6.x-2.1 + Subdomain 6.x-1.7 = OG tokens ignored
OG 6.x-2.1 + Subdomain 6.x-1.x-dev = OG tokens ignored
OG 6.x-2.x-dev + Subdomain 6.x-1.x-dev = OG tokens ignored

Subdomain, wildcard, cookies, etc, etc set up right, all system checks in green in the Subdomain panel. Subdomain setting set to OG nodes, using name to generate token.

As for the "Automated Alias Settings" bit I am guessing this was changed in Pathauto to URL aliases >> Patterns >> Node Paths (which probably should be updated on the manual). In this section I add the toke [subdomain] by itself to the OG group node and content node types. No additional trailing dashes or spaces.

I create a Group Node, look at the Alias generated... and the subdomain completely ignored. It simply adds the name of the node as [title-raw] as a path of the domain (the default). Instead of http://subdomain.domain.com I get http://www.domain.com/subdomain where subdomain is the name of the group node with dashes (i.e the-group-name). When I edit the Alias I see the standard "http://www.domain/" + alias input field form - should this not look different?

I installed, reinstalled, checked permissions, flushed caches, edited, added nodes....no dice. I have not actually been able to make this module work once so I am only guessing this is all in connection with and related to this ticket as it appears to be the only thing not working. Unless somebody points to an error from my part...

morbiD’s picture

That sounds like exactly the same problem ZyanKLee had. Did you read my suggestion to him in #10 regarding "Punctuation settings"? I don't know if it was helpful since he never reported back, but it's worth checking.

Again though, your token is apparently generating something whereas this issue was to fix a potential bug where the token would not be generated at all. I'd suggest opening a new support request if my previous post doesn't help.

@progga: That stable release is from Dec 2009 while this patch was committed in Feb 2010 so the current dev release should work.

3rdLOF’s picture

Sorry. yes it did solve it. For some reason I thought the tilde issue was specific to his case.