Skip to content

Stdlib: extension_loaded('ldap') reports true without Zend ext/ldap — phantom extension gate (ext/ldap/php_ldap.c) #17680

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

php-src registers ext/ldap symbols only when the ldap extension is actually loaded. On hosts without php-ldap, Zend reports extension_loaded('ldap') === false. This compiler unconditionally reports extension_loaded('ldap') === true while shipping PHP stubs under ext/ldap/, breaking extension-introspection parity and code that gates on extension_loaded before calling ldap APIs.

Repro Zend 8.2+ (no php-ldap) VM (2026-07-10)
extension_loaded('ldap') false true
function_exists('ldap_escape') when ext unloaded false true (host VM)

php-src reference

PHP implementation target

  • ext/ldap/ registration — tie extension_loaded('ldap') and function_exists('ldap_*') to the same gate Zend uses (extension table), not unconditional stub export
  • Avoid new C in runtime/; keep ldap semantics in PHP stubs behind the extension gate

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_ldap_extension_loaded_phantom.php'
# Also: php bin/vm.php test/repro/maintainer_gap_ldap_escape_phantom_function_exists.php

Done when

  • Both repro scripts print ok on VM/JIT/AOT on hosts without Zend ext/ldap
  • When ldap is intentionally enabled, ldap_escape() smoke still works
  • Compliance guard under test/compliance/cases/extensions/ldap_extension_loaded.phpt
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 10, 2026
  2. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #17676, #17693, #17680)

  3. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    Merged via #17703.

    Verification (VM):

    php bin/vm.php test/repro/maintainer_gap_define_object_constant.php  # #17676 → ok
    php bin/vm.php test/repro/maintainer_gap_ldap_extension_loaded_phantom.php  # #17680 → ok
    PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro-maintainer/issue_readonly_function.php  # #17693 → true + readonly semantics
    ./script/phpunit.sh --filter define_object_constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions