2323use phpbb \titania \ext ;
2424use phpbb \titania \manage \tool \base ;
2525use Symfony \Component \Console \Helper \ProgressBar ;
26- use Symfony \Component \Finder \SplFileInfo ;
2726
2827class rebuild_repo extends base
2928{
@@ -57,6 +56,9 @@ class rebuild_repo extends base
5756 /** @var string */
5857 protected $ revisions_table ;
5958
59+ /** @var string */
60+ protected $ revisions_phpbb_table ;
61+
6062 /** @var int */
6163 protected $ total ;
6264
@@ -84,6 +86,7 @@ public function __construct(db_driver_interface $db, ext_config $ext_config, typ
8486 $ this ->attachments_table = $ table_prefix . 'attachments ' ;
8587 $ this ->contribs_table = $ table_prefix . 'contribs ' ;
8688 $ this ->revisions_table = $ table_prefix . 'revisions ' ;
89+ $ this ->revisions_phpbb_table = $ table_prefix . 'revisions_phpbb ' ;
8790 }
8891
8992 /**
@@ -140,11 +143,13 @@ protected function get_batch($fetch_attach_data)
140143 }
141144
142145 $ sql = 'SELECT c.contrib_id, c.contrib_name_clean, c.contrib_type, r.revision_id,
143- r.attachment_id, r.revision_composer_json ' . $ attach_fields . '
146+ r.attachment_id, r.revision_composer_json, rp.phpbb_version_branch ' . $ attach_fields . '
144147 FROM ' . $ this ->contribs_table . ' c, ' .
145- $ this ->revisions_table . ' r ' .
148+ $ this ->revisions_table . ' r, ' .
149+ $ this ->revisions_phpbb_table . ' rp ' .
146150 $ attach_table . '
147- WHERE c.contrib_id = r.contrib_id ' .
151+ WHERE c.contrib_id = r.contrib_id
152+ AND r.revision_id = rp.revision_id ' .
148153 $ attach_where . '
149154 AND c.contrib_status = ' . ext::TITANIA_CONTRIB_APPROVED . '
150155 AND r.revision_status = ' . ext::TITANIA_REVISION_APPROVED . '
@@ -192,6 +197,12 @@ public function run($from_file = false, $force = false, $progress = null)
192197
193198 $ last_type = $ last_contrib = '' ;
194199 $ packages = array ();
200+ $ filtered_packages = array ();
201+ $ branches = ext::get_filtered_repository_branches ();
202+ foreach ($ branches as $ branch )
203+ {
204+ $ filtered_packages [$ branch ] = array ();
205+ }
195206
196207 foreach ($ batch as $ contrib_id => $ revisions )
197208 {
@@ -246,6 +257,20 @@ public function run($from_file = false, $force = false, $progress = null)
246257 $ download_url ,
247258 $ contrib_url
248259 );
260+
261+ foreach ($ filtered_packages as $ branch => $ packages_data )
262+ {
263+ if ($ revision ['phpbb_version_branch ' ] >= $ branch )
264+ {
265+ $ filtered_packages [$ branch ] = $ this ->repo ->set_release (
266+ $ filtered_packages [$ branch ],
267+ $ revision ['revision_composer_json ' ],
268+ $ download_url ,
269+ $ contrib_url
270+ );
271+ }
272+ }
273+
249274 unset($ batch [$ contrib_id ][$ index ]);
250275 }
251276
@@ -257,6 +282,11 @@ public function run($from_file = false, $force = false, $progress = null)
257282 if (($ group_count % 50 ) === 0 )
258283 {
259284 $ this ->dump_include ($ last_type , $ group , $ packages );
285+ foreach ($ filtered_packages as $ branch => $ packages_data )
286+ {
287+ $ this ->dump_include ($ last_type , $ group , $ packages_data , $ branch );
288+ $ filtered_packages [$ branch ] = array ();
289+ }
260290 $ group_count = 0 ;
261291 $ group ++;
262292 $ packages = array ();
@@ -266,6 +296,10 @@ public function run($from_file = false, $force = false, $progress = null)
266296 if (!empty ($ packages ))
267297 {
268298 $ this ->dump_include ($ last_type , $ group , $ packages );
299+ foreach ($ filtered_packages as $ branch => $ packages_data )
300+ {
301+ $ this ->dump_include ($ last_type , $ group , $ packages_data , $ branch );
302+ }
269303 }
270304
271305 $ next_batch = $ this ->limit ? $ this ->start + $ this ->limit : $ this ->get_total ();
@@ -288,11 +322,13 @@ public function run($from_file = false, $force = false, $progress = null)
288322 * @param string $type Contrib type name
289323 * @param int $group Group id
290324 * @param array $packages Packages
325+ * @param int $branch Optional branch number for subdirectory
291326 */
292- protected function dump_include ($ type , $ group , array $ packages )
327+ protected function dump_include ($ type , $ group , array $ packages, $ branch = null )
293328 {
294329 $ type_name = $ this ->types ->get ($ type )->name ;
295- $ this ->repo ->dump_include ("packages- $ type_name- $ group.json " , $ packages );
330+ $ subdir = $ branch ? $ branch . '/ ' : '' ;
331+ $ this ->repo ->dump_include ("packages- $ type_name- $ group.json " , $ packages , $ subdir );
296332 }
297333
298334 /**
0 commit comments