Linux: preflight OpenSSL 3 vs PHP <8.1, surface build errors, fix zsh did-you-mean (v1.13.1)#28
Merged
Merged
Conversation
paste -d takes a *list* of delimiters and cycles through it, so `paste -sd ', '` alternated comma and space: three stale patches printed as "8.3.1,8.3.2 8.3.5". Join on a comma and space it out afterwards. Windows was already correct - Show-OlderPatchHint uses -join ', '. devhardiyanto
Building PHP 7.3 on a modern distro fails ~10 minutes in with a wall of C errors, the useful one buried mid-log: RSA_SSLV23_PADDING undeclared. OpenSSL removed that constant in 3.0 and php-src only stopped using it in 8.1, so the outcome is knowable before a single file is compiled. Add _phpvm_check_openssl_compat, called right after the dependency check once the version is fully resolved. It reads the OpenSSL version from pkg-config (what ./configure consults) and falls back to the openssl CLI. It fails open: if neither probe answers the build still runs, and PHPVM_SKIP_OPENSSL_CHECK=1 overrides it outright - a guard that cannot be bypassed would strand anyone whose pkg-config resolves an OpenSSL 1.1 this probe can't see. Also surface the first hard error from the build log on any failure, preferring a configure error over later compiler noise. "See log" alone left the user paging through thousands of lines. Ref: php/php-src#9503 devhardiyanto
phpvm.sh is documented as bash/zsh and registers a chpwd hook for zsh users, but the bats suite runs under bash - so zsh has had zero coverage. Add a smoke script exercising the paths most likely to depend on bash semantics (array indexing in _phpvm_levenshtein, the unquoted $_PHPVM_COMMANDS split in _phpvm_unknown) plus the read-only commands, and wire it into CI. Expected to fail on this commit: proving the gap is the point. The fix follows. devhardiyanto
The zsh job added in the previous commit went red, as intended. It
found three separate bash assumptions, each hidden behind the one
before it, all on the `phpvm <typo>` path:
1. _phpvm_levenshtein assigned row[0]. zsh arrays are 1-based and
reject that outright - "assignment to invalid subscript range" -
so the function printed an error instead of a distance. Shift the
indices by one; bash just leaves index 0 unused.
2. `for c in $_PHPVM_COMMANDS` relied on word-splitting an unquoted
parameter, which zsh does not do. Every typo was answered with
"Did you mean 'install use list ls current ...'" - the entire
command list as a single suggestion. Make it a real array.
3. ${a:i-1:1} makes zsh parse ":i" as a history modifier. Spell the
offset out as $((i-1)). phpvm.sh:335 already documents this exact
trap for the spinner; the levenshtein loop had missed it.
Net effect: under zsh, every mistyped command printed an internal
error and a nonsense suggestion. bash behaviour is unchanged - 77/77
bats still green.
Also fixes two bugs in the smoke script itself: `print "-- x --"` ate
the leading dashes as options, and a status check was reading $? from
the preceding print rather than from the source.
devhardiyanto
devhardiyanto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Patch Linux/macOS: hentikan build PHP < 8.1 di host OpenSSL 3 sebelum compile, munculkan baris error yang relevan saat build gagal, dan perbaiki tiga ketidakcocokan zsh yang membuat
phpvm <typo>rusak total. Bump 1.13.0 → 1.13.1.Why
Dilaporkan dari pemakaian nyata:
phpvm install 7.3.33gagal setelah ~10 menit compile. Log 1801 baris, dan satu baris yang menjelaskannya terkubur di tengah:OpenSSL menghapus konstanta itu di 3.0, dan php-src baru berhenti memakainya di 8.1 — jadi semua PHP < 8.1 tak bisa dibuild di distro modern. Ini kondisi upstream, bukan bug phpvm. Yang jadi masalah: hasilnya sudah bisa dipastikan sebelum satu file pun dicompile, tapi phpvm tetap membiarkan user menunggu sepuluh menit lalu cuma bilang
See log.Temuan zsh datang dari audit terpisah di sesi yang sama, dipicu oleh kelas bug yang baru saja ditemukan di sisi Windows (asumsi tipe yang tak pernah tersentuh test).
How
Preflight OpenSSL.
_phpvm_check_openssl_compatdipanggil tepat setelah_phpvm_check_deps, saat versi sudah diresolusi penuh (jadiphpvm install 7.3→7.3.33dulu, baru dicek). Versi OpenSSL dibaca dari pkg-config — itu yang dikonsultasi./configure— dengan CLIopensslsebagai fallback.Dua keputusan desain yang sengaja:
PHPVM_SKIP_OPENSSL_CHECK=1. Ada setup di mana pkg-config meresolusi OpenSSL 1.1 yang tak terlihat oleh probe ini; guard mutlak akan mengunci mereka tanpa jalan keluar.Surface error. Saat build gagal apa pun sebabnya, ambil error pertama dari log —
configure: error:diutamakan di atas noise compiler yang menyusul. Diuji terhadap log 1801 baris dari laporan asli: ia menarik persis barisRSA_SSLV23_PADDING.zsh. Job CI
zshditambahkan lebih dulu dan sengaja dibiarkan merah, baru fix menyusul — supaya masalahnya terbukti, bukan diasumsikan. Job itu menemukan tiga hal, masing-masing tersembunyi di balik yang sebelumnya:_phpvm_levenshteinmenulisrow[0]. Array zsh 1-based dan menolaknya:assignment to invalid subscript range.for c in $_PHPVM_COMMANDSmengandalkan word-splitting parameter tanpa kutip — zsh tidak melakukannya. Tiap typo dijawabDid you mean 'install use list ls current uninstall ...', seluruh daftar command sebagai satu saran.${a:i-1:1}membuat zsh membaca:isebagai history modifier. Menariknyaphpvm.sh:335sudah mendokumentasikan jebakan yang sama persis untuk spinner — loop levenshtein terlewat.Efek gabungannya: di zsh, setiap command salah ketik memuntahkan error internal plus saran ngawur.
Changes
linux/phpvm.sh—_phpvm_openssl_version+_phpvm_check_openssl_compat(dekat_phpvm_check_deps), dipanggil dariphpvm_installlinux/phpvm.sh—_phpvm_show_build_error, dipanggil saat subshell build gagallinux/phpvm.sh—_phpvm_levenshteinindeks digeser ke basis 1 + offset substring dieksplisitkan;_PHPVM_COMMANDSjadi arraylinux/phpvm.sh— hint older-patch:paste -sd ', 'menyiklus delimiter (8.3.1,8.3.2 8.3.5); Windows sudah benar sejak awaltests/linux/build_preflight.bats(baru) — 12 test guard + surfacingtests/linux/commands.bats— 1 test format hint older-patchtests/linux/zsh-smoke.zsh(baru) + job CIzsh— jaring pengaman zsh pertama di repo iniREADME.md— cara jalankan zsh smoke + tiga jebakan zsh yang perlu diingatversion.txt+ 4 sumber versi → 1.13.1Paritas OS
Semua perubahan Linux-only by design: Windows pakai zip PHP prebuilt (tak ada build-from-source, jadi tak ada padanan OpenSSL/build-log), dan
paste/zsh tak punya counterpart di PowerShell. Bug hint older-patch versi Windows sendiri sudah diperbaiki di rilis sebelumnya.Testing Done
_phpvm_show_build_errordiuji terhadap build.log asli dari laporan (1801 baris) — menarik baris yang benarCatatan review
Commit
test(ci): add a zsh compatibility jobsengaja merah saat berdiri sendiri. Itu bukti gap-nya nyata; commit berikutnya yang menghijaukannya. Kalau mau memverifikasi ulang: checkout commit itu dan jalankanzsh tests/linux/zsh-smoke.zsh.Tidak diambil (sengaja)
--with-openssl=<prefix>) untuk PHP lama — openssl 1.1 sudah EOL dan tak ada di Ubuntu 24.04; deteksinya rumit dengan hasil yang makin jarang berguna. Bypass manual sudah cukup untuk yang benar-benar butuh.phpvm doctorbelum melaporkan kombinasi OpenSSL 3 + PHP lama. Kandidat wajar, tapi di luar scope patch ini.