sunrise.php for multi-network install of domain mapping plugin

Currently using the WP-mu-domain-mapping plugin on a multi-network installation. The domain mapping works fine with the provided sunrise.php file, however it breaks (sites no longer map correctly) when I move the plugin to our mu-plugins directory. I’ve tried the following, but it doesn’t work.

<?php
$sunrises = array(
"dm_sunrise" =>  dirname( __FILE__ ) .  "/mu-plugins/domain-mapping/inc/sunrise.php"
);

foreach( $sunrises as $sunrise ){
    if( is_readable( $sunrise ) ){
        include $sunrise;
    }
}

Solutions Collecting From Web of "sunrise.php for multi-network install of domain mapping plugin"

As per the instructions for setting up WordPress MU Domain Mapping, sunrise.php needs to be placed directly in your /wp-content directory. It’s not a plugin in the traditional sense, so can’t be placed in mu-plugins (or even plugins for that matter).

Setting up this plugin can take a bit of manual work so take care to follow the instructions carefully, including the modifications you need to make to wp-config.php.

By the way, the current status of this plugin is somewhat unclear as – for new sites – it appears its functionality is now baked in to WordPress core. It is (apparently) only now required for pre-existing Multisites which were converted some time ago. You can see various posts from the maintainer of the plugin in this support forum which confirm this.