WordPress MU Domain Mapping
sunrise optimisation (2 posts)

  1. Maik Penz
    Posted 3 years ago #

    Your current sunrise.php does a filesort on each run. Using the ORDER BY is not even needed when the domain is no "^www.". It's nothing to big, but might decrease performance for some hosting options (and slow disks).

    preg_replace is unneeded too.

    Try something like:

    if( strpos($dm_domain, 'www.') === 0 ) {
        $where = $wpdb->prepare( 'domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC', $dm_domain, substr($dm_domain, 4) );
    } else {
        $where = $wpdb->prepare( 'domain = %s', $dm_domain );

    and skip the later "ORDER BY" clause. You could store char_length in $dmtable to ensure mysql uses fast mem sorting. (not that it matters as long as the disk operation is avoided).

    Something else: the closing php-tag '?>' is not needed for this file and might cause wordpress to break if trailed by any space (this is true for any pure script file and final closing tag).

    p.s. if you are reading this already you might want to enable WP_DEBUG for development and do something like array_key_exists() about those E_NOTICE and E_WARNING messages. Even your plugin activation script does not run clean. Yet another performance drawback (even when error_reporting is disabled) and a possible security issue as well.


  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 3 years ago #

    Thanks for the feedback.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress MU Domain Mapping
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic