Skip to content

php-in-php: libxml error buffer — libxml_use_internal_errors/get_errors/clear_errors without host libxml (ext/libxml) #6058

Description

@PurHur

Category

php-in-php | stdlib

Problem

DOM/SimpleXML loaders (#3337, #3338) need libxml_use_internal_errors(), libxml_get_errors(), and libxml_clear_errors() to capture parse failures instead of emitting warnings. These are undefined on bin/vm.php today, forcing host libxml calls or silent parse failures during self-host.

php-src registers them in ext/libxml — not scattered C in runtime/.

php-src reference

Repro

./script/docker-exec.sh -- php bin/vm.php -r '
echo function_exists("libxml_use_internal_errors") ? "yes" : "no", PHP_EOL;
echo class_exists("LibXMLError") ? "yes" : "no", PHP_EOL;
'

Observed: both no

Zend PHP expected: both yes; invalid XML returns errors array when internal errors enabled.

Scope (this repo)

Done when

  • libxml_use_internal_errors(true) suppresses warnings; libxml_get_errors() returns LibXMLError[] for malformed XML load attempt
  • libxml_clear_errors() empties buffer
  • Self-host probe: class_exists('LibXMLError') true without Zend PHP in loop
  • test/compliance/cases/stdlib/libxml_internal_errors.phpt green on VM
  • ./script/docker-exec.sh -- vendor/bin/phpunit --filter LibxmlInternalErrors

Links

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

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions