private function RegenerateFormat(ShortUrlFormat $format, $process_id)
 {
     # KNOWN ISSUE: Only uses GetShortUrlForType which for a match means tournaments are wrong
     require_once "data/process-manager.class.php";
     $this->process = new ProcessManager($process_id);
     if ($this->process->ReadyToDeleteAll()) {
         $this->GetDataConnection()->query('DELETE FROM nsa_short_url WHERE short_url_base IN (
                                                 SELECT ' . $format->GetShortUrlField() . '
                                                 FROM ' . $format->GetTable() . ')');
     }
     require_once 'http/short-url-manager.class.php';
     $short_url_manager = new ShortUrlManager($this->GetSettings(), $this->GetDataConnection());
     $short_url_manager->RegenerateCache();
     # Use format info to get existing short URL and querystring data for each item from the data tables.
     $short_url_manager->ReadAllByFormat($format, $this->process->GetQueryLimit());
     $a_short_urls = $short_url_manager->GetItems();
     # For each short URL runs Save() to re-save records in short url table. Doesn't
     # recalculate whether URLs clash, just takes what was in the data table.
     foreach ($a_short_urls as $o_short_url) {
         $short_url_manager->Save($o_short_url);
         $this->process->OneMoreDone();
     }
     unset($short_url_manager);
 }
 /**
  * When updating a short URL, if child items have short URLs beginning with the URL of the parent, update those too
  * @param ShortUrlFormat $child_item_format
  * @param string $old_prefix The old short URL for the parent
  * @param string $new_prefix The new short URL for the parent
  * @return void
  */
 public function ReplacePrefixForChildUrls(ShortUrlFormat $child_item_format, $old_prefix, $new_prefix)
 {
     $table = $child_item_format->GetTable();
     $field = $child_item_format->GetShortUrlField();
     $old_prefix = $this->SqlString($old_prefix . "/%");
     $new_prefix = $this->SqlString($new_prefix);
     $sql = "UPDATE {$table} SET\n                {$field} = CONCAT({$new_prefix}, RIGHT({$field},CHAR_LENGTH({$field})-LOCATE('/',{$field})+1))\n                WHERE {$field} LIKE {$old_prefix}";
     $this->LoggedQuery($sql);
     if ($this->GetDataConnection()->GetAffectedRows()) {
         $sql = " UPDATE nsa_short_url SET \n            short_url = CONCAT({$new_prefix}, RIGHT(short_url,CHAR_LENGTH(short_url)-LOCATE('/',short_url)+1)), \n            short_url_base = CONCAT({$new_prefix}, RIGHT(short_url_base,CHAR_LENGTH(short_url_base)-LOCATE('/',short_url_base)+1))\n            WHERE short_url_base LIKE {$old_prefix}";
         $this->LoggedQuery($sql);
     }
 }