From 72c642301ae1dd53d997b774ef826b44976d67f6 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 18 Sep 2026 12:01:55 +0530 Subject: [PATCH] Preserve active Windows extensions before probing cached DLLs --- src/scripts/extensions/add_extensions.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scripts/extensions/add_extensions.ps1 b/src/scripts/extensions/add_extensions.ps1 index 564516a5..b57d1611 100644 --- a/src/scripts/extensions/add_extensions.ps1 +++ b/src/scripts/extensions/add_extensions.ps1 @@ -111,7 +111,14 @@ Function Add-Extension { Set-PhpIniKey -Key display_startup_errors -Value Off -Path "$php_dir\php.ini" $deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch" New-Item $deps_dir -Type Directory -Force > $null 2>&1 + $extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension } if($extension_version -ne '' -and (Test-Path "$ext_dir\$extension-$extension_version")) { + # Preserve the active DLL before probing a cache entry for another PHP build. + if(Test-Path "$ext_dir\php_$extension.dll") { + $backup_name = if($extension_info.Version) { "$extension-$($extension_info.Version)" } else { "$extension.bak" } + Copy-Item "$ext_dir\php_$extension.dll" "$ext_dir\$backup_name" -Force -ErrorAction Stop + $extension_backup = "$ext_dir\$backup_name" + } Copy-Item "$ext_dir\$extension-$extension_version" "$ext_dir\php_$extension.dll" -Force try { Enable-ExtensionDependencies $extension @@ -127,8 +134,8 @@ Function Add-Extension { } # A cached DLL may target another PHP build; install it again if it did not load. Remove-Item "$ext_dir\php_$extension.dll" -Force + $extension_info = $null } - $extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension } if ($null -ne $extension_info -and ($extension_version -eq '' -or $extension_info.Version -eq $extension_version)) { switch ($extension_info.State) { 'Builtin' {