Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15390362
D18464.id44367.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18464.id44367.diff
View Options
diff --git a/resources/sql/autopatches/20170824.search.01.saved.php b/resources/sql/autopatches/20170824.search.01.saved.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170824.search.01.saved.php
@@ -0,0 +1,46 @@
+<?php
+
+// Before T12956, normal users could reorder (and disable) builtin queries.
+// After that change, there is a single global order which can only be
+// changed by administrators.
+
+// This migration removes the rows which store individual reordering and
+// disabling of queries. If a user had reordered queries in such a way that
+// a builtin query was at the top of the list, we try to write a preference
+// which pins that query as their default to minimize disruption.
+
+$table = new PhabricatorNamedQuery();
+$conn = $table->establishConnection('w');
+
+$config_table = new PhabricatorNamedQueryConfig();
+
+foreach (new LiskMigrationIterator($table) as $named_query) {
+
+ // If this isn't a builtin query, it isn't changing. Leave it alone.
+ if (!$named_query->getIsBuiltin()) {
+ continue;
+ }
+
+ // If the user reordered things but left a builtin query at the top, pin
+ // the query before we remove the row.
+ if ($named_query->getSequence() == 1) {
+ queryfx(
+ $conn,
+ 'INSERT IGNORE INTO %T
+ (engineClassName, scopePHID, properties, dateCreated, dateModified)
+ VALUES
+ (%s, %s, %s, %d, %d)',
+ $config_table->getTableName(),
+ $named_query->getEngineClassName(),
+ $named_query->getUserPHID(),
+ phutil_json_encode(
+ array(
+ PhabricatorNamedQueryConfig::PROPERTY_PINNED =>
+ $named_query->getQueryKey(),
+ )),
+ PhabricatorTime::getNow(),
+ PhabricatorTime::getNow());
+ }
+
+ $named_query->delete();
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 6:09 AM (1 w, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706059
Default Alt Text
D18464.id44367.diff (1 KB)
Attached To
Mode
D18464: Remove rows for personal saved builtin queries
Attached
Detach File
Event Timeline
Log In to Comment