Skip to content

Stdlib: lower ldap_count_entries through JIT helper bridge (#32172) - #32209

Merged
PurHur merged 1 commit into
masterfrom
fix/32172-ldap-count-entries-jit
Aug 18, 2026
Merged

Stdlib: lower ldap_count_entries through JIT helper bridge (#32172)#32209
PurHur merged 1 commit into
masterfrom
fix/32172-ldap-count-entries-jit

Conversation

@PurHur

@PurHur PurHur commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • JIT/AOT no longer throw LogicException for ldap_count_entries(); lowering goes through JitLdapResult::invokeCountEntries + LdapResultJitHelper::countEntriesArgv and reuses VmLdapNative::countEntries (php-src ext/ldap/ldap.c).
  • LDAP\Result handles from JIT ldap_bind_ext() are registered the same way ldap_connect() registers connections, so compiled count/walk APIs can look up live results.
  • Invalid-handle TypeErrors for $ldap / $result match the VM path.

Closes #32172

php-src reference

PHP implementation

  • ext/ldap/ldap_search_builtins.phpcall()JitLdapResult::invokeCountEntries
  • ext/ldap/JitLdapResult.php / ext/ldap/LdapResultJitHelper.php — LLVM lowering + helper
  • ext/ldap/VmLdapResult.php — JIT result handle map
  • lib/JIT/Builtin/LdapRuntime.php__compiler_ldap_count_entries / __compiler_ldap_result_register
  • No new runtime/*.c

Test plan

  • Issue repro VM + JIT
  • AOT compile + run (phpc build; standalone has no libldap FFI so connect skips)
  • Targeted PHPUnit (LdapCountEntries*, LdapRuntimeShrinkTest)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_ENABLE_LDAP=1 php bin/vm.php test/repro/issue_32172_ldap_count_entries_jit.php'
fn=1
bad_conn=typeerror
bad_result=typeerror
bind_ext=false
ok

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_ENABLE_LDAP=1 php bin/jit.php test/repro/issue_32172_ldap_count_entries_jit.php'
fn=1
bad_conn=typeerror
bad_result=typeerror
bind_ext=false
ok

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_HELPER_RUNTIME_O=1 PHP_COMPILER_ENABLE_LDAP=1 ./phpc build -o /tmp/ldap_count_entries_32172 test/repro/issue_32172_ldap_count_entries_jit.php && /tmp/ldap_count_entries_32172'
fn=1
connect=0
ok

./script/phpunit.sh --filter 'LdapCountEntriesJitHelperTest|LdapRuntimeShrinkTest|LdapCompareJitHelperTest|LdapBindExtJitHelperTest'
OK, but incomplete, skipped, or risky tests!
Tests: 12, Assertions: 79, Skipped: 1.

Standalone AOT has no OpenLDAP FFI (ldap_connect() cannot create a session handle), so the AOT binary skips the live count path after compiling ldap_count_entries (no LogicException). VM/JIT exercise the TypeError path in-process.

JIT/AOT no longer throw LogicException for ldap_count_entries(); lowering
reuses VmLdapNative::countEntries via a Result handle map, matching php-src
ext/ldap/ldap.c.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit e3a3475 into master Aug 18, 2026
1 check failed
@PurHur
PurHur deleted the fix/32172-ldap-count-entries-jit branch August 18, 2026 13:19
PurHur added a commit that referenced this pull request Aug 18, 2026
…nclude (#32203) (#32212)

* Trust: sync bootstrap-inventory + spine after SoapParam/ldap/stream-include (#32203)

Construct-flag drift on soap units plus 7 vm.php-path files missing from compiler_lib_spine_smoke. Regenerated inventory/profile in Docker and appended the requires; no gen-0 sidecar restamp.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Trust: refresh inventory construct flags after ldap_count_entries (#32203)

Rebase onto #32209 grew JitLdapResult/LdapResultJitHelper/VmLdapResult method counts. Regenerated docs/bootstrap-inventory.md in Docker; spine coverage unchanged at 7588/7590.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Stdlib: ldap_count_entries() JIT path throws instead of matching php-src result count (ext/ldap/ldap.c)

1 participant