NogDog wrote:Please explain with concrete examples.
Basically what I was getting at is, magic_quotes_gpc fixup routines typically don't traverse the $GET $POST, $REQUEST $COOKIES etc arrays correctly, thus missing some elements, particularly if there are nested elements. Recall that you can do:
<input type="text" name="something[1][qwer][]">
And it will populate (e.g.) the next element of the array $_POST['something'][1]['qwer'].
The problem I have is testing: It is not feasible to rigorously test an application with every possible combination of ini settings that exists - even with a small subset, a test setup would be a maintenance nightmare, EVEN if the testing was 100% automated.
Testing typically takes far longer than coding on a reasonable sized project anyway, and introducing new bugs into a complex system is extremely easy.
I always try to minimise the amount of testing required, above most other requirements.
Not everyone has the luxury of controlling the environment under which their applications will be executed, or perhaps they are writing scripts they hope to distribute to any who want to use it (either open-source or licensed) that they'd like to work in as wide a range of environments as possible.
Because "as wide a range of environments as possible" is precisely one. Testing will kill your developers' time if you try to support even a very small number of different environments.
I consider this environmental control a necessity rather than a luxury. My development time is far more valuable than any expense notionally saved by deploying on to a substandard platform.
Why not make such an application robust enough to deal with the situation if it occurs?
Because that is additional code which needs to be maintained in a working state.
I do try to make things as robust as possible generally, but not at the expense of additional maintenance work.
It's not rocket science: you check to see if magic_quotes_gpc is turned on; and if it is, negate its effect, then proceed as though it was not turned on.
The algorithm is surprisingly nontrivial. Some implementations I've seen are wrong. Yours may be correct.
Should I stop trying to make my scripts as robust as possible and instead make them only work if the user's configuration is exactly the way I prefer it to be?
Obviously your requirements WILL be different from mine, you should use your judgement.
If it's a setting you can easily workaround, you may prefer to work-around it. Some settings (e.g. allow_url_fopen) can't be worked around by design. I consider, for instance, writing my own HTTP client is an unnecessary piece of code when I can simply use fopen (and of course, have my app "fail fast" if it's disabled).
Settings that can be changed at runtime can just be changed at runtime- which is nice and safe (provided you check that ini_set succeeded).
Mark