Hi all,
Rasmus Schultz wrote:
What about libraries that need to support both PHP 7 and 8? Many libraries
will likely need to, potentially for a long time.
How will these libraries be able to detect whether the names have been
mangled or not? Libraries that "unmangle" run the risk of "unmangling"
names that aren't actually mangled, and could end up mangling them instead.
This is a particular concern with the proposed polyfill - if there's a
polyfill that mangles the names, you can't just use something like
php_version() to check if it's version 8, since the polyfill could have
been applied.
Maybe consider adding something like $_SERVER["REAL_HEADER_NAMES"] which,
if set, will indicate the names have not been mangled? The polyfill could
then unset() this value - it could even check first if the names are
already non-mangled, whether this is because it's running under PHP 8,
because the polyfill gets bootstrapped twice (which it'll probably need to
check somehow anyway) or because somebody else polyfilled the same change
in some other way.
Years ago I also wanted to remove the name mangling, but for
backwards-compatibility reasons I think we should make it as easy as
possible to migrate.
My preferred solution would be to add a new built-in function that
re-does the mangling exactly as it used to be done. It would be no great
maintenance burden on us to maintain such a function for the future,
but it would avoids userland having to reimplement it multiple times and
less performantly or perhaps with bugs.
Imagine:
array php_bc_mangle_request_vars(array $input);
Then an app relying on the legacy behaviour could do this in its
index.php and breathe easy:
$_GET = php_bc_mangle_request_vars($_GET);
$_POST = php_bc_mangle_request_vars($_POST);
// etc
Or for example, something using some form of Request object that didn't
do de-mangling could use this function on its $post array.
What does everyone think?
Andrea
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php