1515
1616class m1_storage extends \phpbb \db \migration \container_aware_migration
1717{
18+ private const BATCH_SIZE = 100 ;
19+
1820 /**
1921 * {@inheritdoc}
2022 */
@@ -33,19 +35,19 @@ public function effectively_installed()
3335 */
3436 public static function depends_on ()
3537 {
36- return array (
38+ return [
3739 '\phpbb\db\migration\data\v400\dev ' ,
3840 '\phpbb\ads\migrations\v20x\m1_hide_ad_for_group ' ,
39- ) ;
41+ ] ;
4042 }
4143
4244 public function update_data ()
4345 {
44- return array (
46+ return [
4547 ['config.add ' , ['storage \\phpbb_ads \\provider ' , local::class]],
4648 ['config.add ' , ['storage \\phpbb_ads \\config \\path ' , 'images/phpbb_ads ' ]],
4749 ['custom ' , [[$ this , 'migrate_ads_storage ' ]]],
48- ) ;
50+ ] ;
4951 }
5052
5153 public function migrate_ads_storage ()
@@ -67,14 +69,29 @@ public function migrate_ads_storage()
6769
6870 if ($ handle )
6971 {
72+ $ files = [];
7073 while (($ file = readdir ($ handle )) !== false )
7174 {
7275 if ($ file === '. ' || $ file === '.. ' )
7376 {
7477 continue ;
7578 }
7679
77- $ file_tracker ->track_file ('phpbb_ads ' , $ file , filesize ($ dir . '/ ' . $ file ));
80+ $ files [] = [
81+ 'file_path ' => $ file ,
82+ 'filesize ' => filesize ($ dir . '/ ' . $ file ),
83+ ];
84+
85+ if (count ($ files ) >= self ::BATCH_SIZE )
86+ {
87+ $ file_tracker ->track_files ('phpbb_ads ' , $ files );
88+ $ files = [];
89+ }
90+ }
91+
92+ if (!empty ($ files ))
93+ {
94+ $ file_tracker ->track_files ('phpbb_ads ' , $ files );
7895 }
7996
8097 closedir ($ handle );
0 commit comments