15
15
16
16
class m1_storage extends \phpbb \db \migration \container_aware_migration
17
17
{
18
+ private const BATCH_SIZE = 100 ;
19
+
18
20
/**
19
21
* {@inheritdoc}
20
22
*/
@@ -33,19 +35,19 @@ public function effectively_installed()
33
35
*/
34
36
public static function depends_on ()
35
37
{
36
- return array (
38
+ return [
37
39
'\phpbb\db\migration\data\v400\dev ' ,
38
40
'\phpbb\ads\migrations\v20x\m1_hide_ad_for_group ' ,
39
- ) ;
41
+ ] ;
40
42
}
41
43
42
44
public function update_data ()
43
45
{
44
- return array (
46
+ return [
45
47
['config.add ' , ['storage \\phpbb_ads \\provider ' , local::class]],
46
48
['config.add ' , ['storage \\phpbb_ads \\config \\path ' , 'images/phpbb_ads ' ]],
47
49
['custom ' , [[$ this , 'migrate_ads_storage ' ]]],
48
- ) ;
50
+ ] ;
49
51
}
50
52
51
53
public function migrate_ads_storage ()
@@ -67,14 +69,29 @@ public function migrate_ads_storage()
67
69
68
70
if ($ handle )
69
71
{
72
+ $ files = [];
70
73
while (($ file = readdir ($ handle )) !== false )
71
74
{
72
75
if ($ file === '. ' || $ file === '.. ' )
73
76
{
74
77
continue ;
75
78
}
76
79
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 );
78
95
}
79
96
80
97
closedir ($ handle );
0 commit comments