did a backtrace, and the code that is causing this issue is in domain_form_alter() on line 1812.

on admin/build/domain/settings I have
SEO: Do not rewrite URLs
Default source domain: Do not change domain

Diving into why this happens; working backwards.
Line 1811: $domain == -1 - This triggers the if statement
Line 1809: $domain = domain_lookup($first_domain);
Line 1780: $first_domain = current($user_domains); $first_domain = -1 at this point
Line 1775-1779:

foreach ($user->domain_user as $key => $value) {
  if (abs($value) > 0) {
    $user_domains[] = $value;
  }
} 

In domain_get_user_domains()

      if ($data->domain_id == 0) {
        $domains[$uid]['-1'] = -1;
      }

But in domain_lookup() there is no special case for -1. Working on a patch.

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new733 bytes
mikeytown2’s picture

StatusFileSize
new1.47 KB

diff in patch takes care of secondary issue where user is assigned to current domain; but is still redirected.

bleen’s picture

I'm having this identical issue (for one, and only one of my users WTF?) but this patch does not seem to fix the issue .. I havent had much time to do anything other than try the patch and note that it doesnt help

bleen’s picture

incidentally, shouldn't this be:

else if ($domain_id == 0 || $domain_id == -1) {
  $domain = domain_default();
}
mikeytown2’s picture

@bleen18
The user will get redirected to the domain default (did:0) if that user is not assigned to the current domain. If the user tries to create a node on a domain they are not assigned to, they will be redirected to one where they have the correct permissions to do so (domain_default()).

Yes, you could combine both if statements into one like you did.

What are the inputs & what is the desired outcome for your situation?

bleen’s picture

User ONLY belongs to domian ID 4 ... she goes to domain4.com/node/add, fills in form, hits save and gets redirectoed to domain0.com/title-of-new-content

If she goes back and edits domain4.com/title-of-new-content everything works fine

Its driving me nuts. This is the only one of my "bloggers" that has this issue.

EDIT:
Also, SEO rewrite = on

mikeytown2’s picture

my patch #2 only works with SEO = off. Looks like I need to redo the patch after reading the SEO configuration

Search engine optimization:
* Do not rewrite URLs
* Rewrite all URLs to point to a single source
If rewrite is turned on, all node links will point to a single instance of the node. This option reduces the chance that search engines will recognize duplicate content.

By "all node links", I think this means node/NUMBER not node/* thus the elseif (variable_get('domain_seo', 0) == 0) { check is not needed in the patch.

agentrickard’s picture

The issue that bleen18 is one of the oldest, most frustrating issues in the queue. Currently we even try to handle this redirect with session handling. See #624360: First time node save gets redirected to main domain

agentrickard’s picture

bleen’s picture

agentrickard - that issue seems to fit my symptoms, but only for one user?!

bleen’s picture

EDIT: removed incorrect info

More info: Ok, so it turns out this is not isolated to one blogger (only one blogger who is smart enough to report it). As of 5 days ago, my site had 5 domains (including the Main domain) ad we did not see this behavior. We added a 6th domain, and it was then (I suspect but cannot prove) that we began having the problem of redirecting to the main domain on node->save

Why would it have worked fine for all this time, and now stop?

... I should probably be moving these comments to the other issue, huh?

bleen’s picture

Turns out that #227947-50: After editing nodes user is redirected to the main domain did the trick for me ... agentrickard: thanks for pointing me in the right direction ... any response to #227947-61: After editing nodes user is redirected to the main domain would be welcome.

agentrickard’s picture

Status: Needs review » Needs work

Moving to needs work based on #7.

sukr_s’s picture

Version: 6.x-2.5 » 6.x-2.9

In my case, the user is always redirected to a first domain (can be any domain other than primary domain). debugging i found that in domain.module, domain_form_alter function redirects the user to the first domain irrespective of the current domain due to the line 1832 where current($user_domains) is used and this returns the first domain_id in the array.
the following changes which checks if the current domain is in user's domain list and then retains the current domain_id or it reassigns the first one fixes this problem i.e. change line 1832

$first_domain = current($user_domains);

to

if(in_array($_domain['domain_id'],$user_domains))
  $first_domain = $_domain['domain_id'];
else          
  $first_domain = current($user_domains);

can domain access expert comment if this fix is okay or has any side effects?

agentrickard’s picture

http://drupal.org/patch/create

Please patch against DRUPAL-6--2. Instructions are at http://drupal.org/project/domain/cvs-instructions.

And please format your code to conventions. http://drupal.org/coding-standards

sukr_s’s picture

StatusFileSize
new783 bytes

here is the patch for #14. can this be reviewed and applied?

agentrickard’s picture

Status: Needs work » Needs review
StatusFileSize
new1013 bytes

Properly formatted patch.

Reviewers?

R.Muilwijk’s picture

subscr

agentrickard’s picture

Thanks for nothing, @R.Muilwijk

Please _review the patch_.

mikeytown2’s picture

Version: 6.x-2.9 » 6.x-2.x-dev

patch #17 appears to fix this issue. Will RTBC after we thoroughly test this.

agentrickard’s picture

Hooray!

agentrickard’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
StatusFileSize
new812 bytes

Current patch for 6.x. Committed.

mikeytown2’s picture

Forgot to report back. Yes the patch works great! Thanks again!

agentrickard’s picture

Status: Needs review » Fixed
StatusFileSize
new782 bytes

Patch for both versions of 7. Committed.

Status: Fixed » Closed (fixed)

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