← 返回首页
ext/spl: spl_autoload() builds include filename from case-preserved class name by jorgsowa · Pull Request #22594 · php/php-src · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

ext/spl: spl_autoload() builds include filename from case-preserved class name#22594

Open
jorgsowa wants to merge 3 commits into
php:masterfrom
jorgsowa:fix/spl-autoload-case-preserved-filename
Open

ext/spl: spl_autoload() builds include filename from case-preserved class name#22594
jorgsowa wants to merge 3 commits into
php:masterfrom
jorgsowa:fix/spl-autoload-case-preserved-filename

Conversation

jorgsowa commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

The default spl_autoload() implementation lowercased the class name before appending the file extension, so a class like MyClass would only autoload from myclass.php, never MyClass.php. This is fine on case-insensitive filesystems (macOS, Windows) but breaks autoloading of any non-lowercase-named class on case-sensitive filesystems (Linux) unless the file on disk happens to be lowercase.

This change breaks backward compatibility of spl autoloading; I'm not sure where it should be fixed, master or PHP 8.4. Or maybe it should be deprecated first?

jorgsowa added 3 commits July 4, 2026 15:54
…lass name The default spl_autoload() implementation lowercased the class name before appending the file extension, so a class like MyClass would only autoload from myclass.php, never MyClass.php. This is fine on case-insensitive filesystems (macOS, Windows) but breaks autoloading of any non-lowercase-named class on case-sensitive filesystems (Linux) unless the file on disk happens to be lowercase. zend_hash_exists() against EG(class_table) still uses a lowercased copy of the name, since the class table itself remains keyed by lowercase name.
…g backslash zend_string_concat2() takes raw (char *, size_t) pairs, so the class name doesn't need to be materialized as its own zend_string just to skip a leading backslash before use. lc_name is now built directly via zend_string_alloc()+zend_str_tolower_copy() from the adjusted pointer/length instead.
…name EG(class_table) stores zend_class_entry* via the _ptr APIs, so the post-load check for whether the class got declared can look it up case-insensitively directly, without spl_autoload() having to build and hold a separate lowercased zend_string for the whole call.

TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

This is documented (and thus intentional) behavior.

Girgias commented Jul 6, 2026

Copy link
Copy Markdown
Member

As Tim said this is documented, so the only way I can see is to deprecate the function altogether.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Footer

© 2026 GitHub, Inc.