Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100786736
PhabricatorSearchDocumentQuery.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 18:20
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Feb 4, 18:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24034254
Attached To
rPH Phabricator
PhabricatorSearchDocumentQuery.php
View Options
<?php
final
class
PhabricatorSearchDocumentQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$savedQuery
;
private
$objectCapabilities
;
public
function
withSavedQuery
(
PhabricatorSavedQuery
$query
)
{
$this
->
savedQuery
=
$query
;
return
$this
;
}
public
function
requireObjectCapabilities
(
array
$capabilities
)
{
$this
->
objectCapabilities
=
$capabilities
;
return
$this
;
}
protected
function
getRequiredObjectCapabilities
()
{
if
(
$this
->
objectCapabilities
)
{
return
$this
->
objectCapabilities
;
}
return
$this
->
getRequiredCapabilities
();
}
protected
function
loadPage
()
{
$phids
=
$this
->
loadDocumentPHIDsWithoutPolicyChecks
();
$handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$this
->
getViewer
())
->
requireObjectCapabilities
(
$this
->
getRequiredObjectCapabilities
())
->
withPHIDs
(
$phids
)
->
execute
();
// Retain engine order.
$handles
=
array_select_keys
(
$handles
,
$phids
);
return
$handles
;
}
protected
function
willFilterPage
(
array
$handles
)
{
// NOTE: This is used by the object selector dialog to exclude the object
// you're looking at, so that, e.g., a task can't be set as a dependency
// of itself in the UI.
// TODO: Remove this after object selection moves to ApplicationSearch.
$exclude
=
array
();
if
(
$this
->
savedQuery
)
{
$exclude_phids
=
$this
->
savedQuery
->
getParameter
(
'excludePHIDs'
,
array
());
$exclude
=
array_fuse
(
$exclude_phids
);
}
foreach
(
$handles
as
$key
=>
$handle
)
{
if
(!
$handle
->
isComplete
())
{
unset
(
$handles
[
$key
]);
continue
;
}
if
(
$handle
->
getPolicyFiltered
())
{
unset
(
$handles
[
$key
]);
continue
;
}
if
(
isset
(
$exclude
[
$handle
->
getPHID
()]))
{
unset
(
$handles
[
$key
]);
continue
;
}
}
return
$handles
;
}
public
function
loadDocumentPHIDsWithoutPolicyChecks
()
{
$query
=
id
(
clone
(
$this
->
savedQuery
))
->
setParameter
(
'offset'
,
$this
->
getOffset
())
->
setParameter
(
'limit'
,
$this
->
getRawResultLimit
());
$engine
=
PhabricatorFulltextStorageEngine
::
loadEngine
();
return
$engine
->
executeSearch
(
$query
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorSearchApplication'
;
}
protected
function
getResultCursor
(
$result
)
{
throw
new
Exception
(
pht
(
'This query does not support cursor paging; it must be offset paged.'
));
}
protected
function
nextPage
(
array
$page
)
{
$this
->
setOffset
(
$this
->
getOffset
()
+
count
(
$page
));
return
$this
;
}
}
Event Timeline
Log In to Comment