Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14083350
D18506.id44441.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
D18506.id44441.diff
View Options
diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php
--- a/src/applications/project/query/PhabricatorProjectQuery.php
+++ b/src/applications/project/query/PhabricatorProjectQuery.php
@@ -609,7 +609,8 @@
}
if ($this->nameTokens !== null) {
- foreach ($this->nameTokens as $key => $token) {
+ $name_tokens = $this->getNameTokensForQuery($this->nameTokens);
+ foreach ($name_tokens as $key => $token) {
$token_table = 'token_'.$key;
$joins[] = qsprintf(
$conn,
@@ -797,4 +798,22 @@
}
}
+ private function getNameTokensForQuery(array $tokens) {
+ // When querying for projects by name, only actually search for the five
+ // longest tokens. MySQL can get grumpy with a large number of JOINs
+ // with LIKEs and queries for more than 5 tokens are essentially never
+ // legitimate searches for projects, but users copy/pasting nonsense.
+ // See also PHI47.
+
+ $length_map = array();
+ foreach ($tokens as $token) {
+ $length_map[$token] = strlen($token);
+ }
+ arsort($length_map);
+
+ $length_map = array_slice($length_map, 0, 5, true);
+
+ return array_keys($length_map);
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 3:58 AM (16 h, 29 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6778348
Default Alt Text
D18506.id44441.diff (1 KB)
Attached To
Mode
D18506: Limit the damage that degenerate project name typeahead queries can cause
Attached
Detach File
Event Timeline
Log In to Comment