/**
  * Run service.
  *
  * @param array $arguments Command line arguments.
  *
  * @return boolean success
  */
 public function run($arguments)
 {
     if (!isset($arguments[0]) || $arguments[0] != 'Y') {
         echo "Usage:\n  php index.php util update_search_hashes Y\n\n" . "  Update hashes of saved searches.\n";
         return false;
     }
     $searchWhere = ['checksum' => null, 'saved' => 1];
     $searchRows = $this->table->select($searchWhere);
     if (count($searchRows) > 0) {
         $count = 0;
         $orFilterCount = 0;
         foreach ($searchRows as $searchRow) {
             try {
                 $minified = $searchRow->getSearchObject();
                 if (!empty($minified->o)) {
                     // Fix orFilters while at it
                     if (!isset($minified->f)) {
                         $minified->f = [];
                     }
                     foreach ($minified->o as $field => $orFilters) {
                         foreach ($orFilters as $orFilter) {
                             $minified->f["~{$field}"][] = $orFilter;
                         }
                     }
                     unset($minified->o);
                     ++$orFilterCount;
                     $searchRow->search_object = serialize($minified);
                 }
                 $searchObj = $minified->deminify($this->manager);
                 $url = $searchObj->getUrlQuery()->getParams();
                 $checksum = crc32($url) & 0xfffffff;
                 $searchRow->checksum = $checksum;
                 $searchRow->save();
             } catch (\Exception $e) {
                 echo "Failed to process search {$searchRow->id}: " . $e->getMessage() . "\n";
                 print_r($searchRow->getSearchObject());
                 continue;
             }
             ++$count;
         }
         echo "Added checksum to {$count} rows and converted orFilters in" . " {$orFilterCount} rows in search table\n";
     } else {
         echo "No saved rows without hash found\n";
     }
     return true;
 }