Skip to content

Commit 7416b80

Browse files
authored
Fix dependency util suggest calculate bug (#441)
* fix dependency util suggest calculate bug * fix dependency util suggest calculate bug
1 parent bde1805 commit 7416b80

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/SPC/util/DependencyUtil.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ public static function getLibs(array $libs, bool $include_suggested_libs = false
6262

6363
if ($include_suggested_libs) {
6464
foreach ($dep_list as $name => $obj) {
65+
$del_list = [];
6566
foreach ($obj['suggests'] as $id => $suggest) {
6667
if (!str_starts_with($suggest, 'ext@')) {
6768
$dep_list[$name]['depends'][] = $suggest;
68-
array_splice($dep_list[$name]['suggests'], $id, 1);
69+
$del_list[] = $id;
6970
}
7071
}
72+
foreach ($del_list as $id) {
73+
unset($dep_list[$name]['suggests'][$id]);
74+
}
75+
$dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']);
7176
}
7277
}
7378

@@ -93,25 +98,35 @@ public static function getExtsAndLibs(array $exts, array $additional_libs = [],
9398
if ($include_suggested_exts) {
9499
// check every deps suggests contains ext@
95100
foreach ($dep_list as $name => $obj) {
101+
$del_list = [];
96102
foreach ($obj['suggests'] as $id => $suggest) {
97103
if (str_starts_with($suggest, 'ext@')) {
98104
$dep_list[$name]['depends'][] = $suggest;
99-
array_splice($dep_list[$name]['suggests'], $id, 1);
105+
$del_list[] = $id;
100106
}
101107
}
108+
foreach ($del_list as $id) {
109+
unset($dep_list[$name]['suggests'][$id]);
110+
}
111+
$dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']);
102112
}
103113
}
104114

105115
// include suggested libraries
106116
if ($include_suggested_libs) {
107117
// check every deps suggests
108118
foreach ($dep_list as $name => $obj) {
119+
$del_list = [];
109120
foreach ($obj['suggests'] as $id => $suggest) {
110121
if (!str_starts_with($suggest, 'ext@')) {
111122
$dep_list[$name]['depends'][] = $suggest;
112-
array_splice($dep_list[$name]['suggests'], $id, 1);
123+
$del_list[] = $id;
113124
}
114125
}
126+
foreach ($del_list as $id) {
127+
unset($dep_list[$name]['suggests'][$id]);
128+
}
129+
$dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']);
115130
}
116131
}
117132

0 commit comments

Comments
 (0)