Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91685864
ConpherenceThreadIndexEngineExtension.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
Wed, Nov 13, 11:17
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Nov 15, 11:17 (2 d)
Engine
blob
Format
Raw Data
Handle
22305580
Attached To
rPH Phabricator
ConpherenceThreadIndexEngineExtension.php
View Options
<?php
final
class
ConpherenceThreadIndexEngineExtension
extends
PhabricatorIndexEngineExtension
{
const
EXTENSIONKEY
=
'conpherence.thread'
;
public
function
getExtensionName
()
{
return
pht
(
'Conpherence Threads'
);
}
public
function
shouldIndexObject
(
$object
)
{
return
(
$object
instanceof
ConpherenceThread
);
}
public
function
indexObject
(
PhabricatorIndexEngine
$engine
,
$object
)
{
$force
=
$this
->
shouldForceFullReindex
();
if
(!
$force
)
{
$xaction_phids
=
$this
->
getParameter
(
'transactionPHIDs'
);
if
(!
$xaction_phids
)
{
return
;
}
}
$query
=
id
(
new
ConpherenceTransactionQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withObjectPHIDs
(
array
(
$object
->
getPHID
()))
->
withTransactionTypes
(
array
(
PhabricatorTransactions
::
TYPE_COMMENT
))
->
needComments
(
true
);
if
(!
$force
)
{
$query
->
withPHIDs
(
$xaction_phids
);
}
$xactions
=
$query
->
execute
();
if
(!
$xactions
)
{
return
;
}
foreach
(
$xactions
as
$xaction
)
{
$this
->
indexComment
(
$object
,
$xaction
);
}
}
private
function
indexComment
(
ConpherenceThread
$thread
,
ConpherenceTransaction
$xaction
)
{
$previous
=
id
(
new
ConpherenceTransactionQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withObjectPHIDs
(
array
(
$thread
->
getPHID
()))
->
withTransactionTypes
(
array
(
PhabricatorTransactions
::
TYPE_COMMENT
))
->
setAfterID
(
$xaction
->
getID
())
->
setLimit
(
1
)
->
executeOne
();
$index
=
id
(
new
ConpherenceIndex
())
->
setThreadPHID
(
$thread
->
getPHID
())
->
setTransactionPHID
(
$xaction
->
getPHID
())
->
setPreviousTransactionPHID
(
$previous
?
$previous
->
getPHID
()
:
null
)
->
setCorpus
(
$xaction
->
getComment
()->
getContent
());
queryfx
(
$index
->
establishConnection
(
'w'
),
'INSERT INTO %T
(threadPHID, transactionPHID, previousTransactionPHID, corpus)
VALUES (%s, %s, %ns, %s)
ON DUPLICATE KEY UPDATE corpus = VALUES(corpus)'
,
$index
->
getTableName
(),
$index
->
getThreadPHID
(),
$index
->
getTransactionPHID
(),
$index
->
getPreviousTransactionPHID
(),
$index
->
getCorpus
());
}
}
Event Timeline
Log In to Comment