Issues with headers already sent and stdClass::$blog_id

Hi!

I cant access the admin panel with the mapped domain (mapped.lo instead of site1.demo.lo). The site1.demo.lo works in the backend though.

When I try to login (mapped.lo/login) the code below appears.

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-login.php on line 365

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-login.php on line 377

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-includes/pluggable.php on line 680

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-includes/pluggable.php on line 681

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-includes/pluggable.php on line 682

Notice: Undefined index: HTTPS in /*SITELOCATION*/files/apps/domain-mapping/domain-mapping.php on line 746

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-includes/pluggable.php on line 881

It works fine to access the frontend and it redirects to the mapped domain, but it shows the following notices:

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined index: HTTPS in /*SITELOCATION*/files/apps/domain-mapping/domain-mapping.php on line 746

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

And finally, when I try to access the admin section (mapped.lo/wp-admin/) it shows following:

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Notice: Undefined property: stdClass::$blog_id in /*SITELOCATION*/wp-includes/functions.php on line 3071

Warning: Cannot modify header information - headers already sent by (output started at /*SITELOCATION*/wp-includes/functions.php:3071) in /*SITELOCATION*/wp-includes/pluggable.php on line 881

Lot of code there, but I hope it will be helpfull!

Thanks for any help!

  • Kimberly

    Hi there!

    Sorry you are having trouble here.

    Have you tried to deactivate all plugins minus the Domain Mapping ot see if this is a conflict issue?

    Also, what are your settings on The domain used for the administration area should be the

    Do you have the highlighted area on your Domain Mapping plugin Menu? If so have you done all it asks?

    (I've not completely set mine up yet, just installed for testing, so please disregard if you have completed all of those instructions)

    Best,

    Kimberly

  • enkreativbyra

    Hi!

    Tried a fresh set of files and cleared all files and databases.

    Still the same problem. Have tried all settings for administration area, but no luck. And I want it to be the domain set up by the user to be used as administration.

    No highlighted areas what I can see, So I guess I've done all tasks, followed the installation guide.

    Any other ideas? Tried the original WP domain mapping and it did work better, but lacks some of the functionality that yours have. At the moment I'm looking into merging the two for a working solution.

    Thanks!

  • enkreativbyra

    So it seems like it's this snippet in wp-includes/functions.php

    /**
     * Is main site?
     *
     *
     * @since 3.0.0
     * @package WordPress
     *
     * @param int $blog_id optional blog id to test (default current blog)
     * @return bool True if not multisite or $blog_id is main site
     */
    function is_main_site( $blog_id = '' ) {
    	global $current_site, $current_blog;
    
    	if ( !is_multisite() )
    		return true;
    
    	if ( !$blog_id )
    		$blog_id = $current_blog->blog_id;
    
    	return $blog_id == $current_site->blog_id;
    }

    that creates all the errors.

    That and the following snippet in domain-mapping.php:

    $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';

    What can I do to fix these?

    Please help!

  • enkreativbyra

    Hi again,

    Sorry to post so many problems, but I need some pointers.

    The backend only shows errors if I use either mapped or user-entered domain - original is fine. Still shows a lot of notices about blog_id though.

    It seems the Domain Mapping makes some plugin stop working on the front end.

    Also, I can't use the WPML plugin in certain ways with the Domain Mapping. It does not work if I add /en/ as a different catalog. But it does work if I use the ?lang= en parameter.

    Anyone smart out there, please?

  • 3SixtyEvolve

    Hope you're well @enkreativbyra

    Just checking in on behalf of @KimberlyL to see if there is anything else that we can assist with. Did you get sorted or are there still issues outstanding that needs to be addressed?

    Since it's been a while that we last heard from you, I will go ahead and resolve this topic, but please don't hesitate to reopen it should you still require additional support from us. Just select the 'Mark as Not Resolved (re-open)' box below the post area (otherwise we might miss your new post).

    All the best!

    Gina

  • Fee

    Hello,
    it's a little bit old, but not resolved yet and I just had this problem, too.
    Here's the fix - please contact the plugin author, that he adds these lines into sunrise.php around line 50:

    if ( ! isset( $current_site->blog_id ) )
    	$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );

    By the way please tell the plugin author that he please replaces all URLs with 'wp-content/'... with the constant WP_CONTENT_URL in domain-mapping.php
    Thanks,
    Fee

  • Fee

    in Domain Mapping version 3.1.1 these errors are still present (in debugging mode of course). The code I mentioned removes them. Is there a reason why the plugin author didn't take a look at it?

    Sure I could ignore the errors, but there are bugs without debugging mode. Should I open new tickets for that?

    For example, subsites with mapped domains show this message in admin:
    "BuddyPress was successfully activated! Please run the installation wizard."
    It seems that the Buddypress network of the mainsite is not recognized. This problem is solved with my mentioned code, too.

    new errors in version 3.1.1 (additional and not solved with my code snippet):
    Notice: Trying to get property of non-object in .../plugins/domain-mapping/classes/class.domainmap.php on line 566
    Warning: Missing argument 2 for wpdb::prepare(), called in .../plugins/domain-mapping/classes/class.domainmap.php on line 857
    Warning: Missing argument 2 for wpdb::prepare(), called in .../plugins/domain-mapping/classes/class.domainmap.php on line 1040

  • Fee

    Hello Barry,
    I updated to your new version 3.1.2 with your fix and wanted to give you feedback that it's working good! Nearly all errors disappeared, all urls are working correctly, no BuddyPress notice anymore. :slight_smile:
    Only the error
    Warning: Missing argument 2 for wpdb::prepare(), called in .../plugins/domain-mapping/classes/class.domainmap.php on line 1040
    is still there. It disappears if I change line 1040 to:
    $olddomain = $this->db->get_var( $this->db->prepare( "SELECT option_value FROM %s WHERE option_name='siteurl' LIMIT 1 /* domain mapping */", $this->db->options ) );
    And the notice (in admin only)
    Notice: Trying to get property of non-object in .../plugins/domain-mapping/classes/class.domainmap.php on line 566
    disappears if I change line 566 to:
    $key = get_user_meta($user['ID'], 'cross_domain', true);
    Thanks for your plugin, it's really great work!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.