Skip to content

Commit ce7829f

Browse files
committed
support for php-src switching by downloading different php version (like it was before, essentially)
1 parent 51ef5e6 commit ce7829f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/SPC/command/BuildPHPCommand.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ public function handle(): int
134134
// Use version-specific php-src
135135
f_putenv("SPC_PHP_SRC_NAME={$version_specific_name}");
136136
logger()->info("Building with PHP {$php_version} (using {$version_specific_name})");
137-
} elseif (isset($lock_content['php-src'])) {
138-
// Fall back to regular php-src
139-
f_putenv('SPC_PHP_SRC_NAME=php-src');
140-
logger()->warning("php-src-{$php_version} not found, using default php-src");
141137
} else {
142138
logger()->error('No php-src found in downloads. Please run download command first.');
143139
return static::FAILURE;
@@ -147,7 +143,6 @@ public function handle(): int
147143
return static::FAILURE;
148144
}
149145
} else {
150-
// No version specified, use default php-src
151146
f_putenv('SPC_PHP_SRC_NAME=php-src');
152147
}
153148

src/SPC/command/DownloadCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ public function handle(): int
280280
logger()->warning("Pre-built content not found for {$source}, fallback to source download");
281281
}
282282
logger()->info("[{$ni}/{$cnt}] Downloading source {$source}");
283+
$force_download = $force_all || in_array($source, $force_list) || str_starts_with($source, 'php-src-') && in_array('php-src', $force_list);
283284
try {
284-
Downloader::downloadSource($source, $config, $force_all || in_array($source, $force_list));
285+
Downloader::downloadSource($source, $config, $force_download);
285286
} catch (SPCException $e) {
286287
// if `--no-alt` option is set, we will not download alternative sources
287288
if ($this->getOption('no-alt')) {
@@ -299,7 +300,7 @@ public function handle(): int
299300
logger()->notice("Trying to download alternative sources for {$source}");
300301
$alt_config = array_merge($config, $alt_sources);
301302
}
302-
Downloader::downloadSource($source, $alt_config, $force_all || in_array($source, $force_list));
303+
Downloader::downloadSource($source, $alt_config, $force_download);
303304
}
304305
}
305306
}

src/SPC/store/source/PhpSource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use JetBrains\PhpStorm\ArrayShape;
88
use SPC\exception\DownloaderException;
99
use SPC\store\Downloader;
10+
use SPC\store\LockFile;
1011

1112
class PhpSource extends CustomSourceBase
1213
{
@@ -28,6 +29,10 @@ public function fetch(bool $force = false, ?array $config = null, int $lock_as =
2829
} else {
2930
Downloader::downloadSource($source_name, $this->getLatestPHPInfo($major), $force);
3031
}
32+
33+
if ($source_name !== 'php-src') {
34+
LockFile::put('php-src', LockFile::get($source_name));
35+
}
3136
}
3237

3338
public function update(array $lock, ?array $config = null): ?array

0 commit comments

Comments
 (0)