From 14d9660823c596dbbcdd14f89d8350c833d46689 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 24 Apr 2024 03:05:05 +0530 Subject: [PATCH] Fix support for sqlsrv and pdo_sqlsrv --- src/scripts/extensions/add_extensions.ps1 | 4 +-- src/scripts/extensions/sqlsrv.ps1 | 31 ++++++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/scripts/extensions/add_extensions.ps1 b/src/scripts/extensions/add_extensions.ps1 index b473f080c..10321c566 100644 --- a/src/scripts/extensions/add_extensions.ps1 +++ b/src/scripts/extensions/add_extensions.ps1 @@ -66,7 +66,7 @@ Function Enable-Extension() { } # Function to add custom built PHP extension for nightly builds. -Function Add-NightlyExtension { +Function Add-ExtensionFromGithub { Param ( [Parameter(Position = 0, Mandatory = $true)] [ValidateNotNull()] @@ -123,7 +123,7 @@ Function Add-Extension { } else { if(($version -match $nightly_versions) -and (Select-String -Path $src\configs\windows_extensions -Pattern $extension -SimpleMatch -Quiet)) { - Add-NightlyExtension $extension + Add-ExtensionFromGithub $extension } else { # Patch till DLLs for PHP 8.1 and above are released as stable. $minimumStability = $stability diff --git a/src/scripts/extensions/sqlsrv.ps1 b/src/scripts/extensions/sqlsrv.ps1 index f158f5035..28f8f2aa0 100644 --- a/src/scripts/extensions/sqlsrv.ps1 +++ b/src/scripts/extensions/sqlsrv.ps1 @@ -29,7 +29,7 @@ Function Get-SqlsrvReleaseUrl() } # Function to add sqlsrv extension from GitHub. -Function Add-SqlsrvFromGithub() +Function Add-SqlsrvFromMSGithub() { Param ( [Parameter(Position = 0, Mandatory = $true)] @@ -37,16 +37,18 @@ Function Add-SqlsrvFromGithub() [string] $extension ) - $zipUrl = SqlsrvReleaseUrl - if($zipUrl) { - $nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" } - $noDotVersion = $version.replace('.', '') - $extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll" - Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1 - Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1 - Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll" - Enable-PhpExtension -Extension $extension -Path $php_dir - } + try { + $zipUrl = SqlsrvReleaseUrl + if($zipUrl) { + $nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" } + $noDotVersion = $version.replace('.', '') + $extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll" + Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1 + Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1 + Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll" + Enable-PhpExtension -Extension $extension -Path $php_dir + } + } catch { } } # Function to add sqlsrv extension. @@ -61,7 +63,12 @@ Function Add-Sqlsrv() { if (Test-Path $ext_dir\php_$extension.dll) { Enable-PhpExtension -Extension $extension -Path $php_dir } else { - Add-SqlsrvFromGithub $extension >$null 2>&1 + try { + Add-ExtensionFromGithub $extension > $null 2>&1 + } catch {} + if (-not(Test-Extension $extension)) { + Add-SqlsrvFromMSGithub $extension >$null 2>&1 + } if (-not(Test-Extension $extension)) { Add-Extension $extension >$null 2>&1 }