Skip to content

tests: pre-installed zvec PHP extension (v0.4.10) shadows FFI classes — suite must run with -n #188

Description

@s2x

Problem

On machines where the legacy zvec PHP extension (v0.4.10, php-ext/) is installed via php.ini, require src/ZVec.php returns early and FFI-only classes never load — e.g. Class "ZVecIndexParams" not found in tests/test_index_params.phpt.

Root cause

src/ZVec.php:9 bails out before loading any PHP classes when the legacy extension is present:

if (extension_loaded('zvec')) return;

The installed extension (v0.4.10) defines only the older classes (ZVec, ZVecSchema, ZVecDoc, ZVecVectorQuery, …) but not the newer FFI-only helper classes — ZVecIndexParams, ZVecGroupByVectorQuery, ZVecCollectionStats, ZVecFieldSchema. Because of the early return, the class_alias block at the bottom of src/ZVec.php (lines 2428–2442) never runs.

Verification

php -m | grep zvec                          # zvec (v0.4.10)
php -n -r 'var_dump(extension_loaded("zvec"), extension_loaded("ffi"));'
# bool(false) bool(true)                    # -n fixes it
php -r 'require "src/ZVec.php"; var_dump(class_exists("ZVecIndexParams"));'
# bool(false)

Pre-existing: introduced in commit c2f0c7f (#25), independent of the v0.6.0 migration (#171#177).

Workaround (current)

Run the suite with php run-tests.php -n tests/ (run-tests passes -n to child PHP processes — line 474), which disables the extension and loads the full FFI class set.

Suggested fixes

  1. Make the early return conditional on the extension actually providing the classes:
    if (extension_loaded('zvec') && class_exists('ZVecIndexParams')) return;
  2. Document the -n requirement in AGENTS.md (Testing Requirements section) so contributors on machines with the old extension don't hit this
  3. Long term: ensure the php-ext/ extension build keeps parity with FFI classes or remove it from the test path

Activity

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

    priority:mediumMedium prioritytype:testTest coverage / test infrastructure issues

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions