Page MenuHomePhabricator

D8671.id20560.diff
No OneTemporary

D8671.id20560.diff

diff --git a/src/applications/phragment/storage/PhragmentFragment.php b/src/applications/phragment/storage/PhragmentFragment.php
--- a/src/applications/phragment/storage/PhragmentFragment.php
+++ b/src/applications/phragment/storage/PhragmentFragment.php
@@ -71,6 +71,39 @@
$view_policy,
$edit_policy) {
+ // Calculate all preceding paths.
+ $path_components = explode('/', $path);
+ array_pop($path_components);
+ $path_preceding = array();
+ $path_buffer = "";
+ for ($i = 0; $i < count($path_components); $i++) {
+ $path_buffer .= $path_components[$i].'/';
+ $path_preceding[] = rtrim($path_buffer, '/');
+ }
+
+ // Query for preceding fragments (use omnipotent user so
+ // we don't double up on paths because the user can't see
+ // them).
+ $preceding_fragments = id(new PhragmentFragmentQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPaths($path_preceding)
+ ->execute();
+ $preceding_fragments = mpull($preceding_fragments, null, 'getPath');
+
+ // Create preceding path fragments.
+ foreach ($path_preceding as $path_to_check) {
+ if (!array_key_exists($path_to_check, $preceding_fragments)) {
+ $fragment = id(new PhragmentFragment());
+ $fragment->setPath($path_to_check);
+ $fragment->setDepth(count(explode('/', $path_to_check)));
+ $fragment->setLatestVersionPHID(null);
+ $fragment->setViewPolicy($view_policy);
+ $fragment->setEditPolicy($edit_policy);
+ $fragment->save();
+ }
+ }
+
+ // Create the new fragment.
$fragment = id(new PhragmentFragment());
$fragment->setPath($path);
$fragment->setDepth(count(explode('/', $path)));

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 2:23 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7456719
Default Alt Text
D8671.id20560.diff (1 KB)

Event Timeline