WP Hive » Troubleshooting and How-To

bug in continual loop

(2 posts)

Tags:


  1. billybob
    Member

    ok, so i have a few domains with similar domain names, and i wasted hours trying to figure out why i couldn't see the installation screen for a new domain, instead just seeing lots of timeouts.

    so, i traced it all through, and upon assigning a new prefix, we see this code to generate a new one:

    do-prefix.php

    while ($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM wphive_hosts WHERE prefix = %s", $prefix)) > 0) {
    $i = ($i == false) ? 0 : $i + 1;
    $prefix = substr($prefix, 0, 2) . $i . "_";
    }

    The problem is specifically here:
    $i = ($i == false) ? 0 : $i + 1;

    on the first run, i is set to 0, so on the second loop i is set to...0 again as false == 0.

    so, an additional = sign needs to be added to prevent the loop:
    $i = ($i === false) ? 0 : $i + 1;

    thanks

    Posted 2 years ago #
  2. ikailo
    Developer

    Thanks very much!

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.