Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F488241
PhabricatorCacheEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorCacheEngine.php
View Options
<?php
final
class
PhabricatorCacheEngine
extends
Phobject
{
public
function
getViewer
()
{
return
PhabricatorUser
::
getOmnipotentUser
();
}
public
function
updateObject
(
$object
)
{
$objects
=
array
(
$object
->
getPHID
()
=>
$object
,
);
$new_objects
=
$objects
;
while
(
true
)
{
$discovered_objects
=
array
();
$load
=
array
();
$extensions
=
PhabricatorCacheEngineExtension
::
getAllExtensions
();
foreach
(
$extensions
as
$key
=>
$extension
)
{
$discoveries
=
$extension
->
discoverLinkedObjects
(
$this
,
$new_objects
);
if
(!
is_array
(
$discoveries
))
{
throw
new
Exception
(
pht
(
'Cache engine extension "%s" did not return a list of linked '
.
'objects.'
,
get_class
(
$extension
)));
}
foreach
(
$discoveries
as
$discovery
)
{
if
(
$discovery
===
null
)
{
// This is allowed because it makes writing extensions a lot
// easier if they don't have to check that related PHIDs are
// actually set to something.
continue
;
}
$is_phid
=
is_string
(
$discovery
);
if
(
$is_phid
)
{
$phid
=
$discovery
;
}
else
{
$phid
=
$discovery
->
getPHID
();
if
(!
$phid
)
{
throw
new
Exception
(
pht
(
'Cache engine extension "%s" returned object (of class '
.
'"%s") with no PHID.'
,
get_class
(
$extension
),
get_class
(
$discovery
)));
}
}
if
(
isset
(
$objects
[
$phid
]))
{
continue
;
}
if
(
$is_phid
)
{
$load
[
$phid
]
=
$phid
;
}
else
{
$objects
[
$phid
]
=
$discovery
;
$discovered_objects
[
$phid
]
=
$discovery
;
// If another extension only knew about the PHID of this object,
// we don't need to load it any more.
unset
(
$load
[
$phid
]);
}
}
}
if
(
$load
)
{
$load_objects
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
$load
)
->
execute
();
foreach
(
$load_objects
as
$phid
=>
$loaded_object
)
{
$objects
[
$phid
]
=
$loaded_object
;
$discovered_objects
[
$phid
]
=
$loaded_object
;
}
}
// If we didn't find anything new to update, we're all set.
if
(!
$discovered_objects
)
{
break
;
}
$new_objects
=
$discovered_objects
;
}
foreach
(
$extensions
as
$extension
)
{
$extension
->
deleteCaches
(
$this
,
$objects
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, May 7, 7:04 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
74952
Default Alt Text
PhabricatorCacheEngine.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment