Conversation
|
It still works if any filter is defined explicitly in the php.ini (also The slowdown comes from the fact that I imagine there will be some kind of optimization coming in PHP 9, since the ini directive is also apparently deprecated. |
|
Hmmm. I was going to look into that. |
|
Yeah the default filter is The slowdown is probably not worth it, and I'd recommend using |
|
Hmmm. So, if you don’t set a default right now, filter_input doesn’t do anything in FrankenPHP? It just returns an empty string? I’m not sure if that’s better or worse for libraries/frameworks that expect it to at least return unsafe-raw if the extension is available.
|
|
I think this is definitely the correct default for worker mode, since worker mode necessarily has to register That being said, I would be fine with enabling it in 'regular mode', if you think the performance hit is worth being more compatible with FPM defaults. As a sidenote: |
|
I have strong opinions about neutering built-in extensions just to eek out a little extra performance. If users want greater performance, they can build php with Otherwise, if the extension is available, we should behave just like any SAPI, even if it hurts performance (or make changes to php-src so that the performance impact is mitigated).
As mentioned earlier,
That bug was fixed ~15 years ago. However, many frameworks also inject things into $_ENV and $_SERVER, such as wdyt @dunglas? |
|
I agree with @withinboredom rationale. However it would be nice to fix that in php-src. |
|
I guess I disagree, at least for worker mode. I think the defaults for worker mode should be fast, performance is the whole point of its existence. Only the |
@AlliBalliBaba Can you give this branch+fork of php-src + this branch of FrankenPHP a go? (you should be able to apply the diff to any branch of PHP as well).
It shouldn't sacrifice correctness for performance. The whole point is to make it faster while still being correct. Otherwise, we could just delete half PHP to make it faster. (edit to add: though I actually think I agree with you -- I was mostly just arguing on principles. Worker mode is already quirky.) |
|
Looks like this branch would at least avoid 1 |
|
Hard to say from looking at the flamegraphs alone, but I think your branch makes this a bit more efficient. Last time I looked at it, it was actually copying the whole memory twice over, I think your branch only copies it once. Haven't tested it for correctness, but this probably also speeds up all other SAPIs. I still think it would be fine to break with FPM default behavior in worker mode. |
|
Should we merge this one? |
|
|
|
Let's see how that RFC shakes out then. I'm just getting back from a short vacation and have a bajillion emails to read through -- I hope it doesn't get removed, but rather it may be better to replace it with something else. |
|
Looks like none of the filter deprecations passed. |
|
given that they are not deprecated, we should probably merge this. @dunglas ? |
|
IMO we have the superior defaults. You can still enable the global filter, but you have to explicitly set it in the php.ini. filter.default=unsafe_raw # only unsafe_raw is not deprecatedEnabling global filters will create 2 additional deep-copies of each superglobal, which seems like it is too pricey for a feature that 99% of people don't use. If you really think it should be enabled by default, we should at least keep the current logic in worker mode, where very likely not a single soul is using |
|
Perhaps, instead of changing it in the code, we could change the default Caddyfile to include the php_ini setting then. The only thing important is to stay compatible with fpm applications by default. Would you be happy with that instead? |
| size_t new_val_len = val_len; | ||
| if (!should_filter_var || | ||
| sapi_module.input_filter(PARSE_SERVER, key, &val, new_val_len, | ||
| if (sapi_module.input_filter(PARSE_SERVER, key, &val, new_val_len, |
There was a problem hiding this comment.
Would also be fine with just keeping the current logic in worker mode:
| if (sapi_module.input_filter(PARSE_SERVER, key, &val, new_val_len, | |
| if ((is_worker_thread && !should_filter_var) || sapi_module.input_filter(PARSE_SERVER, key, &val, new_val_len, |




There was a small logic bug in
frankenphp.cwhere ifshould_filter_varistrue, it would never execute the next part of the if-statement, and thus never callsapi_module.input_filter(). This PR simply adjusts the logic to ensure ifshould_filter_varistrue, then callsapi_module.input_filter(), otherwise, only enter the body ifshould_filter_varisfalse.closes #1657