function run($request)
 {
     increase_time_limit_to();
     $self = get_class($this);
     $verbose = isset($_GET['verbose']);
     if (isset($_GET['class']) && isset($_GET['id'])) {
         $item = DataObject::get($_GET['class'])->byID($_GET['id']);
         if (!$item || !$item->exists()) {
             die('not found: ' . $_GET['id']);
         }
         $item->rebuildVFI();
         echo "done";
         return;
     }
     if (isset($_GET['link'])) {
         $item = SiteTree::get_by_link($_GET['link']);
         if (!$item || !$item->exists()) {
             die('not found: ' . $_GET['link']);
         }
         $item->rebuildVFI();
         echo "done";
         return;
     }
     if (isset($_GET['start'])) {
         $this->runFrom($_GET['class'], $_GET['start'], $_GET['field']);
     } else {
         foreach (array('framework', 'sapphire') as $dirname) {
             $script = sprintf("%s%s{$dirname}%scli-script.php", BASE_PATH, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
             if (file_exists($script)) {
                 break;
             }
         }
         $classes = VirtualFieldIndex::get_classes_with_vfi();
         foreach ($classes as $class) {
             if (isset($_GET['class']) && $class != $_GET['class']) {
                 continue;
             }
             $singleton = singleton($class);
             $query = $singleton->get($class);
             $dtaQuery = $query->dataQuery();
             $sqlQuery = $dtaQuery->getFinalisedQuery();
             $singleton->extend('augmentSQL', $sqlQuery, $dtaQuery);
             $total = $query->count();
             $startFrom = isset($_GET['startfrom']) ? $_GET['startfrom'] : 0;
             $field = isset($_GET['field']) ? $_GET['field'] : '';
             echo "Class: {$class}, total: {$total}\n\n";
             for ($offset = $startFrom; $offset < $total; $offset += $this->stat('recordsPerRequest')) {
                 echo "{$offset}..";
                 $cmd = "php {$script} dev/tasks/{$self} class={$class} start={$offset} field={$field}";
                 if ($verbose) {
                     echo "\n  Running '{$cmd}'\n";
                 }
                 $res = $verbose ? passthru($cmd) : `{$cmd}`;
                 if ($verbose) {
                     echo "  " . preg_replace('/\\r\\n|\\n/', '$0  ', $res) . "\n";
                 }
             }
         }
     }
 }