• When set up as a subdomain install, Google Appengine does some funkiness with pseudo 2nd level subdomains because of SSL certs. Instead of adding a subdomain like subsite.mainsite.appspot.com you have to address it like subsite-dot-mainsite.appspot.com. The default wordpress COOKIE_DOMAIN in this case would be .mainsite.appspot.com. Since I am trying to access the non-mapped hostname, I get a cookie error. since my domain does not match the cookie domain.

    When I try to resolve this via define(‘COOKIE_DOMAIN’, ”), sunrise.php gives me an error about COOKIE_DOMAIN being defined. From what I can tell, this check is not needed unless you find a valid $domain_mapping_id.

    By moving the following condition

    if ( defined( 'COOKIE_DOMAIN' ) ) {
    	die( 'The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that define() line.' );
    }

    into the block where we find a $domain_mapping_id, this issue is resolved without affecting the plugin.

    This is the diff containing the bugfix for appengine multisite

    diff --git a/wp-content/sunrise.php b/wp-content/sunrise.php
    index a7593fe..f64addf 100644
    --- a/wp-content/sunrise.php
    +++ b/wp-content/sunrise.php
    @@ -2,10 +2,6 @@
     if ( !defined( 'SUNRISE_LOADED' ) )
            define( 'SUNRISE_LOADED', 1 );
    
    -if ( defined( 'COOKIE_DOMAIN' ) ) {
    -       die( 'The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that def
    -}
    -
     // let the site admin page catch the VHOST == 'no'
     $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
     $dm_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );
    @@ -19,6 +15,9 @@ $wpdb->suppress_errors();
     $domain_mapping_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->dmtable} WHERE {$where} ORDER BY CHAR_LENGTH(domain)
     $wpdb->suppress_errors( false );
     if( $domain_mapping_id ) {
    +    if ( defined( 'COOKIE_DOMAIN' ) ) {
    +        die( 'The constant "COOKIE_DOMAIN" is defined (probably in wp-config.php). Please remove or comment out that de
    +    }
            $current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$domain_mapping_id' LIMIT 1");
            $current_blog->domain = $_SERVER[ 'HTTP_HOST' ];
            $current_blog->path = '/';

    https://ww.wp.xz.cn/plugins/wordpress-mu-domain-mapping/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ron Rennick

    (@wpmuguru)

    The reason the check is global is so that a network administrator will see right away that they have a configuration issue.

    Thread Starter Josh Johnston

    (@tree2054)

    Could it be handled in a more graceful way by showing a banner notification in the admin instead of die()’ing? I’ll write the patch if you’ll consider it.

    Plugin Author Ron Rennick

    (@wpmuguru)

    While it could be handled in a more graceful way the reason we added it was the number of support threads we had to answer when there was just a warning in the dashboard.

    Plugin Author Ron Rennick

    (@wpmuguru)

    I forgot to mention that COOKIE_DOMAIN is always defined in the dashboard. You can’t log in without it being defined.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Bug in Appengine with COOKIE_DOMAIN’ is closed to new replies.