Skip to content

web2project_autoload() includes without checking the file exists #468

Closed

Description

@caseysoftware

web2project_autoload() in classes/w2p/web2project.php (L11) does:

return include dirname(__FILE__) . "/$file.class.php";

It doesn't check that the file exists first. So any w2p_* name that has no matching file emits include(...): Failed to open stream and include(): Failed opening ... warnings before the real Class not found error. That covers a typo, a class an add-on module still expects (for example w2p_Output_PDFRenderer, which dev-6.0.0 removes), or a class_exists('w2p_...') probe. On installs with display_errors on, those warnings also leak the absolute install path.

An autoloader also shouldn't return a value. SPL ignores it, and include returns 1 on success.

Fix: build the path, return early when !is_file($path), and use require_once for files that do exist. This goes away entirely if the classes move to Composer PSR-4 autoloading (PSR-4 migration proposal, #470), but it's worth fixing on dev-5.0.0 now.

Activity

  1. added
    php
    on Oct 23, 2026
  2. added a commit that references this issue on Oct 24, 2026
    0c8ac5e
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

    php

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions