The MU forums have moved to WordPress.org

Domain Mapping Plugin Updated (146 posts)

  1. donncha
    Key Master
    Posted 14 years ago #

    As I suspected, it's a chicken and egg problem. You login on the original url which redirects to the dashboard on the original url.
    That redirects to the dashboard on the domain mapped url where of course you're not logged in. So it redirects you to the login page on the original url where you are logged in and redirects to the dashboard there.
    Cycle continues. :(

  2. kgraeme
    Member
    Posted 14 years ago #

    I'm having a heck of a time recreating the bug. What I was seeing was that when logging in to the mapped domain, with the dashboard url being the mapped domain, it was logging me in as admin even though I was using a different account. Then when I tried to log out it would give the "you're trying to log out of this site" error like when there's a bad nonce key match and wouldn't let me log out.

    After closing things down and clearing the browsers I can't recreate that problem. But I have a couple new issues.

    1. The toggle isn't working again to change the admin blog url. It was working initially, but now it's stuck on the mapped domain. (Sorry, I know inconsistent behavior is the hardest to diagnose.)

    2. Should the vhost setting in wp-config matter?

    When set for define('VHOST', 'no'), things generally work (other than the admin blog toggle).

    When it's commented out, login works but logout takes me to url formatted like so: mainhost.com/?dm=4865a8ffad02787c242243e140f23394&action=logout&blogid=28&k=403&t=1887413996 and shows a white page. If I hit the browser back button, I get a wonderfully funky dashboard with the wp-login screen down in one of the widget locations.

  3. kgraeme
    Member
    Posted 14 years ago #

    Also, because of the admin blog now only being the mapped domain (if on a mapped domain blog, just to be clear), the remote login/out isn't working. Which I expected, but just wanted to make it clear.

  4. donncha
    Key Master
    Posted 14 years ago #

    Fixed the problem I described above - by redirecting to ?dm_gotoadmin=1 on the domain mapped blog.
    That url will redirect back to the main blog to login and return.
    Finally, if dm_gotoadmin is found and the user is logged in, they get sent to the dashboard :)

    Did I say "hoops"?

  5. donncha
    Key Master
    Posted 14 years ago #

    kgraeme - just tried with vhost on (I've been working with it off for the past few days) and login/logout seems ok here. Did you svn up?

  6. donncha
    Key Master
    Posted 14 years ago #

    kgraeme - did you update the logins table? Is the "id" field an INT or a VARCHAR? It should be a VARCHAR now.

  7. kgraeme
    Member
    Posted 14 years ago #

    The logins table is varchar. Just did an svn up and testing the latest.

  8. kgraeme
    Member
    Posted 14 years ago #

    I'm still seeing weird problems. Getting different results on two different wpmu installs.

    On one wpmu, logging in to the mapped domain only works if "Redirect admin pages to original blog domain" is checked. But then when trying to log out, I get put into a "you're trying to log out" loop. If I uncheck the redirect admin pages, when I try to log in on the domain it loops back to /?dm_gotoadmin=1 .

    With the other install, it only logs in to the mapped domain admin url regardless of setting and when I try to log out I gete the long URL string like I posted before and the blank page.

    Both of these were pre-existing installs, so I don't know if there's something else going on. I'm thinking next step on my end is to do a clean install of wpmu to test on. I've got some other things to take care of here for a bit though.

  9. kgraeme
    Member
    Posted 14 years ago #

    Quick followup. For the second install mentioned above, I deleted the plugins and cleaned out the tables, reinstalled and now the behavior is consistent with the first one. So at least they're consistent in how they're not working!

  10. DeannaS
    Member
    Posted 14 years ago #

    So, on to more debugging:

    With the setting "Redirect administration pages to original blog's domain" unchecked, we're seeing some funky behavior. I can log in just fine. Kevin, not so much. I threw some debugging code in there. When we hit the page
    http:mappedomain.com/?dm_gotoadmin=1
    I am sometimes getting nothing (not false or true) from the is_user_logged_in() function.

    I can't come up with any rhyme or reason for it. I threw this instead of the redirect_to_admin() function:

    function redirect_to_admin() {
    
    		if ( isset( $_GET[ 'dm_gotoadmin' ] ) && is_user_logged_in() ) {
    		wp_redirect( site_url( "wp-admin/" ) );
    	}
    
    	 {
    		echo("<p>This is where it fails</p>");
    		echo("<p>Is he logged in? " . is_user_logged_in() . "</p>");
    		echo(site_url("wp-admin/"));
    		die();
    	}
    
    }

    For me, if that debugging code is there, it consistently hits the else statement. However, if I attempt to log in - hit the page with the ?dm_gotoadmin=1, get the die else statement, then modify the code to take out the else statement and reupload it and refresh the same page (not having done anything else) I get through to the admin page.

    It seems like there's some sort of log in how long it takes to recognize that someone is logged in... Is that even possible?

  11. miklb
    Member
    Posted 14 years ago #

    the www. will be stripped out so the user will need a CNAME (for the www) as well as an A record (for the domain).

    Can you explain that a bit more? I need to create an A Record to the IP, and a CNAME to the original subdomain?

  12. donncha
    Key Master
    Posted 14 years ago #

    Yeah, because the www. will be stripped out by WPMU.

  13. donncha
    Key Master
    Posted 14 years ago #

    DeannaS - any differences in the cookies in your browsers? Are both users site admins or ordinary users?

  14. miklb
    Member
    Posted 14 years ago #

    I just grabbed the latest from trunk, and removed the mapped domain, and clicked "dashboard", I was redirected to example.com/wp-signup.php?new=removed_mapped_domain

    I'm assuming that's not expected behavior?

    Granted, I've not cleared any cookies, and have added/removed the mapped domain a couple of times for the test subdomain.

  15. miklb
    Member
    Posted 14 years ago #

    Just to be sure, I removed all cookies for the mapped domain, as well as the original, subdomain, and got the same behavior.

  16. kgraeme
    Member
    Posted 14 years ago #

    DeannaS - any differences in the cookies in your browsers? Are both users site admins or ordinary users?

    On that server, Deanna is using the default admin login and I'm using a "kgraeme" account that has been added to the site-admins list. (Previously I was just a blog admin on the mapped blog.)

    We cleared all cookies.

    With IE7, when I log in I get the http:mappedomain.com/?dm_gotoadmin=1 and then it goes to the dashboard.

    With FF(3.5.5) for me it gets hung up on the http:mappedomain.com/?dm_gotoadmin=1 and shows the blog homepage.

  17. donncha
    Key Master
    Posted 14 years ago #

    Thanks for all the testing! I just fixed a few possible problems - I had forgotten to exit after redirecting. That may fix the redirection problem you're seeing. I was somehow able to recreate it myself and it fixed it for me :)

    So, please svn up and fingers crossed!

  18. miklb
    Member
    Posted 14 years ago #

    I seem to be getting a blank admin when I swapped out the last version I had with r174759.

    No immediate errors, haven't had a chance to look at logs. I didn't have a terminal open for the site I was testing to properly check out the files, just saved the files directly from http://svn.wp-plugins.org/wordpress-mu-domain-mapping/trunk/ which I had previously done, so don't think that's the issue.

  19. kgraeme
    Member
    Posted 14 years ago #

    Easy thing first.

    http://kgraeme.wordpress.com/files/2009/11/domainmapping-redirectfunky.png

    Extra single quote tick. To fix change line 98 to:

    echo " /> Permanent redirect. (better for your blogger's pagerank)<br />";

    Edit: it was just rendering wrong in IE. Firefox was more foregiving of the malformed tag with the extra single quote.

  20. kgraeme
    Member
    Posted 14 years ago #

    Redirect administration pages to original blog's domain = checked.
    Mapped domain set as primary.

    • Logging in to mapped domain successfully takes me to hostdomain/blog/wp-admin.
    • Also logged in to rest of main host domain blogs. (As expected.)
    • Custom admin banner that displays on non-admin pages and calls is_user_logged_in() fails to show logged in state on mapped domain blog.
    • Custom admin banner correctly shows logged in state on main host url blogs.
    • Logging out from mapped blog's dashboard fails. Takes me to the failure notice screen "You are attempting to log out...Please try again." which takes me back to the dashboard.
    • Logging out from a main domain blog correctly logs out and subsequently logs me out of the mapped domain.

    Results are the same with both IE and Firefox.

    Redirect administration pages to original blog's domain = unchecked.
    Mapped domain set as primary.

    Firefox:

    • Logging in to mapped domain blog redirects me to mappeddomain/?dm_gotoadmin=1 and shows blog homepage instead of dashboard.
    • wp-admin on a main domain blog is a blank page

    IE

    • Login on either mapped or main domain is a blank page
  21. kgraeme
    Member
    Posted 14 years ago #

    The failure to log out feels a lot like a nonce key problem. On another project I had encountered a bug with wp_nonce_url() generating an incorrect nonce key which resulted in the same inability to log out. (Note that this was on a different wpmu install than any of these tests.)

    I see you're calling wp_nonce_field(). Is it possible there's a bug in the nonce functions?

  22. kgraeme
    Member
    Posted 14 years ago #

    @miklb

    If you're locked out of your dashboard now because of the white screen, go into the db. Table wp_sitemeta. Find "dm_redirect_admin" and change the value to 1. That will set the blogs to use the main blog domain for all admin.

  23. miklb
    Member
    Posted 14 years ago #

    thanks kgraeme, that's what I needed. I too am experiencing similar issues as that you've outlined.

  24. kgraeme
    Member
    Posted 14 years ago #

    Okay, I'm thinking there's definitely something odd going on with my Firefox (yeah, big surprise there). Now when I test with IE I can successfully log in/log out and our custom admin bar correctly shows logged in state on the mapped domain blog. Firefox still locked in the nonce-like logout loop preventing logout.

    This is with Redirect Admin checked.

    Want an awesome new bug? I can't add widgets to the mapped domain blog.

  25. kgraeme
    Member
    Posted 14 years ago #

    Another bug: Try to edit an existing post/page and it redirects to the Dashboard.

  26. donncha
    Key Master
    Posted 14 years ago #

    kgraeme - thanks, just fixed the extra quote problem.

  27. donncha
    Key Master
    Posted 14 years ago #

    kgraeme - editing a post worked for me. Are you using ldap or have you modified/overridden any of the functions in wp-includes/pluggable.php?

  28. kgraeme
    Member
    Posted 14 years ago #

    We have one with and one without ldap. The edit is redirecting to the dashboard on both. I disabled ldap auth on the one and it didn't change anything.

    I'd have to do some digging to see what else might hook into pluggable.php since that's Deanna's bailiwick but she's out today. I'll take a look though.

  29. miklb
    Member
    Posted 14 years ago #

    Editing the DB worked to get me back into admin, but I can't seem to use the plugin if I don't want to redirect to original blog.

    If I uncheck the option, it goes blank, even if I log out and clear cookies.

  30. miklb
    Member
    Posted 14 years ago #

    Another bug: Try to edit an existing post/page and it redirects to the Dashboard

    .

    I can recreate that bug as well, obviously with the option to redirect to original blog checked (see above).

About this Topic