Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F847840
D269.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
Sat, Apr 19, 6:55 PM
Size
1 KB
Mime Type
text/x-diff
Expires
Sun, Apr 20, 6:55 PM (11 m, 59 s)
Engine
blob
Format
Raw Data
Handle
602627
Attached To
D269: INP-1645 - Create categories during theme scan based on their location in SMS
D269.diff
View Options
Index: branches/5.2.x/core/units/categories/categories_event_handler.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_event_handler.php
+++ branches/5.2.x/core/units/categories/categories_event_handler.php
@@ -2443,6 +2443,7 @@
return;
}
+ $files = $this->sortByDependencies($files);
kUtil::setResourceLimit();
/** @var CategoriesItem $dummy */
@@ -2472,6 +2473,44 @@
}
/**
+ * 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'] : '';
+ $page_name = isset($meta['name']) ? $meta['name'] : '_Auto: ' . $template;
+ $files[$template]['sort_key'] = substr_count(($section ? $section . '||' : '') . $page_name, '||');
+ }
+
+ uasort($files, array($this, 'compareSMSTemplates'));
+
+ return $files;
+ }
+
+ /**
+ * Files array comparing.
+ *
+ * @param array $sms_template_a First item.
+ * @param array $sms_template_b Second item.
+ *
+ * @return integer
+ */
+ public function compareSMSTemplates(array $sms_template_a, array $sms_template_b)
+ {
+ if ( $sms_template_a['sort_key'] == $sms_template_b['sort_key'] ) {
+ return 0;
+ }
+
+ return $sms_template_a['sort_key'] < $sms_template_b['sort_key'] ? -1 : 1;
+ }
+
+ /**
* Processes OnMassMoveUp, OnMassMoveDown events
*
* @param kEvent $event
Event Timeline
Log In to Comment