subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | SerdanKK | g1lei08 | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>Isn't this exactly what you'd expect in a dynamic language? Python does the same thing. Type hints are no substitute for a static language, they can't really participate in resolving.
Or are PHP type hints stronger than python ones?<|eor|><|soopr|>I don't have any experience with Python, but I'd expect they are similar enough.
My problem with this is that if PHP being dynamic means that it can't be implemented in a sensible way, then it shouldn't be implemented at all.
The current implementation leads to fragile code that'll be difficult to reason about, even with the use of static analysis.<|eoopr|><|sor|>> The current implementation leads to fragile code that'll be difficult to reason about, even with the use of static analysis.
Dynamic typing in a nutshell? :)<|eor|><|soopr|>Eh, kinda. In TypeScript you can put types on everything and the parser helps you make sure everything seems sensible. But you can lie to the parser and in the end everything gets transpiled to js and at runtime there's nary a type in sight. Despite that, ts remains a massive step up.<|eoopr|><|eoss|><|endoftext|> | 6 |
lolphp | SerdanKK | g1kfty3 | <|soss|><|sot|>Named parameters are cool, but PHP variables aren't typed so the implementation is completely broken.<|eot|><|sost|>[https://3v4l.org/P2XSm](https://3v4l.org/P2XSm)
Someone please tell me wth they're thinking. If this ships I'll have to put up another "don't use this feature" sign at work.
[C# equivalent](https://dotnetfiddle.net/1ptTml)
I've been strangely optimistic about PHP lately, so I suppose *something* had to come up.
​
EDIT: Someone on internals agrees: [https://externals.io/message/111161#111178](https://externals.io/message/111161#111178)
Andreas, you're my hero, despite your futile efforts.
EDIT2: I'm intrigued by the down-votes. I think the feature is *obviously* broken, so if you disagree what's your reasoning?<|eost|><|sor|>Random<|eor|><|soopr|>The concrete type is not known to the programmer. Do you actually understand the problem?<|eoopr|><|sor|>I was just making fun of the word choice because the `time()` function is being used.<|eor|><|soopr|>It's arguably nondeterministic in any practical sense, but fair enough.<|eoopr|><|eoss|><|endoftext|> | 6 |
lolphp | MazeChaZer | 4v0d24 | <|sols|><|sot|>Numbers from SimpleXML elements are implicitly casted to int, not float<|eot|><|sol|>https://3v4l.org/FcIV9<|eol|><|eols|><|endoftext|> | 35 |
lolphp | carlos_vini | d5ucnln | <|sols|><|sot|>Numbers from SimpleXML elements are implicitly casted to int, not float<|eot|><|sol|>https://3v4l.org/FcIV9<|eol|><|sor|>SimpleXmlElement is an object, there's no automatic toInt() in PHP, only toString(). https://3v4l.org/9cTbr. ~~even so i don't know why your snippet becomes a int~~
there was a bug report for this: https://bugs.php.net/bug.php?id=53033
there's no toInt() in PHP objects, but SimpleXml is a special case cause it's internal<|eor|><|eols|><|endoftext|> | 10 |
lolphp | emilvikstrom | d5vms1t | <|sols|><|sot|>Numbers from SimpleXML elements are implicitly casted to int, not float<|eot|><|sol|>https://3v4l.org/FcIV9<|eol|><|sor|>This is exactly the kind of behavior that makes SimpleXML not simple. Too many edge cases. I prefer parsing XML with a DOM parser as it was intended to be.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | BOOM_BOOM_BADABOOM | 3guasl | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|eols|><|endoftext|> | 33 |
lolphp | smog_alado | cu1jt53 | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>If I understood that correctly, I don't think it executes the code when saving the image. The uploaded image has a "php" extension and that causes PHP to execute it as a script when someone requests that URL (instead of serving it back as an image as it should).<|eor|><|eols|><|endoftext|> | 41 |
lolphp | Sheepshow | cu1zv17 | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>> When saving the image to disk, always force the file extension to be what it should be. That way the file will be served directly to the browser instead of being executed by PHP.
Security gold, right there<|eor|><|eols|><|endoftext|> | 25 |
lolphp | Schmittfried | cu1m46g | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|soopr|>> Exactly : PHP is secure out of the box, but if you let users upload anything to your server you're screwed no matter which language you use.
I'm pretty sure you can upload a virus that formats a HDD to my ASP.NET app and it will be fine.<|eoopr|><|sor|>Although I do agree that PHP is always good for a laugh, I don't see how this is PHP's fault when the developer clearly made disastrous mistakes (you might argue that such developers are the majority with PHP, but I would rather say they are the majority in general).
1. He accepts file uploads and leaves the file name as is. What. the. fuck. When one accepts user input (especially file input), one has to validate the shit out of it. That's an obligation that no language relieves you of. You always have to think about validation and be careful with user submitted input. There are frameworks that automate the common things, yes, but that doesn't mean you can slack off.
2. Instead of merely validating input, I force it to match my expectations whenever I can. I force the file extension to be correct (if possible, I actually generate the file name myself and either return it to the user or map external name <=> internal name in the DB).
3. This would not have been possible, if the upload directory had not been publicly accessible. With mod_rewrite and mod_xsendfile it's a trivial task to write a script that serves the files and keep the actual upload directory outside of the web root (or at least restrict it with .htaccess files, goddamn).
Granted, PHP does in fact have the (major or minor, decide for yourself) shortcoming of allowing every file to be a possible entry point. This attack would not have been possible, if PHP had only one entry point that delegates requests to the appropriate handlers, like every other sane language.
Then again, you can emulate that behavior with mod_rewrite and .htaccess files (or even better: just keep your code (apart from that one delegating entry point) far away from the publicly accessible directories and make those write-protected) which is what several PHP frameworks do.
Sorry, no lolphp for me. loldeveloper would fit it better.<|eor|><|eols|><|endoftext|> | 23 |
lolphp | BOOM_BOOM_BADABOOM | cu1i6mz | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|soopr|>> Exactly : PHP is secure out of the box, but if you let users upload anything to your server you're screwed no matter which language you use.
I'm pretty sure you can upload a virus that formats a HDD to my ASP.NET app and it will be fine.<|eoopr|><|eols|><|endoftext|> | 14 |
lolphp | fishburne | cu1i3go | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|eols|><|endoftext|> | 12 |
lolphp | user0x29a | cu1sq9u | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>so they let users upload "images" that end on .php? and store them in a folder that is configured by the webserver to execute php? while this is lol it isn't lolphp.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | browner87 | cu1ud02 | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>I feel there is an inherent idiocy on the part of OP and the users in that thread. "Here's a compromised website running unknown code a hack uploaded. Please visit it."<|eor|><|eols|><|endoftext|> | 9 |
lolphp | 00DEADBEEF | cu1ylc0 | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|soopr|>> Exactly : PHP is secure out of the box, but if you let users upload anything to your server you're screwed no matter which language you use.
I'm pretty sure you can upload a virus that formats a HDD to my ASP.NET app and it will be fine.<|eoopr|><|sor|>Although I do agree that PHP is always good for a laugh, I don't see how this is PHP's fault when the developer clearly made disastrous mistakes (you might argue that such developers are the majority with PHP, but I would rather say they are the majority in general).
1. He accepts file uploads and leaves the file name as is. What. the. fuck. When one accepts user input (especially file input), one has to validate the shit out of it. That's an obligation that no language relieves you of. You always have to think about validation and be careful with user submitted input. There are frameworks that automate the common things, yes, but that doesn't mean you can slack off.
2. Instead of merely validating input, I force it to match my expectations whenever I can. I force the file extension to be correct (if possible, I actually generate the file name myself and either return it to the user or map external name <=> internal name in the DB).
3. This would not have been possible, if the upload directory had not been publicly accessible. With mod_rewrite and mod_xsendfile it's a trivial task to write a script that serves the files and keep the actual upload directory outside of the web root (or at least restrict it with .htaccess files, goddamn).
Granted, PHP does in fact have the (major or minor, decide for yourself) shortcoming of allowing every file to be a possible entry point. This attack would not have been possible, if PHP had only one entry point that delegates requests to the appropriate handlers, like every other sane language.
Then again, you can emulate that behavior with mod_rewrite and .htaccess files (or even better: just keep your code (apart from that one delegating entry point) far away from the publicly accessible directories and make those write-protected) which is what several PHP frameworks do.
Sorry, no lolphp for me. loldeveloper would fit it better.<|eor|><|sor|>[deleted]<|eor|><|sor|>Yes, this is also the reason why every PHP developer doesn't realise what URN is.
Like it's literally the same thing as passing commands to CLI application.
Yet to their depraved minds, it's sort of a "hack" or "magic" infused by url rewrite or w/e. It's just like ftp for them - it should point to a real (.php) file in the end. WHAT???
So disgusting.<|eor|><|sor|>> every PHP developer doesn't realise what URN is.
It's a type of vase. Everybody knows that.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | BufferUnderpants | cu1p6jp | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|soopr|>> Exactly : PHP is secure out of the box, but if you let users upload anything to your server you're screwed no matter which language you use.
I'm pretty sure you can upload a virus that formats a HDD to my ASP.NET app and it will be fine.<|eoopr|><|sor|>Although I do agree that PHP is always good for a laugh, I don't see how this is PHP's fault when the developer clearly made disastrous mistakes (you might argue that such developers are the majority with PHP, but I would rather say they are the majority in general).
1. He accepts file uploads and leaves the file name as is. What. the. fuck. When one accepts user input (especially file input), one has to validate the shit out of it. That's an obligation that no language relieves you of. You always have to think about validation and be careful with user submitted input. There are frameworks that automate the common things, yes, but that doesn't mean you can slack off.
2. Instead of merely validating input, I force it to match my expectations whenever I can. I force the file extension to be correct (if possible, I actually generate the file name myself and either return it to the user or map external name <=> internal name in the DB).
3. This would not have been possible, if the upload directory had not been publicly accessible. With mod_rewrite and mod_xsendfile it's a trivial task to write a script that serves the files and keep the actual upload directory outside of the web root (or at least restrict it with .htaccess files, goddamn).
Granted, PHP does in fact have the (major or minor, decide for yourself) shortcoming of allowing every file to be a possible entry point. This attack would not have been possible, if PHP had only one entry point that delegates requests to the appropriate handlers, like every other sane language.
Then again, you can emulate that behavior with mod_rewrite and .htaccess files (or even better: just keep your code (apart from that one delegating entry point) far away from the publicly accessible directories and make those write-protected) which is what several PHP frameworks do.
Sorry, no lolphp for me. loldeveloper would fit it better.<|eor|><|sor|>> Granted, PHP does in fact have the (major or minor, decide for yourself) shortcoming of allowing every file to be a possible entry point.
Considering that you have to go out of your way to prevent user-uploaded files from being executed, by obfuscating and quarantining them, I would consider it pretty major. <|eor|><|eols|><|endoftext|> | 7 |
lolphp | hylje | cu42pmi | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>so they let users upload "images" that end on .php? and store them in a folder that is configured by the webserver to execute php? while this is lol it isn't lolphp.<|eor|><|sor|>How come it somehow doesn't work with .dll or .jar or whatever?<|eor|><|sor|>If the web server had a CGI style handler that loaded DLLs and executed them, yes, it would work.
That is, if the uploaded library is in the correct binary format for the server platform, e.g. a Linux binary (SO) for Linux, a Windows binary (DLL) for Windows.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Schmittfried | cu23hre | <|sols|><|sot|>Uploading image with PHP code in metadata executes that code when image is being saved.<|eot|><|sol|>https://www.reddit.com/r/PHP/comments/3gq3mh/my_site_was_hacked_php_injection_can_anybody/<|eol|><|sor|>[PHP security: PHP is secure out of the box](https://np.reddit.com/r/PHP/comments/3gt1hs/sticking_with_php_rather_than_switching/cu18jj0)
Some other comments, in that thread, particularly the ones by 'phpdevster' is amusing...<|eor|><|soopr|>> Exactly : PHP is secure out of the box, but if you let users upload anything to your server you're screwed no matter which language you use.
I'm pretty sure you can upload a virus that formats a HDD to my ASP.NET app and it will be fine.<|eoopr|><|sor|>Although I do agree that PHP is always good for a laugh, I don't see how this is PHP's fault when the developer clearly made disastrous mistakes (you might argue that such developers are the majority with PHP, but I would rather say they are the majority in general).
1. He accepts file uploads and leaves the file name as is. What. the. fuck. When one accepts user input (especially file input), one has to validate the shit out of it. That's an obligation that no language relieves you of. You always have to think about validation and be careful with user submitted input. There are frameworks that automate the common things, yes, but that doesn't mean you can slack off.
2. Instead of merely validating input, I force it to match my expectations whenever I can. I force the file extension to be correct (if possible, I actually generate the file name myself and either return it to the user or map external name <=> internal name in the DB).
3. This would not have been possible, if the upload directory had not been publicly accessible. With mod_rewrite and mod_xsendfile it's a trivial task to write a script that serves the files and keep the actual upload directory outside of the web root (or at least restrict it with .htaccess files, goddamn).
Granted, PHP does in fact have the (major or minor, decide for yourself) shortcoming of allowing every file to be a possible entry point. This attack would not have been possible, if PHP had only one entry point that delegates requests to the appropriate handlers, like every other sane language.
Then again, you can emulate that behavior with mod_rewrite and .htaccess files (or even better: just keep your code (apart from that one delegating entry point) far away from the publicly accessible directories and make those write-protected) which is what several PHP frameworks do.
Sorry, no lolphp for me. loldeveloper would fit it better.<|eor|><|sor|>[deleted]<|eor|><|sor|>Yes, this is also the reason why every PHP developer doesn't realise what URN is.
Like it's literally the same thing as passing commands to CLI application.
Yet to their depraved minds, it's sort of a "hack" or "magic" infused by url rewrite or w/e. It's just like ftp for them - it should point to a real (.php) file in the end. WHAT???
So disgusting.<|eor|><|sor|>Yeah, dude, literally every PHP developer sucks. Oh wait.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | msiemens | 34pnwk | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|eols|><|endoftext|> | 35 |
lolphp | PlasmaSheep | cqwzi1i | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>[Obligatory](http://www.bash.org/?949214)<|eor|><|eols|><|endoftext|> | 28 |
lolphp | tdammers | cqx4scq | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Another day, another suite of wordpress vulnerabilities...
I mean, just read the fucking source code, I dare you - if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.<|eor|><|eols|><|endoftext|> | 24 |
lolphp | gu3st12 | cqx834m | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Again, not lolphp (as any sane PHP dev will agree Wordpress is awful), just lolwordpress.
<|eor|><|eols|><|endoftext|> | 14 |
lolphp | msiemens | cqxb982 | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Again, not lolphp (as any sane PHP dev will agree Wordpress is awful), just lolwordpress.
<|eor|><|soopr|>It's not a problem with the PHP language itself, yes. But I dare to claim that the PHP culture somehow attracts sloppy and insecure code, which is so unfunny that I don't know whether to laugh or to cry.<|eoopr|><|eols|><|endoftext|> | 13 |
lolphp | OneWingedShark | cqxnyxx | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Another day, another suite of wordpress vulnerabilities...
I mean, just read the fucking source code, I dare you - if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.<|eor|><|sor|>> if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.
100 lines?
My hat's off to you, that's more than I could handle without rage, despair and/or sheer-WTF-ness.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | merreborn | cqwz734 | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>lolwordpress almost deserves its own sub<|eor|><|eols|><|endoftext|> | 8 |
lolphp | sli | cqxhd5h | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Another day, another suite of wordpress vulnerabilities...
I mean, just read the fucking source code, I dare you - if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.<|eor|><|sor|>I know a guy that works for a WordPress shop and he told me that I clearly don't know what I'm talking about when I said WordPress has more holes than a sieve.
But hey, whatever makes you money, I guess.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Sarcastinator | cqxppcn | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Again, not lolphp (as any sane PHP dev will agree Wordpress is awful), just lolwordpress.
<|eor|><|sor|>Not even lolwordpress, just loldevelopers.
Third party plugins sporting vulnerabilities. So PHP exclusive.. /s<|eor|><|sor|>> Not even lolwordpress, just loldevelopers
Have you seen the source code to `add_query_arg()`? It most certainly is lolwordpress.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Sandbucketman | cqxcr3q | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Good guy WordPress keeping good PHP developers in business since its conception.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | OneWingedShark | cqya5h8 | <|sols|><|sot|>So unfunny it's funny again: XSS Vulnerability Affecting Multiple WordPress Plugins<|eot|><|sol|>https://blog.sucuri.net/2015/04/security-advisory-xss-vulnerability-affecting-multiple-wordpress-plugins.html<|eol|><|sor|>Another day, another suite of wordpress vulnerabilities...
I mean, just read the fucking source code, I dare you - if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.<|eor|><|sor|>> if you're not sick after 100 lines or so of that stuff, you should at least wonder why wordpress isn't compromised more often than it is.
100 lines?
My hat's off to you, that's more than I could handle without rage, despair and/or sheer-WTF-ness.<|eor|><|sor|>Let's just say that I've spent too much time in the trenches. I have seen terrible terrible things.<|eor|><|sor|>[I understand](https://www.youtube.com/watch?v=k6qFJ09KY-A).<|eor|><|eols|><|endoftext|> | 5 |
lolphp | dagbrown | 251aue | <|sols|><|sot|>Dat return value<|eot|><|sol|>http://www.php.net/manual/en/function.system.php<|eol|><|eols|><|endoftext|> | 39 |
lolphp | diagonalfish | chcrul2 | <|sols|><|sot|>Dat return value<|eot|><|sol|>http://www.php.net/manual/en/function.system.php<|eol|><|sor|>This one has always baffled me. Why would you not return the exit code??? In what percentage of situations is just the last line of output useful?<|eor|><|eols|><|endoftext|> | 29 |
lolphp | ahruss | chdunv5 | <|sols|><|sot|>Dat return value<|eot|><|sol|>http://www.php.net/manual/en/function.system.php<|eol|><|sor|>This one has always baffled me. Why would you not return the exit code??? In what percentage of situations is just the last line of output useful?<|eor|><|sor|>You might need it, but then that should be the out param not the exit code. You are forced to write two lines of code instead of one for the 80% use case.<|eor|><|sor|>I doubt the 80% use case is "I want the last line only."<|eor|><|eols|><|endoftext|> | 9 |
lolphp | frezik | chg2fua | <|sols|><|sot|>Dat return value<|eot|><|sol|>http://www.php.net/manual/en/function.system.php<|eol|><|sor|>This one has always baffled me. Why would you not return the exit code??? In what percentage of situations is just the last line of output useful?<|eor|><|sor|>I wouldn't ding it *too* much if it returned the complete output. It's different than the same function call on many other languages, but that's not necessarily wrong in itself. At worst, it violates the expectations of experienced programmers.
But why just the last line?<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Sarcastinator | chdr7k1 | <|sols|><|sot|>Dat return value<|eot|><|sol|>http://www.php.net/manual/en/function.system.php<|eol|><|sor|>This one has always baffled me. Why would you not return the exit code??? In what percentage of situations is just the last line of output useful?<|eor|><|sor|>windows ?<|eor|><|sor|>Windows has return codes?<|eor|><|eols|><|endoftext|> | 5 |
lolphp | ChoHag | 1yzdwf | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|eoss|><|endoftext|> | 35 |
lolphp | pgl | cfp6wvs | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>[deleted]<|eor|><|soopr|>It would appear that /r/lolphp's collective reading skills are on a par with /r/sysadmin's.
> Thankfully at this place, production is SEP.<|eoopr|><|sor|>Signaling End Point? Someone Else's Problem? Stanford Encyclopedia of Philosophy? <|eor|><|sor|>Someone else's problem.<|eor|><|eoss|><|endoftext|> | 23 |
lolphp | svtguy88 | cfp81t5 | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>So, if magic quotes is deprecated, the only real "lol" here is that OP's production servers are running an old version of PHP...<|eor|><|eoss|><|endoftext|> | 17 |
lolphp | ConcernedInScythe | cfp71hd | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>Yes, so the real WTF here is that PHP defaults to "allow blatant security holes" mode.<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | jeanlucpikachu | cfp6p7r | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>[deleted]<|eor|><|soopr|>It would appear that /r/lolphp's collective reading skills are on a par with /r/sysadmin's.
> Thankfully at this place, production is SEP.<|eoopr|><|sor|>Signaling End Point? Someone Else's Problem? Stanford Encyclopedia of Philosophy? <|eor|><|eoss|><|endoftext|> | 15 |
lolphp | ChoHag | cfp8y8f | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>So, if magic quotes is deprecated, the only real "lol" here is that OP's production servers are running an old version of PHP...<|eor|><|soopr|>Hey it's not all bad. They're running it on an old version of centos too.
They're not my production servers though. I'm here to ~~massacre~~write puppet recipes.<|eoopr|><|eoss|><|endoftext|> | 10 |
lolphp | cbraga | cfp9hhn | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>no, sane software defaults to print an error and exit<|eor|><|eoss|><|endoftext|> | 10 |
lolphp | ChoHag | cfp5rnc | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>[deleted]<|eor|><|soopr|>It would appear that /r/lolphp's collective reading skills are on a par with /r/sysadmin's.
> Thankfully at this place, production is SEP.<|eoopr|><|eoss|><|endoftext|> | 9 |
lolphp | Packet_Ranger | cfpulri | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>So, if magic quotes is deprecated, the only real "lol" here is that OP's production servers are running an old version of PHP...<|eor|><|soopr|>Hey it's not all bad. They're running it on an old version of centos too.
They're not my production servers though. I'm here to ~~massacre~~write puppet recipes.<|eoopr|><|sor|>The puppet DSL has its own special place in hell. It's a declarative language that doesn't need things like flow control or iteration. That's presumably why it needs the following keywords:
before
require
after
creates
subscribe
->
~>
Idempotent my ass.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | pgl | cfp7py4 | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>Yes, so the real WTF here is that PHP defaults to "allow blatant security holes" mode.<|eor|><|sor|>OK, magic_quotes is a WTF. But it's been gone for ages. Defaulting to a WTF feature is basically just, WTF for that feature. I think people try too hard in this subreddit.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | pgl | cfp6wmy | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | merreborn | cfpa3vt | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>Yes, so the real WTF here is that PHP defaults to "allow blatant security holes" mode.<|eor|><|sor|>fortunately, they fixed that hole five years ago (by disabling magic quotes by default). i dont know if we can blame php for the fact that OPs company is over 5 years behind on php patches.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | vita10gy | cfq5pwf | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>no, sane software defaults to print an error and exit<|eor|><|sor|>I disagree. Sane software prints an error - preferably to an error log and to the standard error - and continues to run as best it can.<|eor|><|sor|>It depends on the error. I would classify "hey, so, yeah, I can't read the master configuration file with all the settings in it" as something worthy of die("Fix the server numbnuts");
That PHP does everything it can to keep chugging along in the face of stuff like this is a major flaw, not a feature. It KNOWS there's a config file that it KNOWS it can't read...and it keeps going with different settings even though it can know with almost absolute certainty that those are wrong because you wouldn't have overridden them otherwise. That's absurd, not good.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | cbraga | cfpi03i | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>no, sane software defaults to print an error and exit<|eor|><|sor|>I disagree. Sane software prints an error - preferably to an error log and to the standard error - and continues to run as best it can.<|eor|><|sor|>But HOW can software run sanely if it can't read its settings?
Note that this is a case different from settings file being non-existant where it would be reasonable to revert to defaults. It is a case of settings file being unreadable, therefore indicating that settings have been set, and therefore reverting to default is *not* reasonable behaviour because the file being there and yet not being readable indicates something seriously wrong.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | ChoHag | cfpx259 | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>no, sane software defaults to print an error and exit<|eor|><|sor|>I disagree wholeheartedly.
If you don't provide HTTPD (or various other daemons) w/ a configuration, they simply don't work and proceed to tell you, loudly, about it.<|eor|><|soopr|>This is correct.
"I am a server. I don't know what to serve. Ooh that directory over there looks nice, let's serve that. Silently."<|eoopr|><|eoss|><|endoftext|> | 5 |
lolphp | vita10gy | cfq5kqf | <|soss|><|sot|>Failsafe? Just revert to default.<|eot|><|sost|>Production went down. It was traced back to a change made to php.ini by the MSP (I *really* want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:
"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...
I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.<|eost|><|sor|>Sorry, isn't it the case for *lots* of software that if they can't read their registration settings, they revert to default?<|eor|><|sor|>no, sane software defaults to print an error and exit<|eor|><|sor|>I disagree wholeheartedly.
If you don't provide HTTPD (or various other daemons) w/ a configuration, they simply don't work and proceed to tell you, loudly, about it.<|eor|><|soopr|>This is correct.
"I am a server. I don't know what to serve. Ooh that directory over there looks nice, let's serve that. Silently."<|eoopr|><|sor|>I think you guys over looked that comma. "No, sane software..." and "No sane software..." are different. I think you're on the same page there. He's agreeing that the sane thing to do is error and exit, not chug along as if there's no issue. <|eor|><|eoss|><|endoftext|> | 5 |
lolphp | mjtribute | 192s7z | <|sols|><|sot|>Different behavior the second time around (php 5.4.11). I don't even...<|eot|><|sol|>http://bpaste.net/show/KiqfBA8H2iPgcXIt0FSc/<|eol|><|eols|><|endoftext|> | 33 |
lolphp | postmodest | c8kp0bh | <|sols|><|sot|>Different behavior the second time around (php 5.4.11). I don't even...<|eot|><|sol|>http://bpaste.net/show/KiqfBA8H2iPgcXIt0FSc/<|eol|><|sor|>If you think like a beginning PHP programmer, this makes sense because false == null, right? And $undefined[] = 3, right? So clearly $undefined = null; $undefined == false; $undefined[] = 3; makes sense!
Now you're *thinking with Rasmus*!<|eor|><|eols|><|endoftext|> | 9 |
lolphp | scud43 | pwtr0 | <|sols|><|sot|>does this function really belong in the core?<|eot|><|sol|>http://www.php.net/manual/en/function.metaphone.php<|eol|><|eols|><|endoftext|> | 35 |
lolphp | Altreus | c3sx2ia | <|sols|><|sot|>does this function really belong in the core?<|eot|><|sol|>http://www.php.net/manual/en/function.metaphone.php<|eol|><|sor|>oh sorry I didn't realise PHP had modules! ;)<|eor|><|eols|><|endoftext|> | 14 |
lolphp | ealf | c3t1c1x | <|sols|><|sot|>does this function really belong in the core?<|eot|><|sol|>http://www.php.net/manual/en/function.metaphone.php<|eol|><|sor|>[My favorite](http://www.php.net/manual/en/function.gzgetss.php).<|eor|><|eols|><|endoftext|> | 12 |
lolphp | UnpopularStatment | c3t0p7b | <|sols|><|sot|>does this function really belong in the core?<|eot|><|sol|>http://www.php.net/manual/en/function.metaphone.php<|eol|><|sor|>That anonymous flair thing is stupid. Why should scud43 (OP) and Altreus have their names hidden?<|eor|><|eols|><|endoftext|> | 7 |
lolphp | infinull | c3t12io | <|sols|><|sot|>does this function really belong in the core?<|eot|><|sol|>http://www.php.net/manual/en/function.metaphone.php<|eol|><|sor|>That anonymous flair thing is stupid. Why should scud43 (OP) and Altreus have their names hidden?<|eor|><|sor|>especially since you can just turn "subreddit style" off and see everyone's names.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Jinxuan | fdg5tb | <|soss|><|sot|>array_diff([$self], [$self]) will give error if $self is object<|eot|><|sost|>PHP is always a headache with all comparison functions in its std. It always compare by `==`. For example,
```
in_array(true, ['lolphp']); // return True if you do not pass a third arg for strict comparison.
```
You may image it is the worst thing PHP can have about comparison. However, `array_diff` is worse. `array_diff` will force the compared elements as string, regardless of whether they are strictly equal.
```
$x = new stdClass;
array_diff([$x], [$x]); // PHP Error: Object of class stdClass could not be converted to string
```
What is more lol, `array_diff` does not have a optional variable to force strict comparison. You have to use `array_udiff` with a function callback, like:
```
array_udiff(
[ [$x]
, [$x]
, function ($a, $b) {
return $a === $b;
}
);
```<|eost|><|eoss|><|endoftext|> | 36 |
lolphp | shaql | fjjlbut | <|soss|><|sot|>array_diff([$self], [$self]) will give error if $self is object<|eot|><|sost|>PHP is always a headache with all comparison functions in its std. It always compare by `==`. For example,
```
in_array(true, ['lolphp']); // return True if you do not pass a third arg for strict comparison.
```
You may image it is the worst thing PHP can have about comparison. However, `array_diff` is worse. `array_diff` will force the compared elements as string, regardless of whether they are strictly equal.
```
$x = new stdClass;
array_diff([$x], [$x]); // PHP Error: Object of class stdClass could not be converted to string
```
What is more lol, `array_diff` does not have a optional variable to force strict comparison. You have to use `array_udiff` with a function callback, like:
```
array_udiff(
[ [$x]
, [$x]
, function ($a, $b) {
return $a === $b;
}
);
```<|eost|><|sor|>Well, at least it's [documented](https://www.php.net/manual/en/function.array-diff.php), I guess... D:
> Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In other words: when the string representation is the same.
[Function source code](https://github.com/php/php-src/blob/33ef3d64dac366733f2af40d5bce2bac4e5bca1e/ext/standard/array.c#L5387), if anyone's curious how it works.<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | deusex_ | fjhixie | <|soss|><|sot|>array_diff([$self], [$self]) will give error if $self is object<|eot|><|sost|>PHP is always a headache with all comparison functions in its std. It always compare by `==`. For example,
```
in_array(true, ['lolphp']); // return True if you do not pass a third arg for strict comparison.
```
You may image it is the worst thing PHP can have about comparison. However, `array_diff` is worse. `array_diff` will force the compared elements as string, regardless of whether they are strictly equal.
```
$x = new stdClass;
array_diff([$x], [$x]); // PHP Error: Object of class stdClass could not be converted to string
```
What is more lol, `array_diff` does not have a optional variable to force strict comparison. You have to use `array_udiff` with a function callback, like:
```
array_udiff(
[ [$x]
, [$x]
, function ($a, $b) {
return $a === $b;
}
);
```<|eost|><|sor|>PHP is barely usable. Its a nightmare to work with. The worst thing is core team refuses to fix anything, its old bugs like this still in the new PHP versions.<|eor|><|sor|>Well, maybe the reason why it's so popular is that things don't break as you upgrade.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | Jinxuan | fji9n8q | <|soss|><|sot|>array_diff([$self], [$self]) will give error if $self is object<|eot|><|sost|>PHP is always a headache with all comparison functions in its std. It always compare by `==`. For example,
```
in_array(true, ['lolphp']); // return True if you do not pass a third arg for strict comparison.
```
You may image it is the worst thing PHP can have about comparison. However, `array_diff` is worse. `array_diff` will force the compared elements as string, regardless of whether they are strictly equal.
```
$x = new stdClass;
array_diff([$x], [$x]); // PHP Error: Object of class stdClass could not be converted to string
```
What is more lol, `array_diff` does not have a optional variable to force strict comparison. You have to use `array_udiff` with a function callback, like:
```
array_udiff(
[ [$x]
, [$x]
, function ($a, $b) {
return $a === $b;
}
);
```<|eost|><|sor|>And why does it cast to string in the first place? Probably because it seemed more bearable than plain `==`, which is concerning.<|eor|><|soopr|>I think they use a `Set String` for the second variable to limit the time complexity. However, just like other implementations in PHP std, it is not a good implementation.
​
The correct implementation shall store different typed variables in different set, like
```
type SecondProxy = (Set String, Set Float, Set Int, Set ObjectAddress, ArrayStore)
```
And then search the elements from the first arg in the hashset by type.<|eoopr|><|eoss|><|endoftext|> | 6 |
lolphp | Takeoded | e4q901 | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|eoss|><|endoftext|> | 34 |
lolphp | duskwuff | f9ewomj | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>Most of the `FILTER_SANITIZE_` filters are pretty questionable, TBH. Input sanitization is application-specific, and applications are often better off rejecting bad input than trying to "sanitize" it.
The `FILTER_VALIDATE_` filters are generally more reasonable.<|eor|><|eoss|><|endoftext|> | 19 |
lolphp | doublej42 | f9fejc4 | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>My email address has a space in it and is case sensitive. Find any system that supports it.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | Takeoded | f9fg62t | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>My email address has a space in it and is case sensitive. Find any system that supports it.<|eor|><|soopr|>neat, [section 3 of RFC3696](https://tools.ietf.org/html/rfc3696#section-3) explicitly states that spaces are technically legal (as long as they're escaped with `\`, eg `Fred\ Bloggs@example.com`), yet FILTER_VALIDATE_EMAIL won't accept it. seems FILTER_VALIDATE_EMAIL is bugged here?
still, FILTER_SANITIZE_EMAIL would just remove the space, meaning the email would be sent to the wrong address.<|eoopr|><|eoss|><|endoftext|> | 8 |
lolphp | Altreus | f9h5kyb | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>My email address has a space in it and is case sensitive. Find any system that supports it.<|eor|><|soopr|>neat, [section 3 of RFC3696](https://tools.ietf.org/html/rfc3696#section-3) explicitly states that spaces are technically legal (as long as they're escaped with `\`, eg `Fred\ Bloggs@example.com`), yet FILTER_VALIDATE_EMAIL won't accept it. seems FILTER_VALIDATE_EMAIL is bugged here?
still, FILTER_SANITIZE_EMAIL would just remove the space, meaning the email would be sent to the wrong address.<|eoopr|><|sor|>I do believe you can also just quote that part. "Fred Bloggs"@example.com for instance.
Not sure I'm remembering that correctly though.<|eor|><|sor|>>Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
Double quotes are not legal either.<|eor|><|sor|>Sorry, I meant the email address spec, not this abortion of a function<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | steamruler | f9fxvy1 | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>Honestly, when it comes to email, just check that it contains an unescaped at-symbol, and no linebreaks, and then just give it a go and send a validation email. The local part of an email address is a pain to validate.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | Schmittfried | f9gnwih | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>Honestly, when it comes to email, just check that it contains an unescaped at-symbol, and no linebreaks, and then just give it a go and send a validation email. The local part of an email address is a pain to validate.<|eor|><|sor|>That's exactly what I do, with the addition of checking for a \`.\` after the at sign.
However, that strategy is for recording, storing, and sending mail to a user's email address. For actually displaying in a webpage or HTML attribute, the standard user-entered-sanitation should be applied. And **never** output user-entered data into an HTML comment or \`<script>\` tag. There really is no way to protect against exploits for HTML comments or scripts.<|eor|><|sor|>You don't do that by removing characters, you escape them with html entities.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | Altreus | f9fi834 | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>My email address has a space in it and is case sensitive. Find any system that supports it.<|eor|><|soopr|>neat, [section 3 of RFC3696](https://tools.ietf.org/html/rfc3696#section-3) explicitly states that spaces are technically legal (as long as they're escaped with `\`, eg `Fred\ Bloggs@example.com`), yet FILTER_VALIDATE_EMAIL won't accept it. seems FILTER_VALIDATE_EMAIL is bugged here?
still, FILTER_SANITIZE_EMAIL would just remove the space, meaning the email would be sent to the wrong address.<|eoopr|><|sor|>I do believe you can also just quote that part. "Fred Bloggs"@example.com for instance.
Not sure I'm remembering that correctly though.<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | ubekame | f9hamxx | <|soss|><|sot|>FILTER_SANITIZE_EMAIL should never have existed<|eot|><|sost|>i can't think of a single valid use-case for
> FILTER_SANITIZE_EMAIL "email" Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
if you're actually dealing with an email, the only thing this flag is good for, as far as i can see, is ***data corruption*** , check this:
<?php
$email="@example.org";
$sanitized=filter_var($email,FILTER_SANITIZE_EMAIL,FILTER_FLAG_EMAIL_UNICODE);
var_dump(
filter_var($email,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE),
filter_var($sanitized,FILTER_VALIDATE_EMAIL,FILTER_FLAG_EMAIL_UNICODE)
);
.. it corrupted this 100% syntactically valid email address, to the point where it isn't even a syntactically valid email address anymore, and you can forget all about emails going to the intended recipient.
(saw a co-worker the other day trying to use this god-awful sanitizer for a email-based login system <.<)<|eost|><|sor|>Honestly, when it comes to email, just check that it contains an unescaped at-symbol, and no linebreaks, and then just give it a go and send a validation email. The local part of an email address is a pain to validate.<|eor|><|sor|>That's exactly what I do, with the addition of checking for a \`.\` after the at sign.
However, that strategy is for recording, storing, and sending mail to a user's email address. For actually displaying in a webpage or HTML attribute, the standard user-entered-sanitation should be applied. And **never** output user-entered data into an HTML comment or \`<script>\` tag. There really is no way to protect against exploits for HTML comments or scripts.<|eor|><|sor|>>That's exactly what I do, with the addition of checking for a \`.\` after the at sign.
That is not correct though. There can be MX records on a TLD, .dk has it for example. `dk@dk` is a valid email address.
However, in the vast majority of cases no dot after @ means the user typoed their email so using it to display a warning would probably be good.<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | Takeoded | 7jnt3s | <|sols|><|sot|>we have E_ERROR, we have InvalidArgumentException, but lets just silently mod it<|eot|><|sol|>http://php.net/manual/en/function.chr.php#41471<|eol|><|eols|><|endoftext|> | 31 |
lolphp | maweki | dr8adb3 | <|sols|><|sot|>we have E_ERROR, we have InvalidArgumentException, but lets just silently mod it<|eot|><|sol|>http://php.net/manual/en/function.chr.php#41471<|eol|><|sor|>We wouldn't want to inconvenience the users by having to use the modulo operator themselves.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | tdammers | dr8e8db | <|sols|><|sot|>we have E_ERROR, we have InvalidArgumentException, but lets just silently mod it<|eot|><|sol|>http://php.net/manual/en/function.chr.php#41471<|eol|><|sor|>We wouldn't want to inconvenience the users by having to use the modulo operator themselves.<|eor|><|sor|>Indeed. And we *really* don't want to put them through the agonizing inconvenience of seeing all sorts of error messages ~~in their logs~~ on their website just because of one small programming error.
I also love how this function completely ignores Unicode, another one of those pesky inconveniences that programmers have to deal with in other languages. But not in PHP, no siree, we use ASCII, and if you speak a broken language that doesn't, well, deal with it. Back in the days, we only had 7 bits to store our characters, and we had to store them uphill both ways. And did we complain? No, we didn't, we dealt with it. Now get off my lawn, punk.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | tdammers | dr8gk7r | <|sols|><|sot|>we have E_ERROR, we have InvalidArgumentException, but lets just silently mod it<|eot|><|sol|>http://php.net/manual/en/function.chr.php#41471<|eol|><|sor|>We wouldn't want to inconvenience the users by having to use the modulo operator themselves.<|eor|><|sor|>Indeed. And we *really* don't want to put them through the agonizing inconvenience of seeing all sorts of error messages ~~in their logs~~ on their website just because of one small programming error.
I also love how this function completely ignores Unicode, another one of those pesky inconveniences that programmers have to deal with in other languages. But not in PHP, no siree, we use ASCII, and if you speak a broken language that doesn't, well, deal with it. Back in the days, we only had 7 bits to store our characters, and we had to store them uphill both ways. And did we complain? No, we didn't, we dealt with it. Now get off my lawn, punk.<|eor|><|soopr|>inb4 mb_chr (apparently this does the trick though: `mb_convert_encoding ( '&#' . $i . ';', 'UTF-8', 'HTML-ENTITIES' );`, suggested by a guy in the comments)<|eoopr|><|sor|>Thank God PHP is so simple. My boss has been forcing Haskell on us, where in order to get a character from an integer, you have to use the following monstrosity:
chr i
At least I get to hack on PHP in the weekends and evenings.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | Various_Pickles | dra1v2t | <|sols|><|sot|>we have E_ERROR, we have InvalidArgumentException, but lets just silently mod it<|eot|><|sol|>http://php.net/manual/en/function.chr.php#41471<|eol|><|sor|>We wouldn't want to inconvenience the users by having to use the modulo operator themselves.<|eor|><|sor|>Indeed. And we *really* don't want to put them through the agonizing inconvenience of seeing all sorts of error messages ~~in their logs~~ on their website just because of one small programming error.
I also love how this function completely ignores Unicode, another one of those pesky inconveniences that programmers have to deal with in other languages. But not in PHP, no siree, we use ASCII, and if you speak a broken language that doesn't, well, deal with it. Back in the days, we only had 7 bits to store our characters, and we had to store them uphill both ways. And did we complain? No, we didn't, we dealt with it. Now get off my lawn, punk.<|eor|><|soopr|>inb4 mb_chr (apparently this does the trick though: `mb_convert_encoding ( '&#' . $i . ';', 'UTF-8', 'HTML-ENTITIES' );`, suggested by a guy in the comments)<|eoopr|><|sor|>Thank God PHP is so simple. My boss has been forcing Haskell on us, where in order to get a character from an integer, you have to use the following monstrosity:
chr i
At least I get to hack on PHP in the weekends and evenings.<|eor|><|sor|>I cannot fathom a language / standard library whose reaction to codepoints and characters not being equivalent being anything but telling nonsense lies or ass fucking itself to death immediately.
You have been reported for sheer perversion.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | the_alias_of_andrea | 41gkss | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|eols|><|endoftext|> | 36 |
lolphp | cbraga | cz2ssk0 | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|sor|>Once I was developing my little PHP app and I changed precision to a big number then it broke another app on my server because it relied on that to round off its numbers.
*Can anyone tell if I'm joking or not?*<|eor|><|eols|><|endoftext|> | 21 |
lolphp | the_alias_of_andrea | cz26n2m | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | emilvikstrom | cz2mq1k | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|sor|>I sense that you just spent multiple hours troubleshooting this?<|eor|><|eols|><|endoftext|> | 12 |
lolphp | the_alias_of_andrea | cz3873h | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|sor|>The lolphp is that the behavior of every single part of the language depends on 1001 configuration options.
But there's no such thing as "accurately" converting a floating point to a string. There isn't even such a thing as "converting" a floating point to a string. It's more like "rendering" an internal representation into a human-readable format. It's reasonable to impose a precision limit with an arbitrary default.
I don't want 20+ extra trailing decimal places representing the least significant bit in a string representation of a floating point number, just so that format->parse round trips properly, which should never need to round trip properly, since if you're storing intermediate computation results as strings, you're obviously doing something wrong.
Newfags can't floating point.<|eor|><|soopr|>> The lolphp is that the behavior of every single part of the language depends on 1001 configuration options.
Thankfully not quite every. We've gotten more averse to adding php.ini options, but we're stuck with a lot that are still there.
> But there's no such thing as "accurately" converting a floating point to a string. There isn't even such a thing as "converting" a floating point to a string. It's more like "rendering" an internal representation into a human-readable format.
That's not quite fair. You can convert floats to decimal and print them at full precision, but *typically* what is done instead is print the shortest string that when converted back to a float produces the same result. Either is fine.
> It's reasonable to impose a precision limit with an arbitrary default.
Why is it reasonable to discard information?
> I don't want 20+ extra trailing decimal places representing the least significant bit in a string representation of a floating point number
You can't get 20+ extra trailing decimal places. There's *at most* 17 significant digits, and for very large or small numbers you'll get something in scientific notation anyway.
> just so that format->parse round trips properly, which should never need to round trip properly, since if you're storing intermediate computation results as strings, you're obviously doing something wrong
Who said these were *intermediate* results?<|eoopr|><|eols|><|endoftext|> | 9 |
lolphp | the_alias_of_andrea | cz33va0 | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|sor|>Once I was developing my little PHP app and I changed precision to a big number then it broke another app on my server because it relied on that to round off its numbers.
*Can anyone tell if I'm joking or not?*<|eor|><|soopr|>That sounds too real to be a joke. I can completely imagine someone setting the precision to "4" or something with `ini_set`.<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | the_alias_of_andrea | cz33sus | <|sols|><|sot|>The existence of the "precision" INI setting - PHP converts floats to string inaccurately, by default<|eot|><|sol|>http://php.net/manual/en/ini.core.php#ini.precision<|eol|><|soopr|>Because *deliberately discarding ten binary digits* is a problem when, you know, trying to reproduce a number, it has a separate `serialize_precision` option used for serialisation functions, which is set to a reasonable setting, i.e. not getting rid of your digits.
Rather than, you know, doing the sensible thing by default. I mean, why would anyone ever want PHP to *accurately* convert floats to string? That's just what a reasonable person would expect!
Rather than, you know, *not having a goddamn GLOBAL CONFIGURATION FILE SETTING ON WHETHER TO ACCURATELY REPRODUCE NUMBERS*.
And why the hell does `var_dump` use `precision` instead of `serialize_precision`? It's a *debugging function*, yet it doesn't output numbers with full accuracy! [It **LIES TO YOU**!](https://3v4l.org/kYdZd) (and before you point out you should compare within some epsilon, PHP rounds off enough digits that it may encompass your epsilon value)
\*cries\*<|eoopr|><|sor|>I sense that you just spent multiple hours troubleshooting this?<|eor|><|soopr|>Luckily, it's never actually caused me an issue. I just got a little upset when someone tried to justify it.<|eoopr|><|eols|><|endoftext|> | 7 |
lolphp | Miserable_Fuck | 41fshf | <|soss|><|sot|>[META] Why all the white knighting?<|eot|><|sost|>In almost every post, there's always at least one comment dismissing it by claiming that it "isn't a lolphp", or that it was fixed in version x.y.z, or that other languages do the same, or that it's really a "lol php developer" or a "lol php manual" or a "lol php community", etc.
Why are you people even here? Why come to /r/lolphp to defend php? Is it not clear what this sub is for? This is supposed to be a fun place, to make fun of php and maybe...*maybe* even learn something along the way. Your pontification ruins the mood, man. You're a killjoy.
I'm not sure if you feel personally attacked when people make fun of php, or if you just want to show a bunch of strangers how much you know, but this isn't the place to do it. It's not like this sub is a leading authority when it comes to php critique. No one looking for a good list of pros/cons of php is going to come here. Nobody takes it too seriously. In fact, the only people who *do* take it seriously seem to be the ones who rush to dismiss as much criticism as possible.
This is just my opinion. I'm expecting downvotes and passive-aggressive replies, because these apologetic comments are usually among the most upvoted in the thread, but I had to say this. I'm not sure how the mods feel about this sub, but unless the post is a blatant, bold-faced lie, these types of comments shouldn't exist.<|eost|><|eoss|><|endoftext|> | 37 |
lolphp | DoctorWaluigiTime | cz22wob | <|soss|><|sot|>[META] Why all the white knighting?<|eot|><|sost|>In almost every post, there's always at least one comment dismissing it by claiming that it "isn't a lolphp", or that it was fixed in version x.y.z, or that other languages do the same, or that it's really a "lol php developer" or a "lol php manual" or a "lol php community", etc.
Why are you people even here? Why come to /r/lolphp to defend php? Is it not clear what this sub is for? This is supposed to be a fun place, to make fun of php and maybe...*maybe* even learn something along the way. Your pontification ruins the mood, man. You're a killjoy.
I'm not sure if you feel personally attacked when people make fun of php, or if you just want to show a bunch of strangers how much you know, but this isn't the place to do it. It's not like this sub is a leading authority when it comes to php critique. No one looking for a good list of pros/cons of php is going to come here. Nobody takes it too seriously. In fact, the only people who *do* take it seriously seem to be the ones who rush to dismiss as much criticism as possible.
This is just my opinion. I'm expecting downvotes and passive-aggressive replies, because these apologetic comments are usually among the most upvoted in the thread, but I had to say this. I'm not sure how the mods feel about this sub, but unless the post is a blatant, bold-faced lie, these types of comments shouldn't exist.<|eost|><|sor|>Because half the time the post shouldn't exist. Defending PHP is fine when it's warranted, like when the post is either
* incorrect
* references a fixed bug (as recently as [today](https://www.reddit.com/r/lolphp/comments/41ejnm/php_debugger_xdebug_cant_break_on_or_step_into/))
* is about poor coding (e.g. "look at this 3,000 line abomination!") instead of the language itself.
We're here because PHP has plenty to make fun of and ridicule. It doesn't need any help.<|eor|><|eoss|><|endoftext|> | 63 |
lolphp | Rhomboid | cz20i4s | <|soss|><|sot|>[META] Why all the white knighting?<|eot|><|sost|>In almost every post, there's always at least one comment dismissing it by claiming that it "isn't a lolphp", or that it was fixed in version x.y.z, or that other languages do the same, or that it's really a "lol php developer" or a "lol php manual" or a "lol php community", etc.
Why are you people even here? Why come to /r/lolphp to defend php? Is it not clear what this sub is for? This is supposed to be a fun place, to make fun of php and maybe...*maybe* even learn something along the way. Your pontification ruins the mood, man. You're a killjoy.
I'm not sure if you feel personally attacked when people make fun of php, or if you just want to show a bunch of strangers how much you know, but this isn't the place to do it. It's not like this sub is a leading authority when it comes to php critique. No one looking for a good list of pros/cons of php is going to come here. Nobody takes it too seriously. In fact, the only people who *do* take it seriously seem to be the ones who rush to dismiss as much criticism as possible.
This is just my opinion. I'm expecting downvotes and passive-aggressive replies, because these apologetic comments are usually among the most upvoted in the thread, but I had to say this. I'm not sure how the mods feel about this sub, but unless the post is a blatant, bold-faced lie, these types of comments shouldn't exist.<|eost|><|sor|>There are actual lolphp posts and then there are people that don't know what they're talking about that claim something is a lolphp when it's notfor example, it's something that works the same way in a dozen other major languages and is in no way specific to PHP. For example, "oh my good, look at this, PHP thinks that 0.1 + 0.2 doesn't equal 0.3! What a loser of a language!" If someone posted that they deserve ridicule and downvotes, because that's not a lolphp, and it has no business being posted here. If you don't understand what makes a lolphp a lolphp you have no right to critique language design.
PHP is such a fertile ground for legitimate observations of shitty design that you should have no problem finding a steady stream of them without resorting to dredging up nonsense. It comes off as pathetic. It's like when a group of people are all standing around telling hilarious jokes and then another person walks up and tries to tell a joke but completely fucks up the punchline and then there's awkward silence while everyone stares at their feet. You have completely killed the mood for everyone. It has nothing to do with "white knighting" (an utterly vile term) or wanting to defend PHP. It's about requiring criticisms to actually be coherent and have some basis in reality. If you can't form a coherent argument, then you're no better than some moron that thinks PHP is just fine and doesn't have any problems.
<|eor|><|eoss|><|endoftext|> | 22 |
lolphp | Rhomboid | cz6dbb5 | <|soss|><|sot|>[META] Why all the white knighting?<|eot|><|sost|>In almost every post, there's always at least one comment dismissing it by claiming that it "isn't a lolphp", or that it was fixed in version x.y.z, or that other languages do the same, or that it's really a "lol php developer" or a "lol php manual" or a "lol php community", etc.
Why are you people even here? Why come to /r/lolphp to defend php? Is it not clear what this sub is for? This is supposed to be a fun place, to make fun of php and maybe...*maybe* even learn something along the way. Your pontification ruins the mood, man. You're a killjoy.
I'm not sure if you feel personally attacked when people make fun of php, or if you just want to show a bunch of strangers how much you know, but this isn't the place to do it. It's not like this sub is a leading authority when it comes to php critique. No one looking for a good list of pros/cons of php is going to come here. Nobody takes it too seriously. In fact, the only people who *do* take it seriously seem to be the ones who rush to dismiss as much criticism as possible.
This is just my opinion. I'm expecting downvotes and passive-aggressive replies, because these apologetic comments are usually among the most upvoted in the thread, but I had to say this. I'm not sure how the mods feel about this sub, but unless the post is a blatant, bold-faced lie, these types of comments shouldn't exist.<|eost|><|sor|>There are actual lolphp posts and then there are people that don't know what they're talking about that claim something is a lolphp when it's notfor example, it's something that works the same way in a dozen other major languages and is in no way specific to PHP. For example, "oh my good, look at this, PHP thinks that 0.1 + 0.2 doesn't equal 0.3! What a loser of a language!" If someone posted that they deserve ridicule and downvotes, because that's not a lolphp, and it has no business being posted here. If you don't understand what makes a lolphp a lolphp you have no right to critique language design.
PHP is such a fertile ground for legitimate observations of shitty design that you should have no problem finding a steady stream of them without resorting to dredging up nonsense. It comes off as pathetic. It's like when a group of people are all standing around telling hilarious jokes and then another person walks up and tries to tell a joke but completely fucks up the punchline and then there's awkward silence while everyone stares at their feet. You have completely killed the mood for everyone. It has nothing to do with "white knighting" (an utterly vile term) or wanting to defend PHP. It's about requiring criticisms to actually be coherent and have some basis in reality. If you can't form a coherent argument, then you're no better than some moron that thinks PHP is just fine and doesn't have any problems.
<|eor|><|sor|>>For example, "oh my good, look at this, PHP thinks that 0.1 + 0.2 doesn't equal 0.3! What a loser of a language!" If someone posted that they deserve ridicule and downvotes, because that's not a lolphp, and it has no business being posted here.
Am I being stupid? I just tried that and it does equal 0.3?<|eor|><|sor|>[No it doesn't](https://3v4l.org/T4TJv).
<|eor|><|sor|>Okay, I'm seriously confused at this point. The print statement is what I originally tried:
https://3v4l.org/4afdT
It's certainly not obvious to me why that's the "correct" behaviour? My first thought was borken type handling, but == gets the same result.
If it is correct, it's not hard to see how it gets posted as a lolphp all the time.<|eor|><|sor|>The computer cannot represent 0.3. When you write 0.3 in a program, what you really get is a number that is very close to 0.3 but not actually 0.3. The same applies to 0.1 and 0.2. None of these values can be represented by the computer. (At least not without using something other than IEEE binary floating point, which is what virtually all languages use as the standard floating point number type as that's what the hardware actually implements.)
When you add not-quite-0.1 to not-quite-0.2 you get not-quite-0.3. But that not-quite-0.3 is slightly different than the not-quite-0.3 you get if you just write 0.3, because the two errors compounded. That's why the equality is false. However, if you try to print either of those not-quite-0.3 values, the code that handles converting those values to strings will often choose to round them if they're very close. You generally do not want to see values like 0.299999999999999988897769753748434595763683319091796875 or 0.3000000000000000444089209850062616169452667236328125 when you ask to print a floating point value. The former is the actual result computed by 0.1 + 0.2, and the latter is the actual value you get when you write 0.3. So those IO routines will do some rounding and print 0.3 because that's probably what you wanted, but that's not the value that the computer is working with.
This is not a lolphp because it works the same way in just about any language, and it's the nature of binary floating point.
<|eor|><|eoss|><|endoftext|> | 10 |
lolphp | BoredOfCanada | cz9xa4y | <|soss|><|sot|>[META] Why all the white knighting?<|eot|><|sost|>In almost every post, there's always at least one comment dismissing it by claiming that it "isn't a lolphp", or that it was fixed in version x.y.z, or that other languages do the same, or that it's really a "lol php developer" or a "lol php manual" or a "lol php community", etc.
Why are you people even here? Why come to /r/lolphp to defend php? Is it not clear what this sub is for? This is supposed to be a fun place, to make fun of php and maybe...*maybe* even learn something along the way. Your pontification ruins the mood, man. You're a killjoy.
I'm not sure if you feel personally attacked when people make fun of php, or if you just want to show a bunch of strangers how much you know, but this isn't the place to do it. It's not like this sub is a leading authority when it comes to php critique. No one looking for a good list of pros/cons of php is going to come here. Nobody takes it too seriously. In fact, the only people who *do* take it seriously seem to be the ones who rush to dismiss as much criticism as possible.
This is just my opinion. I'm expecting downvotes and passive-aggressive replies, because these apologetic comments are usually among the most upvoted in the thread, but I had to say this. I'm not sure how the mods feel about this sub, but unless the post is a blatant, bold-faced lie, these types of comments shouldn't exist.<|eost|><|sor|>Lately I've seen posts lifted from r/php and the comment's within it, which are border-line attacking the poster/commenter, which isn't on.
We're making fun of the language and it's inconsistencies and bugs, not it's users.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | Hacre | 3zqf0w | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|eoss|><|endoftext|> | 36 |
lolphp | Dylan16807 | cyoe7sq | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>But JSON only has a single number type. The real joke is someone that tries to pretend otherwise and breaks when the same value is printed with different formatting.<|eor|><|eoss|><|endoftext|> | 41 |
lolphp | jspenguin | cyo982l | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>Is there still no way to chose whether array() outputs [] or {} ?<|eor|><|sor|>[deleted]<|eor|><|sor|>Murphy's law, PHP version: "Whenever there is a right way and a wrong way to to something, PHP will do it both ways at the same time, poorly"<|eor|><|eoss|><|endoftext|> | 26 |
lolphp | McGlockenshire | cyo9vdk | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>Is there still no way to chose whether array() outputs [] or {} ?<|eor|><|sor|>You get [] if and only if the array has only numeric indexes, the first index is 0, there are no gaps in the index numbering, and the index numbers are in ascending order. Otherwise you get {}.
It kinda makes sense. If the first index isn't zero, or there are gaps in the indexes, it's not a normal array structure, so representing it using [] is troublesome. Out of order keys could be OK, but they'd end up sorted differently in the output, which might not be the intent of the data structure being serialized. The closest thing JS has to the ordered map that PHP calls an "array" would be an object.
If you just need an empty [], `array()` / `[]` produce it. If you need an empty {}, then just pass in an empty stdClass.<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | polish_niceguy | cyocqsx | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>Is there still no way to chose whether array() outputs [] or {} ?<|eor|><|sor|>[deleted]<|eor|><|sor|>I'm getting `[[]]` on 5.6.10<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | CliffEdgeOrg | cyomdqo | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>Is there still no way to chose whether array() outputs [] or {} ?<|eor|><|sor|>just write
json_encode($arr, JSON_FORCE_OBJECT);
available since 5.3.0<|eor|><|eoss|><|endoftext|> | 9 |
lolphp | vita10gy | cyom3g5 | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|soopr|>Not to mention fixing a bug by adding a stupid option because "muh BC"<|eoopr|><|sor|>https://xkcd.com/1172/<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | the_alias_of_andrea | cyovsod | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>But JSON only has a single number type. The real joke is someone that tries to pretend otherwise and breaks when the same value is printed with different formatting.<|eor|><|sor|>Yeah, this is lol$otherlanguage, not lolphp.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | Schmittfried | cyp6d91 | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>On a related note. Why does using an undefined CONSTANT give only a notice? Are there other languages that accept this so lightly out there? Can you think of a case where using an undefined constant is not a mayor issue?<|eor|><|sor|>>Can you think of a case where using an undefined constant is not a mayor issue?
Because people are lazy and liked to write stuff like `$arr[key] = $value;`. It's not about actually having undefined constants, it's about being able to use simple strings without quotes. Of course it's stupid, but once introduced, you cannot simply break so much code by issuing an error immediately. If anything, you have to gradually make it a notice, then a warning and then an error.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | berkes | cyp3xe0 | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|sor|>On a related note. Why does using an undefined CONSTANT give only a notice? Are there other languages that accept this so lightly out there? Can you think of a case where using an undefined constant is not a mayor issue?<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | Hacre | cyo4sas | <|soss|><|sot|>JSON_PRESERVE_ZERO_FRACTION because someone realised json cares about types...<|eot|><|sost|>[5.6.6 JSON_PRESERVE_ZERO_FRACTION option was added.](http://php.net/manual/en/function.json-encode.php)
Before 5.6.6, [tough shit](https://3v4l.org/GFGRr)<|eost|><|soopr|>Not to mention fixing a bug by adding a stupid option because "muh BC"<|eoopr|><|eoss|><|endoftext|> | 6 |
lolphp | cythrawll | 1mbcrr | <|soss|><|sot|>PDO's default error mode is "silent"<|eot|><|sost|>The Other error modes, are Warning and Exception. You can still get errors from the API with errorInfo() etc... but that means a manual check... which most newbie developers ALWAYS forget to do.
I've seen people waste days wondering why PDO isn't working... only for me to tell them to switch error modes, and they get an obvious message that they figure out how to fix in seconds.<|eost|><|eoss|><|endoftext|> | 30 |
lolphp | cythrawll | cc7s5g1 | <|soss|><|sot|>PDO's default error mode is "silent"<|eot|><|sost|>The Other error modes, are Warning and Exception. You can still get errors from the API with errorInfo() etc... but that means a manual check... which most newbie developers ALWAYS forget to do.
I've seen people waste days wondering why PDO isn't working... only for me to tell them to switch error modes, and they get an obvious message that they figure out how to fix in seconds.<|eost|><|sor|>Don't tell them to switch error modes. Tell them to use proper error handling.<|eor|><|soopr|>IMO, exception mode IS the way to properly handle database errors. But I'm sure we could have a debate on that.
Also if there is no one to tell them to do it right... does it make a sound?
edit: adding point.<|eoopr|><|eoss|><|endoftext|> | 11 |
lolphp | phoshi | cc83x7t | <|soss|><|sot|>PDO's default error mode is "silent"<|eot|><|sost|>The Other error modes, are Warning and Exception. You can still get errors from the API with errorInfo() etc... but that means a manual check... which most newbie developers ALWAYS forget to do.
I've seen people waste days wondering why PDO isn't working... only for me to tell them to switch error modes, and they get an obvious message that they figure out how to fix in seconds.<|eost|><|sor|>Like you say yourself, it's not "silent". It's just a different method of error handling. Some people prefer to use return codes to check for errors, others want exceptions. It's a matter of both preference and software design.<|eor|><|sor|>Except, php already made that choice, it's a language with an exceptions system. If it preferred return codes then it wouldn't have an exceptions system, and mixing and matching is just confusing. <|eor|><|eoss|><|endoftext|> | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.