Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046761
D269.id660.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 29, 3:57 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Mon, Jun 30, 3:57 AM (5 h, 8 m)
Engine
blob
Format
Raw Data
Handle
676749
Attached To
D269: INP-1645 - Create categories during theme scan based on their location in SMS
D269.id660.diff
View Options
Index: core/units/categories/categories_event_handler.php
===================================================================
--- core/units/categories/categories_event_handler.php
+++ core/units/categories/categories_event_handler.php
@@ -2359,6 +2359,7 @@
return;
}
+ $files = $this->sortByDependencies($files);
kUtil::setResourceLimit();
$dummy = $this->Application->recallObject($event->Prefix . '.rebuild', NULL, Array ('skip_autoload' => true));
@@ -2388,6 +2389,48 @@
}
/**
+ * Sort structure files array by dependencies.
+ *
+ * @param array $files Files.
+ *
+ * @return array
+ */
+ protected function sortByDependencies(array $files)
+ {
+ foreach ( $files as $template => $data ) {
+ $meta = unserialize($data['FileMetaInfo']);
+ $section = isset($meta['section']) && $meta['section'] ? array($meta['section']) : array();
+ $section[] = isset($meta['name']) ? $meta['name'] : '_Auto: ' . $template;
+ $files[$template]['sort_key'] = implode('||', $section);
+ }
+
+ uasort($files, array($this, 'sortCompare'));
+
+ return $files;
+ }
+
+ /**
+ * Files array comparing/
+ *
+ * @param array $a First item.
+ * @param array $b Second item.
+ *
+ * @return integer
+ */
+ public function sortCompare(array $a, array $b)
+ {
+ if ( $a['sort_key'] < $b['sort_key'] ) {
+ return -1;
+ }
+
+ if ( $a['sort_key'] > $b['sort_key'] ) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ /**
* Processes OnMassMoveUp, OnMassMoveDown events
*
* @param kEvent $event
Event Timeline
Log In to Comment