Repository navigation
[4.x] Resolve Input magic properties without the autoloader, case-insensitively, and add __isset() - #63
Open
Hackwar wants to merge 1 commit into
Open
[4.x] Resolve Input magic properties without the autoloader, case-insensitively, and add __isset()#63Hackwar wants to merge 1 commit into
Hackwar wants to merge 1 commit into
Conversation
__get() turned every property name into a class name and called class_exists() on it, so the first access to $input->get, ->post, ->server etc. queried the autoloader for Joomla\Input\Get and friends, and arbitrary names (including ones with backslashes) reached it as well. The cache was keyed by the name as written, so $input->get and $input->GET were two separate objects, and isset($input->get) returned false although the property works. The subclasses are now looked up in a fixed map, names are case-insensitive, and __isset() reports the available properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Input::__get()builds a class name from every property name (__NAMESPACE__ . '\' . ucfirst($name)) and callsclass_exists()on it before looking at the superglobals. As a result:$input->get,->post,->server,->envand->requestqueries the autoloader forJoomla\Input\Getetc., and any name — including one with backslashes,$input->{'Foo\Bar'}→Joomla\Input\Foo\Bar— reaches the autoloader;$input->getand$input->GETare two different objects, and$input->FILESis aFilesobject on case-insensitive file systems but a plainInputelsewhere;isset($input->get)returnsfalsealthough the property works, because there is no__isset().The subclasses (
files,cookie,json) are now looked up in a fixed map, the names are case-insensitive (the cache key is lowercased), and__isset()returns whether a property is available.One side effect:
$input->inputused to resolve toJoomla\Input\Inputby accident and returned a new$_REQUESTinput. It is not in the map, so it now throws like any other unknown property;$input->requestis the documented way to get that.Testing Instructions
New tests in
InputTest:test__getIsCaseInsensitive(),test__getDoesNotQueryTheAutoloader()(registers a spy autoloader) andtest__isset(). All fail before the change and pass after it.Documentation Changes Required
docs/overview.md("The sub-inputs"): the note thatisset()returnsfalseis replaced by the case-insensitivity andisset()behaviour.🤖 Generated with Claude Code