Skip to content

Include Visual C++ DLLs with Windows PHP builds and add packageVersion field to identify PHP packages#4042

Merged
fredrikekelund merged 5 commits into
trunkfrom
stu-1972-fix-missing-dlls-windows
Jul 2, 2026
Merged

Include Visual C++ DLLs with Windows PHP builds and add packageVersion field to identify PHP packages#4042
fredrikekelund merged 5 commits into
trunkfrom
stu-1972-fix-missing-dlls-windows

Conversation

@fredrikekelund

@fredrikekelund fredrikekelund commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Codex drove the implementation based on previous diagnosis.

Proposed Changes

Sentry shows that some users are running into PHP command failed (code: 3221225781) errors. This is because of missing DLLs on their system – very likely the Visual C++ Redistributable ones, as PHP explicitly names that dependency. This PR updates the native PHP build workflow to include the necessary DLLs next to php.exe.

Because there aren't new PHP patch versions available yet for every minor PHP version we offer, I also had to find a way to rebuild PHP versions that already exist on appscdn. This cannot be done today without breaking local Studio installations, because they expect the appscdn package to have a predefined checksum. If the checksum of the appscdn package changes, the Studio client will refuse to install it.

The solution is to add a packageVersion field that identifies the package version separately from the PHP version. The workflow sets this to studio-1 by default – meaning a typical workflow run (that builds a new PHP version) can just use the default. Moreover, I've set error_on_duplicate to always be true (same as in #4026, which I mistakenly merged to another branch than trunk)

Testing Instructions

I'll manually verify that these builds do what we want on Windows.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from bcotrim July 2, 2026 07:57
@fredrikekelund fredrikekelund self-assigned this Jul 2, 2026
@fredrikekelund fredrikekelund requested a review from a team as a code owner July 2, 2026 07:57
@fredrikekelund fredrikekelund changed the title Include Visual C++ DLLs with Windows PHP builds Include Visual C++ DLLs with Windows PHP builds and add packageVersion field to identify PHP packages Jul 2, 2026
@wpmobilebot

wpmobilebot commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing f7398ec vs trunk

app-size

Metric trunk f7398ec Diff Change
App Size (Mac) 1316.83 MB 1316.83 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk f7398ec Diff Change
load 1083 ms 749 ms 334 ms 🟢 -30.8%

site-startup

Metric trunk f7398ec Diff Change
siteCreation 6499 ms 6521 ms +22 ms ⚪ 0.0%
siteStartup 1863 ms 1872 ms +9 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Comment on lines +483 to +510
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vsInstallPath = & $vswhere -latest -version '[17.0,18.0)' -products * -property installationPath
if ( -not $vsInstallPath ) {
throw 'Could not locate Visual Studio to package the Visual C++ runtime'
}

$vcRedistRoot = Join-Path $vsInstallPath 'VC\Redist\MSVC'
$vcRuntimeDir = Get-ChildItem -Path $vcRedistRoot -Directory |
ForEach-Object { Join-Path $_.FullName 'x64\Microsoft.VC143.CRT' } |
Where-Object { Test-Path (Join-Path $_ 'vcruntime140.dll') } |
Sort-Object {
[version]( (Get-Item (Join-Path $_ 'vcruntime140.dll')).VersionInfo.FileVersion )
} -Descending |
Select-Object -First 1
if ( -not $vcRuntimeDir ) {
throw "Could not locate the x64 app-local Visual C++ runtime under $vcRedistRoot"
}

$requiredVcRuntimeDlls = @('vcruntime140.dll', 'vcruntime140_1.dll')
foreach ( $dll in $requiredVcRuntimeDlls ) {
if ( -not (Test-Path (Join-Path $vcRuntimeDir $dll)) ) {
throw "Required Visual C++ runtime DLL not found: $dll"
}
}

Copy-Item -Path (Join-Path $vcRuntimeDir '*.dll') -Destination $stagingDir
$vcRuntimeVersion = (Get-Item (Join-Path $vcRuntimeDir 'vcruntime140.dll')).VersionInfo.FileVersion
Set-Content -Path (Join-Path $stagingDir 'vc-runtime.version') -Value $vcRuntimeVersion -NoNewline

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying the DLLs from the CI Windows system was the method recommended by Codex for putting them next to the php.exe. AFAICT, Microsoft only offers an installation wizard for the Visual C++ Redistributables – not static DLLs that we can download and put where we want them.

@fredrikekelund

Copy link
Copy Markdown
Contributor Author

Confirmed that #4045 fixes the issue on a Windows VM that has no system-wide Visual C++ Redistributable DLLs 👍

@bcotrim bcotrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and fix LGTM 👍
The true test will happen when we distribute the new build, let me know if you want an extra validation then.

Suggestion:

  • Let's add a migration to remove superseded PHP package dirs (older patch/package revisions of each minor, and minors we no longer support). Keeping them in ~/.studio/php-bin/ just takes space for no purpose. It's ok to tackle as a follow-up.

@fredrikekelund

Copy link
Copy Markdown
Contributor Author

add a migration to remove superseded PHP package dirs

Agreed that this is a good idea, although I'd prefer to do it in a follow-up. Not critical yet, either, as this is only the second version of each PHP package that we ship to users.

@fredrikekelund fredrikekelund merged commit e03d037 into trunk Jul 2, 2026
12 checks passed
@fredrikekelund fredrikekelund deleted the stu-1972-fix-missing-dlls-windows branch July 2, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants