/** Keep trying titles starting with $basename until one is unoccupied. */ public static function incrementedTitle($basename, $namespace) { global $wgContLang; $i = 2; // Try to make the title valid. $basename = Threads::makeTitleValid($basename); $t = Title::makeTitleSafe($namespace, $basename); while (!$t || in_array($t->getPrefixedDBkey(), self::$occupied_titles) || $t->exists() || $t->isDeletedQuick()) { if (!$t) { throw new Exception("Error in creating title for basename {$basename}"); } $n = $wgContLang->formatNum($i); $t = Title::makeTitleSafe($namespace, $basename . ' (' . $n . ')'); $i++; } return $t; }