@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Implement saving queries.

Summary: Enable saved query objects to actually be saved to the database.

Test Plan: Insert a call to save() and check that the query is written correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D5775

Conflicts:

src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php

authored by

Bryan Cuccioli and committed by
epriestley
7ad2eae4 c7be6f4a

+28
+11
resources/sql/patches/20130426.search_savedquery.sql
··· 1 + CREATE TABLE {$NAMESPACE}_search.search_savedquery ( 2 + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, 3 + engineClassName VARCHAR(255) NOT NULL COLLATE utf8_bin, 4 + parameters LONGTEXT NOT NULL COLLATE utf8_bin, 5 + dateCreated INT(10) UNSIGNED NOT NULL, 6 + dateModified INT(10) UNSIGNED NOT NULL, 7 + queryKey VARCHAR(12) NOT NULL COLLATE utf8_bin, 8 + PRIMARY KEY(id), 9 + UNIQUE KEY key_queryKey (queryKey) 10 + ) 11 + ENGINE=InnoDB, COLLATE utf8_general_ci
+13
src/applications/search/storage/PhabricatorSavedQuery.php
··· 6 6 final class PhabricatorSavedQuery extends PhabricatorSearchDAO { 7 7 8 8 protected $parameters = array(); 9 + protected $queryKey = ""; 10 + protected $engineClassName = "PhabricatorPasteSearchEngine"; 9 11 10 12 public function getConfiguration() { 11 13 return array( ··· 21 23 22 24 public function getParameter($key, $default = null) { 23 25 return idx($this->parameters, $key, $default); 26 + } 27 + 28 + public function save() { 29 + if ($this->getEngineClass() === null) { 30 + throw new Exception(pht("Engine class is null.")); 31 + } 32 + 33 + $serial = $this->getEngineClass().serialize($this->parameters); 34 + $this->queryKey = PhabricatorHash::digestForIndex($serial); 35 + 36 + return parent::save(); 24 37 } 25 38 }
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1254 1254 'type' => 'sql', 1255 1255 'name' => $this->getPatchPath('20130423.conpherenceindices.sql'), 1256 1256 ), 1257 + '20130426.search_savedquery.sql' => array( 1258 + 'type' => 'sql', 1259 + 'name' => $this->getPatchPath('20130426.search_savedquery.sql'), 1260 + ), 1257 1261 ); 1258 1262 } 1259 1263 }