subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | DoYouEverJustInvert | j9olx4y | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|sor|>The comments on the bug report are even worse. Just because its documented doesnt make this behaviour any less insane. A standard library function whose job it is to accept correct passwords shouldnt also accept some other bullshit. Youre setting yourself up for failure, because now all of a sudden everything else in your app needs to be airtight.<|eor|><|eols|><|endoftext|> | 41 |
lolphp | quchen | j9oeifx | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|soopr|>In PHPs defense, they fixed this. In the links defense, the first answer states that this is documented behavior and therefore not a bug.<|eoopr|><|eols|><|endoftext|> | 30 |
lolphp | elcapitanoooo | j9oibm5 | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|soopr|>In PHPs defense, they fixed this. In the links defense, the first answer states that this is documented behavior and therefore not a bug.<|eoopr|><|sor|>A lesson i learned a long time ago. Never trust PHP for anything. We moved our auth service away from PHP for the numerous sec vulnerabilities and bugs we encountered.<|eor|><|eols|><|endoftext|> | 21 |
lolphp | lego_not_legos | j9qoupe | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|sor|>If I'm reading this correctly, one would first need write privileges to whatever data store holds password hashes, and not via typical application code where a valid hash would be generated. I'm pretty sure that if someone has that privilege, and can easily abuse it, then this bug is the least of your concerns.<|eor|><|eols|><|endoftext|> | 19 |
lolphp | snuggl | j9osi7d | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|soopr|>In PHPs defense, they fixed this. In the links defense, the first answer states that this is documented behavior and therefore not a bug.<|eoopr|><|sor|>A lesson i learned a long time ago. Never trust PHP for anything. We moved our auth service away from PHP for the numerous sec vulnerabilities and bugs we encountered.<|eor|><|sor|>And surely, you can provide some of that "numerous" sec vulnerabilities and bugs, can't you?<|eor|><|sor|>This is a sub about shitting on PHP and its shortcomings, no one here will care about you simping for it lol, if you actually want a list of historical php vulns then thats not hard to find with google.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | thenickdude | j9r2gcu | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|sor|>If I'm reading this correctly, one would first need write privileges to whatever data store holds password hashes, and not via typical application code where a valid hash would be generated. I'm pretty sure that if someone has that privilege, and can easily abuse it, then this bug is the least of your concerns.<|eor|><|sor|>The only thing I can think of that would give an attacker any benefit using this bug is that the attacker could put one of these magic hashes on an account, and then both the attacker and the user would still be able to log into it afterwards.
This would allow an attacker persistent access to the account without alerting the victim, compared to just replacing the hash with a standard known one.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | elcapitanoooo | j9p013z | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|soopr|>In PHPs defense, they fixed this. In the links defense, the first answer states that this is documented behavior and therefore not a bug.<|eoopr|><|sor|>A lesson i learned a long time ago. Never trust PHP for anything. We moved our auth service away from PHP for the numerous sec vulnerabilities and bugs we encountered.<|eor|><|sor|>And surely, you can provide some of that "numerous" sec vulnerabilities and bugs, can't you?<|eor|><|sor|>This was back in PHP4 days, going to PHP5 IIRC. I cant recall specifics, but i do know the constant trouble we had back then. Basically we ended up writing unit tests for stdlib edge case behaviour.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | daperson1 | j9tc45i | <|sols|><|sot|>Password_verify() always returns true with some hash<|eot|><|sol|>https://bugs.php.net/bug.php?id=81744<|eol|><|sor|>It's been 84 years since I've written contemporary PHP, so I don't know recommended error handling practices these days, butsurely this should throw an exception, or something like that?<|eor|><|sor|>PHP likes to mix things up: sometimes things do exceptions, sometimes things do C-style return status codes, sometimes things exhibit undefined behaviour, and sometimes they just insist "of course nobody will ever do that" and screech at anyone who questions it.
PHP as a language is kinda buggy, but the real reason to avoid it like the plague is that the people behind it lack the necessary attitudes/sanity to improve it at a decent pace. Things are less bad than they used to be, but it's still far from good.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | vytah | 249spg | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|eols|><|endoftext|> | 54 |
lolphp | poizan42 | ch502rd | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>The real WTF is this:
> Casting non-empty array to boolean using (bool) takes a time with respect to array length. There are no reasons for this. This is abnormal.
> **Any other checks like `if ($array)`, `($array) ?:`, `[] === $array` and so on are not affected.**
IOW the explicit cast to boolean uses another code path than using array in a boolean context...<|eor|><|eols|><|endoftext|> | 25 |
lolphp | lisp-case | ch55tcf | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>The real WTF is this:
> Casting non-empty array to boolean using (bool) takes a time with respect to array length. There are no reasons for this. This is abnormal.
> **Any other checks like `if ($array)`, `($array) ?:`, `[] === $array` and so on are not affected.**
IOW the explicit cast to boolean uses another code path than using array in a boolean context...<|eor|><|sor|>Wouldn't be the first time. Take the string -> number conversion for example:
$ php -a
Interactive shell
php > var_dump((int) "0xa");
int(0)
php > var_dump(intval("0xa"));
int(0)
php > var_dump("0xa" == 10);
bool(true)
Explicit casts of strings to numbers go down one coede path, implicit casts go down another. Now, one might object that we can't expect `intval` to work here because the implicit value of the `$base` parameter is `10`, that if we really want this behavior we can pass `0` (special value for "auto-detect") explicitly. This kind of works:
php > var_dump(intval("0xa", 0));
int(10)
But you know what it doesn't work for? Octal:
php > var_dump(intval("010", 0));
int(8)
php > var_dump("010" == 8);
bool(false)
So. I have no Earthly idea what's going on.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | vytah | ch5k46e | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>not a problem in hhvm
$ hhvm test.php
empty 0.10 sec. total
x10 0.10 sec. total
x100 0.10 sec. total
x1000 0.10 sec. total
$ php test.php
empty 0.15 sec. total
x10 0.42 sec. total
x100 2.70 sec. total
x1000 26.20 sec. total
edit: formatting<|eor|><|soopr|>What would be really good for PHP is the following sequence of events:
* HHVM becomes the most popular PHP implementation in the wild
* amount of new software that works only with the original interpreter becomes smaller than amount of new software that works only on HHVM
* Facebook initiates slow, yet thorough cleaning of the language: deprecating more and more of the silly stuff we laugh about, making it throw warnings on other, and finally growing it into a clunky, yet sane language<|eoopr|><|eols|><|endoftext|> | 16 |
lolphp | cythrawll | ch5i4w7 | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>not a problem in hhvm
$ hhvm test.php
empty 0.10 sec. total
x10 0.10 sec. total
x100 0.10 sec. total
x1000 0.10 sec. total
$ php test.php
empty 0.15 sec. total
x10 0.42 sec. total
x100 2.70 sec. total
x1000 26.20 sec. total
edit: formatting<|eor|><|eols|><|endoftext|> | 10 |
lolphp | milordi | ch8quao | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>Wow, no one from php.net team not pointed in comments that's "not a bug" or something? I'm shocked.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | cbraga | ch5602s | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>The real WTF is this:
> Casting non-empty array to boolean using (bool) takes a time with respect to array length. There are no reasons for this. This is abnormal.
> **Any other checks like `if ($array)`, `($array) ?:`, `[] === $array` and so on are not affected.**
IOW the explicit cast to boolean uses another code path than using array in a boolean context...<|eor|><|sor|>this comment takes the cake imho
> Yes, "workaround" to pass thru the bugs maze. Welcome to PHP. Did you expect something else?..<|eor|><|eols|><|endoftext|> | 8 |
lolphp | vytah | ch58v3u | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>Not to be "that guy" but...casting an array as a bool? Egads.
If you mean count($array)>0 then put count($array)>0 because that automatically adds some explicitness/clarity to what you're doing anyway and, of course, makes it a bool. IMHO this is one of those things where your code will be much better off in the long run if you ignore/forget that arrays have inherent truthiness.
Same thing for strings. We all love all these things that PHP does "for you" at first, but a few years into developing PHP you start to realize that $x=="" or $x!="" are worth the 4 extra keystrokes, because it imparts explicitness to it, as well as denoting $x is a string.
Edit: Which isn't to say this isn't an issue that needs fixing. <|eor|><|soopr|>Not very relevant, but [the official Python style guide (PEP-8)](http://legacy.python.org/dev/peps/pep-0008/) recommends testing a collection itself instead of its length for being empty:
>For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
>
>`Yes: if not seq:`
>`if seq:`
>` `
>`No: if len(seq)`
>`if not len(seq)`
<|eoopr|><|eols|><|endoftext|> | 8 |
lolphp | suspiciously_calm | ch5bbsz | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>The real WTF is this:
> Casting non-empty array to boolean using (bool) takes a time with respect to array length. There are no reasons for this. This is abnormal.
> **Any other checks like `if ($array)`, `($array) ?:`, `[] === $array` and so on are not affected.**
IOW the explicit cast to boolean uses another code path than using array in a boolean context...<|eor|><|sor|>this comment takes the cake imho
> Yes, "workaround" to pass thru the bugs maze. Welcome to PHP. Did you expect something else?..<|eor|><|sor|>What really takes the cake imho is the comment that the code is too spaghetti to fix.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | vita10gy | ch59cu8 | <|sols|><|sot|>Casting arrays to booleans is O(n), because instead of simply checking array length directly, PHP copies the entire array first<|eot|><|sol|>https://bugs.php.net/bug.php?id=67124<|eol|><|sor|>Not to be "that guy" but...casting an array as a bool? Egads.
If you mean count($array)>0 then put count($array)>0 because that automatically adds some explicitness/clarity to what you're doing anyway and, of course, makes it a bool. IMHO this is one of those things where your code will be much better off in the long run if you ignore/forget that arrays have inherent truthiness.
Same thing for strings. We all love all these things that PHP does "for you" at first, but a few years into developing PHP you start to realize that $x=="" or $x!="" are worth the 4 extra keystrokes, because it imparts explicitness to it, as well as denoting $x is a string.
Edit: Which isn't to say this isn't an issue that needs fixing. <|eor|><|soopr|>Not very relevant, but [the official Python style guide (PEP-8)](http://legacy.python.org/dev/peps/pep-0008/) recommends testing a collection itself instead of its length for being empty:
>For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
>
>`Yes: if not seq:`
>`if seq:`
>` `
>`No: if len(seq)`
>`if not len(seq)`
<|eoopr|><|sor|>First off, even that isn't casting it to a bool, although I did subsequently go beyond that point.
Secondly, while there are places where someone could persuade me that ___ is faster, I'd disagree with that approach in general. Also, maybe you don't have to use count() but could use empty(), isset(), or something else, depending on what you *actually* meant there.
As a generality I would say that a person would be happier in the long run if they, and their cohorts, all get in the habit of explicitly putting what they mean to be there, instead of leaning on PHP's inherent "everything is truthy or falsey" magic. The code will read better, the programmers' intent is clear, and they won't get in to trouble, because EVERYTHING is truthy or falsey.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Serialk | 1zb7kl | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|eoss|><|endoftext|> | 57 |
lolphp | maktouch | cfs8ljx | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>2014 and still using php4? wtf. <|eor|><|eoss|><|endoftext|> | 39 |
lolphp | i_zumba | cfscs3q | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>The real WTF is that there was no February 29th in 2014, so I call fake. Last time February 29th was a Saturday was in 1992, so whatever...
<|eor|><|eoss|><|endoftext|> | 34 |
lolphp | Drainedsoul | cfsbg7p | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>I think it is a typo, its meant to read PHP5.4<|eor|><|sor|>You mean you **hope**. <|eor|><|eoss|><|endoftext|> | 22 |
lolphp | vexii | cfsijwo | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>The real WTF is that there was no February 29th in 2014, so I call fake. Last time February 29th was a Saturday was in 1992, so whatever...
<|eor|><|sor|>php time you know.<|eor|><|eoss|><|endoftext|> | 21 |
lolphp | jsanc623 | cfs5wrl | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>So they're not monitoring their CPU temperature? Sounds more like shoddy administration and they chose to blame it on software.<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | you_drown_now | cft4run | <|soss|><|sot|>PHP can cause bad things to happen.<|eot|><|sost|>Not really a lolphp, I think it will probably make you laugh though.
https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png
Translation:
> 0:32 We're proceeding to the complete migration of servers [...]
> 10:40 User data have been saved.
> 16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.<|eost|><|sor|>Ah the good ol'
./configure --prefix=/opt/php4 --with-config-file-path=/etc/php4 --with-mysql --with-ttf --enable-gd-native-ttf --with-freetype-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-zlib --with-openssl-dir=/usr/include/openssl --with-dom --with-gd --enable-sockets --enable-mbstring --with-curl --enable-mbregex --with-libxml --with-imap --with-iconv --enable-force-fed-redirect --enable-fastcgi --with-kerberos --with-imap-ssl --enable-cgi --enable-memory-limit --enable-cli --bindir=/usr/bin && echo -e 'why' && rm -Rf / <|eor|><|eoss|><|endoftext|> | 8 |
lolphp | FenneDL | 1r7iz6 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|eols|><|endoftext|> | 58 |
lolphp | n1c0_ds | cdkh5v1 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>As much as it sucks, report it. This way it will be added to the feature list.<|eor|><|eols|><|endoftext|> | 31 |
lolphp | ajmarks | cdkdrzq | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|eols|><|endoftext|> | 21 |
lolphp | _vec_ | cdkhhwi | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|eols|><|endoftext|> | 18 |
lolphp | catcradle5 | cdktda9 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>[deleted]<|eor|><|sor|>I totally disagree with point 1. In very few languages would you expect a loop-variable to be bound after you exit the loop scope.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | h2ooooooo | cdkj1jg | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | billy_tables | cdki2gg | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>What's @func?
Edit - it silences any errors or notices that are raised. Why would you do that!?<|eor|><|eols|><|endoftext|> | 10 |
lolphp | ma-int | cdke10g | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>Isn't this the hidden beauty of PHP? :-) <|eor|><|eols|><|endoftext|> | 9 |
lolphp | _vec_ | cdkjqb6 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>I almost said that the construction `mysqli_connect($db_url) or die();` is an acceptible use of `die()`, but then I realized that `mysqli_connect()` is also on the list.
It's a long list.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | midir | cdkwafm | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>As much as it sucks, report it. This way it will be added to the feature list.<|eor|><|sor|>This is discovered and rediscovered by people regularly. It's been reported many times. The PHP devs seem to consider it a feature rather than a bug.
It's still awful, but it is [warned about](http://www.php.net/manual/en/control-structures.foreach.php) in the manual that you should immediately `unset` after `foreach`ing by reference.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | hylje | cdl4or2 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>[deleted]<|eor|><|sor|>> Don't reuse variable names unnecessarily
you look at this and your reaction is ... what, exactly? That they'd be better off with
foreach($items as &$item) { ...
foreach($items as $item_) { ...
or something? I seriously would not expect `$item` to mean anything once the block ends.<|eor|><|sor|>[deleted]<|eor|><|sor|>Short, nondescript names like `$i` are fine if they are only used in the local context which establishes them. They only become incomprehensible when they leak out and lose any context that would otherwise identify their meaning.<|eor|><|eols|><|endoftext|> | 8 |
lolphp | more_exercise | cdlz3pa | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>Working with perl, it makes me sad that `die()` isn't a more acceptable method of error handling. `or die()` is just so goddamn poetic.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | MrZander | cdl2xcd | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>I almost said that the construction `mysqli_connect($db_url) or die();` is an acceptible use of `die()`, but then I realized that `mysqli_connect()` is also on the list.
It's a long list.<|eor|><|sor|>Why is mysqli_connect on the list?<|eor|><|sor|>because pdo?<|eor|><|sor|>Can I get a real answer? I'm honestly curious. Just because PDO is better? Or are there actual issues with mysqli?<|eor|><|eols|><|endoftext|> | 6 |
lolphp | jercos | cdnancr | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>What's @func?
Edit - it silences any errors or notices that are raised. Why would you do that!?<|eor|><|sor|>[deleted]<|eor|><|sor|>Seems like a bad design, but that might not be your fault. Why would you unserialize twice though?<|eor|><|sor|>[deleted]<|eor|><|sor|>Well, given passing untrusted data into unserialize can result in executing code, you know if the value is serialized because you should only ever unserialize something you serialized yourself. If you're passing data into unserialize without knowing if you serialized it, you're doing it wrong. If you're not, then unserialize failing should be an error.
P.S. don't keep your data in the database in blobs. :|<|eor|><|eols|><|endoftext|> | 6 |
lolphp | rustyshaklferd | cdlysy6 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>I almost said that the construction `mysqli_connect($db_url) or die();` is an acceptible use of `die()`, but then I realized that `mysqli_connect()` is also on the list.
It's a long list.<|eor|><|sor|>Why is mysqli_connect on the list?<|eor|><|sor|>because pdo?<|eor|><|sor|>Can I get a real answer? I'm honestly curious. Just because PDO is better? Or are there actual issues with mysqli?<|eor|><|sor|>Well from personal experience, if you're using mysqli there's a good chance your code isn't set up very well for development/unit testing. Being able to drop in a sqlite database in place of a beta or prod mysql instance for development and unit testing is really useful.
That and everyone seems to be on an anti-mysql bandwagon lately in favor of mariadb and postgres.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | _vec_ | cdmqtyb | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>Working with perl, it makes me sad that `die()` isn't a more acceptable method of error handling. `or die()` is just so goddamn poetic.<|eor|><|sor|>I miss it too, but there's a subtle but important difference between perl and PHP here. in perl (and everyplace else that isn't PHP) `and` and `or` return the last executed value, so it works like this:
$var = 'truthy' or die();
$var eq 'truthy'
In PHP, they return a literal `true` or `false`, so the same code results in the following
$var = 'truthy' or die();
$var === true
That means that in PHP, useful looking constructions like the following break in nonobvious ways.
$conf = Configuration::load() or die();
`$conf` is equal to `true`, the `die()` will not execute, and best of all because PHP coerces `true` into an empty array, `$conf['anything']` will return `NULL` without any warning.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | MrZander | cdkvfdc | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>You can add `or die()` to that list.<|eor|><|sor|>I almost said that the construction `mysqli_connect($db_url) or die();` is an acceptible use of `die()`, but then I realized that `mysqli_connect()` is also on the list.
It's a long list.<|eor|><|sor|>Why is mysqli_connect on the list?<|eor|><|eols|><|endoftext|> | 5 |
lolphp | gerrywastaken | cdl0q73 | <|sols|><|sot|>What I found out debugging a piece of code that should have worked<|eot|><|sol|>http://codepad.org/fbAPhlTp<|eol|><|sor|>Can somebody please explain what's going on here? I am at a total loss for how that could happen.<|eor|><|sor|>[deleted]<|eor|><|sor|>This is why `&$var` is only slightly below `@func()` on the list of constructions that will singlehandedly cause me to reject a code review.<|eor|><|sor|>What's @func?
Edit - it silences any errors or notices that are raised. Why would you do that!?<|eor|><|sor|>Because the user doesn't want any errors in his output stream, silly.<|eor|><|sor|>The day spent tracking down the issue is a problem for the next guy.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | koro666 | 1p2iu2 | <|sols|><|sot|>PHP Manual Masterpieces<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/<|eol|><|eols|><|endoftext|> | 57 |
lolphp | infinull | ccy5itp | <|sols|><|sot|>PHP Manual Masterpieces<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/<|eol|><|sor|>This is gold, I'm learning so many more reasons to hate PHP.
I'd like to take a moment to quote my favorite parts:
> Dear language designer, pick one:
> * A language with a very casual typing system;
> * A language with standard API functions that cannot return an error indicating incompatible types were passed at runtime.
> NOT BOTH. YOU CANT HAVE BOTH.
---
> You can easily cut yourself on the standard API of many languages. The difference is that languages like C are labeled sharp knife and PHP is labeled child-safe scissors. Cutting yourself should not be this easy.
> Dear sweet merciful angels I want to stab this language, twist the knife, yank out its still-beating heart and smash it against a rock.
> ( 0xabad1dea OUT.
---
> These are both lovely and sensible ways to delineate control structures. Having both in the same programming language, however, is madness.
> Did you know that mixing these two styles in close proximity can result in baffling errors, even if theyre nested scopes that seem conceptually separate?
> Did you know that the brace style accepts both elseif and else if, but colon style only accepts elseif?
(for the record `if {} else if {} else {}` etc. is for code not mixed with html and `<?php if ... :?> ... <? elseif: ?> ... <?php endif; ?> is for template-like code that intermixes html (it's still terrible that both exist)
---
> When your language manual straight-up has a page called Type Juggling, youre gonna have a bad time.
True dat
---
> You know what? It took me a really long time to work out how PHP arrived at this bizarre result. Now I would have supposed that the concatenation operator would be either higher or lower than the subtraction operator, depending on the mood of the language designer, but to my surprise, in PHP they have the same precedence, meaning we fall back on the left-to-right rule.This means we have:<|eor|><|eols|><|endoftext|> | 18 |
lolphp | infinull | ccy9vko | <|sols|><|sot|>PHP Manual Masterpieces<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/<|eol|><|sor|>This is gold, I'm learning so many more reasons to hate PHP.
I'd like to take a moment to quote my favorite parts:
> Dear language designer, pick one:
> * A language with a very casual typing system;
> * A language with standard API functions that cannot return an error indicating incompatible types were passed at runtime.
> NOT BOTH. YOU CANT HAVE BOTH.
---
> You can easily cut yourself on the standard API of many languages. The difference is that languages like C are labeled sharp knife and PHP is labeled child-safe scissors. Cutting yourself should not be this easy.
> Dear sweet merciful angels I want to stab this language, twist the knife, yank out its still-beating heart and smash it against a rock.
> ( 0xabad1dea OUT.
---
> These are both lovely and sensible ways to delineate control structures. Having both in the same programming language, however, is madness.
> Did you know that mixing these two styles in close proximity can result in baffling errors, even if theyre nested scopes that seem conceptually separate?
> Did you know that the brace style accepts both elseif and else if, but colon style only accepts elseif?
(for the record `if {} else if {} else {}` etc. is for code not mixed with html and `<?php if ... :?> ... <? elseif: ?> ... <?php endif; ?> is for template-like code that intermixes html (it's still terrible that both exist)
---
> When your language manual straight-up has a page called Type Juggling, youre gonna have a bad time.
True dat
---
> You know what? It took me a really long time to work out how PHP arrived at this bizarre result. Now I would have supposed that the concatenation operator would be either higher or lower than the subtraction operator, depending on the mood of the language designer, but to my surprise, in PHP they have the same precedence, meaning we fall back on the left-to-right rule.This means we have:<|eor|><|sor|>I didn't read it all as it got boring and it sounded like the same old dead horse being beaten to some degree, but I found myself wondering why so much hate.
Now don't get me wrong. PHP can suck a fat one most days. But if your coding practices are such that you want to do bizarre shit like mixing styles of 'if else if' then why is that the fault of the language? It sounds like this guy really wants PHP to do things how he wants it to do thing, instead of him doing things the way they are meant to be done. You have your choices, now pick one and stick to it. Just because you WANT to mix and match doesn't mean you CAN or SHOULD. In fact, I'd want to punch anyone who attempted to do such a thing, or create obscure if else blocks. It only makes for making it more difficult to read and debug and becomes more error-prone.
The strcmp issue I don't get either. Why would you use that function? I would have expected === in that situation. Granted, === to me is the same poor situation as = versus == which can screw you over within an if test when you miss-key.
And isset does what isset does. It's whole purpose is to check for a specifically defined variable name, as though you are reaching down inside the guts of the php system and digging in its stomach for a very specific thing. It wasn't meant for PHP's typical kludginess where you can magically create something out of thin-air.
Maybe I've been looking at too much PHP lately and have crossed-over to the dark side. There's always plenty to hate, but the stuff mentioned really does seem to me to be issues with the coder and not the language. Should I see a doctor and get checked for a brain tumor?<|eor|><|sor|>to quote the author:
> When I shared this on Twitter, legions of people showed up to say it was the programmers fault for using strcmp(). Riddle me this: is strcmp() part of the standard PHP API? Yes. Is it deprecated? No. Are there any caution notes in the official documentation? No. I dont care how hard you try to blame the programmer, this is fundamentally bad language design. Its a trap.
You can write perfectly legible, maintainable code in PHP, Facebook is quick to point this out with all their projects to make PHP faster, but it's more difficult than in languages like Python which care about there being one correct way to do things (or least trying make as many incorrect ways not easy to write in the language).
PHP's problems come from many places, bad initial design, bad current maintainers, and users too uneducated to know what they want from their designers/maintainers. PHP has made progress, and programmers who know what they are doing can be very productive in it, and the deployment and concurrency models of PHP provide some nifty benefits, but it's really hard to describe PHP as "good."<|eor|><|eols|><|endoftext|> | 10 |
lolphp | infinull | ccyaht8 | <|sols|><|sot|>PHP Manual Masterpieces<|eot|><|sol|>http://phpmanualmasterpieces.tumblr.com/<|eol|><|sor|>This is gold, I'm learning so many more reasons to hate PHP.
I'd like to take a moment to quote my favorite parts:
> Dear language designer, pick one:
> * A language with a very casual typing system;
> * A language with standard API functions that cannot return an error indicating incompatible types were passed at runtime.
> NOT BOTH. YOU CANT HAVE BOTH.
---
> You can easily cut yourself on the standard API of many languages. The difference is that languages like C are labeled sharp knife and PHP is labeled child-safe scissors. Cutting yourself should not be this easy.
> Dear sweet merciful angels I want to stab this language, twist the knife, yank out its still-beating heart and smash it against a rock.
> ( 0xabad1dea OUT.
---
> These are both lovely and sensible ways to delineate control structures. Having both in the same programming language, however, is madness.
> Did you know that mixing these two styles in close proximity can result in baffling errors, even if theyre nested scopes that seem conceptually separate?
> Did you know that the brace style accepts both elseif and else if, but colon style only accepts elseif?
(for the record `if {} else if {} else {}` etc. is for code not mixed with html and `<?php if ... :?> ... <? elseif: ?> ... <?php endif; ?> is for template-like code that intermixes html (it's still terrible that both exist)
---
> When your language manual straight-up has a page called Type Juggling, youre gonna have a bad time.
True dat
---
> You know what? It took me a really long time to work out how PHP arrived at this bizarre result. Now I would have supposed that the concatenation operator would be either higher or lower than the subtraction operator, depending on the mood of the language designer, but to my surprise, in PHP they have the same precedence, meaning we fall back on the left-to-right rule.This means we have:<|eor|><|sor|>I didn't read it all as it got boring and it sounded like the same old dead horse being beaten to some degree, but I found myself wondering why so much hate.
Now don't get me wrong. PHP can suck a fat one most days. But if your coding practices are such that you want to do bizarre shit like mixing styles of 'if else if' then why is that the fault of the language? It sounds like this guy really wants PHP to do things how he wants it to do thing, instead of him doing things the way they are meant to be done. You have your choices, now pick one and stick to it. Just because you WANT to mix and match doesn't mean you CAN or SHOULD. In fact, I'd want to punch anyone who attempted to do such a thing, or create obscure if else blocks. It only makes for making it more difficult to read and debug and becomes more error-prone.
The strcmp issue I don't get either. Why would you use that function? I would have expected === in that situation. Granted, === to me is the same poor situation as = versus == which can screw you over within an if test when you miss-key.
And isset does what isset does. It's whole purpose is to check for a specifically defined variable name, as though you are reaching down inside the guts of the php system and digging in its stomach for a very specific thing. It wasn't meant for PHP's typical kludginess where you can magically create something out of thin-air.
Maybe I've been looking at too much PHP lately and have crossed-over to the dark side. There's always plenty to hate, but the stuff mentioned really does seem to me to be issues with the coder and not the language. Should I see a doctor and get checked for a brain tumor?<|eor|><|sor|>to quote the author:
> When I shared this on Twitter, legions of people showed up to say it was the programmers fault for using strcmp(). Riddle me this: is strcmp() part of the standard PHP API? Yes. Is it deprecated? No. Are there any caution notes in the official documentation? No. I dont care how hard you try to blame the programmer, this is fundamentally bad language design. Its a trap.
You can write perfectly legible, maintainable code in PHP, Facebook is quick to point this out with all their projects to make PHP faster, but it's more difficult than in languages like Python which care about there being one correct way to do things (or least trying make as many incorrect ways not easy to write in the language).
PHP's problems come from many places, bad initial design, bad current maintainers, and users too uneducated to know what they want from their designers/maintainers. PHP has made progress, and programmers who know what they are doing can be very productive in it, and the deployment and concurrency models of PHP provide some nifty benefits, but it's really hard to describe PHP as "good."<|eor|><|sor|>Woops, did I say php was 'good'? I don't think I did, but mistakes do happen.
There's a lot of crap in PHP, and a lot to hate. I just don't feel what the author writes is necessarily fair. If you try to go about things the wrong way just because a language allows you to go down that path doesn't make the language at fault.
It feels to me as though, for example, it's like the author is blaming the language for allowing you to store numbers in a string and then getting bitten when some evaluation reads the string as an octal, when instead the coder should have been assigning actual int values from the start. You do the wrong thing, just because it's possible, then get bit in the ass for doing so.
The author mentions there being no caution notes. You can't caution people against all possible problems. Some intelligence has to be brought to the table. When people are getting tripped-up on the basics like operator precedence, which is documented, then I find it hard to swallow complaints like what the author gave.
But, that's just me and my opinion. Tomorrow I might hate PHP with a passion and damn it to hell and be in full agreement with the author.<|eor|><|sor|>Honestly, I think this is one of the least harsh criticisms I've seen on this board in a while, it's significantly less harsh than say "A Fractal of Bad Design"
0xabad1dea (the author) shows both sides, he sees where the designers were coming from, but argues that it would be confusing to developers. I think you have to take a step back and ask if a design violates the principle of least surprise. I think overall, that is what PHP lacks from a design perspective. Designers did what made sense to them and didn't look at the big picture.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | stesch | 5egi6u | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|eols|><|endoftext|> | 58 |
lolphp | Matt3k | dace9qj | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>That looks like proper parsing of a CSV line to me.
I realize CSV isn't exactly an ISO standard, but most parsers / writers would output such a string as:
"A", "Some ""Stuff""", "C"
I have never seen a CSV format that escapes delimiters with a backslash. That sounds like a PHP-ism.
But yes, if you specify a different escape mechanism, it should obviously remove that character. How odd.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | armornick | daca24c | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>You could possibly say that this works as intended since the bug description implies that escape characters should only be removed if the next character is the delimiter.
Not intuitive, though, and it works differently from every other CSV parser in any other language.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Banane9 | danhy52 | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>BTW: Most programs don't output CSV correctly aswell. Microsoft Products use ";" as a field separator. Did they know what the fucking **C** in **C**VS stands for?<|eor|><|sor|>Well, C could stand for comma or colon, so they just covered all their bases! ;)<|eor|><|eols|><|endoftext|> | 7 |
lolphp | caffeinep0wered | dackit9 | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>So fix it. PHP is open source. Just look at all those useless complainers.<|eor|><|sor|>You're right, but you realise this is the PHP anti-circlejerk subreddit, right<|eor|><|eols|><|endoftext|> | 7 |
lolphp | ZiggyTheHamster | dacnvi9 | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>That looks like proper parsing of a CSV line to me.
I realize CSV isn't exactly an ISO standard, but most parsers / writers would output such a string as:
"A", "Some ""Stuff""", "C"
I have never seen a CSV format that escapes delimiters with a backslash. That sounds like a PHP-ism.
But yes, if you specify a different escape mechanism, it should obviously remove that character. How odd.<|eor|><|sor|>Some CSV-writing applications use `\"` to escape a double quote and `\\` to escape a backslash (Postgres is a good example I can think of, where it also does `\N` for null).<|eor|><|eols|><|endoftext|> | 6 |
lolphp | iftpadfs | dajj4ll | <|sols|><|sot|>PHP can't parse CSV correctly. Bug open since 2011.<|eot|><|sol|>https://bugs.php.net/bug.php?id=55413<|eol|><|sor|>BTW: Most programs don't output CSV correctly aswell. Microsoft Products use ";" as a field separator. Did they know what the fucking **C** in **C**VS stands for?<|eor|><|eols|><|endoftext|> | 5 |
lolphp | the_alias_of_andrea | 3xfhwr | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|eols|><|endoftext|> | 54 |
lolphp | DCoder1337 | cy4e2p2 | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|sor|>It seems odd, too, that the comment says that PHP 5.5 is already relegated to security patches only. Didn't PHP 7 only come out a few weeks ago? Why have they *already* essentially abandoned the 5.x line?<|eor|><|sor|>5.5 != 5.x line. The lifecycles for various versions are documented at https://secure.php.net/supported-versions.php<|eor|><|eols|><|endoftext|> | 19 |
lolphp | theevildjinn | cy4pm1b | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|sor|>It seems odd, too, that the comment says that PHP 5.5 is already relegated to security patches only. Didn't PHP 7 only come out a few weeks ago? Why have they *already* essentially abandoned the 5.x line?<|eor|><|sor|>Because PHP 5.6.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | myaut | cy4f2fw | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|sor|>3v4l for code in bug: https://3v4l.org/7vYoX<|eor|><|eols|><|endoftext|> | 10 |
lolphp | coredumperror | cy4puni | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|sor|>It seems odd, too, that the comment says that PHP 5.5 is already relegated to security patches only. Didn't PHP 7 only come out a few weeks ago? Why have they *already* essentially abandoned the 5.x line?<|eor|><|sor|>Because PHP 5.6.<|eor|><|sor|>I've been stuck on PHP 5.3 for years, due to hosting constraints, so I wasn't even aware of PHP 5.6. I'm guessing this problem was already fixed on 5.6, or the commenter would have mentioned that.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | the_alias_of_andrea | cy4wvp3 | <|sols|><|sot|>PHP :: Bug #70517 :: isset() on string produces invalid result<|eot|><|sol|>https://bugs.php.net/bug.php?id=70517<|eol|><|sor|>It seems odd, too, that the comment says that PHP 5.5 is already relegated to security patches only. Didn't PHP 7 only come out a few weeks ago? Why have they *already* essentially abandoned the 5.x line?<|eor|><|sor|>Because PHP 5.6.<|eor|><|sor|>I've been stuck on PHP 5.3 for years, due to hosting constraints, so I wasn't even aware of PHP 5.6. I'm guessing this problem was already fixed on 5.6, or the commenter would have mentioned that.<|eor|><|soopr|>It wasn't fixed on 5.6. They were just pointing out it's not going to get fixed on 5.5 and is already fixed in 7.0.<|eoopr|><|eols|><|endoftext|> | 6 |
lolphp | silvinci | 2anava | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|eols|><|endoftext|> | 53 |
lolphp | gu3st12 | ciwv1x7 | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>It's a bit easier instead of pointing out a specific line in WP as a WTF moment, to simply point out all of WP. There's ssome obscene mess of if elses somewhere in there
<|eor|><|eols|><|endoftext|> | 27 |
lolphp | allthediamonds | ciwymqx | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|eols|><|endoftext|> | 19 |
lolphp | jb2386 | ciww2vu | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>This is a lolwordpress not lolphp<|eor|><|eols|><|endoftext|> | 18 |
lolphp | tdammers | ciwxaor | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>This is a lolwordpress not lolphp<|eor|><|sor|>Except that drupal, magento, mediawiki, and most any other popular PHP project I've seen so far is approximately equally shitty, as far as code quality is concerned. Phabricator is a notable exception, but I believe that one has a somewhat sane codebase *despite* PHP, not because of it; the folks who made it (bunch of Facebook people IIRC) have made a heroic effort, and if you read the code carefully, you'll see them indirectly apologize for PHP in the comments.<|eor|><|eols|><|endoftext|> | 11 |
lolphp | _vec_ | cixe31i | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>It's a bit easier instead of pointing out a specific line in WP as a WTF moment, to simply point out all of WP. There's ssome obscene mess of if elses somewhere in there
<|eor|><|sor|>Let's compare it to code you wrote 10 years ago and see how it does. ;)
EDIT: Lots of people failing to realize how old this code is and that rewriting it just to be pretty and better match modern OOP standards would break many sites. The WordPress developers aren't dumb. Backwards compatibility is more important than pretty code.<|eor|><|sor|>Agreed. People are too quick to judge code bases. We don't know the time pressures, restrictions, etc that were on the developer when the code was written. It's just usually not worth the effort to rewrite it merely to make it pure to the eyes. Maybe instead of bitching about code, people should fix it and post real lolphps, not lolwordpress.<|eor|><|sor|>>> Let's compare it to code you wrote 10 years ago and see how it does. ;)
The code I wrote 10 years ago doesn't run [almost a fifth of the public internet](http://venturebeat.com/2013/07/27/19-percent-of-the-web-runs-on-wordpress/).
> We don't know the time pressures, restrictions, etc that were on the developer when the code was written.
I don't care about the pressure the devs were under. When your software is responsible for tens of millions of sites I expect you to get it right. And the problem isn't that the code is ugly and badly named (although it is); the problem is that there are performance problems collecting debugging information during imports and some developer thought this was an acceptable solution.
> Maybe instead of bitching about code, people should fix it
The problem is that people still consider Wordpress to be the default choice for making a new site. And no small number of developers end up lashing themselves to PHP primarily because it's what Wordpress happens to be written in.
There are much better tools, and if "bitching about code" helps encourage people to switch to them then both our profession and the web will be happier places.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | captainramen | cixn9ax | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>It's a bit easier instead of pointing out a specific line in WP as a WTF moment, to simply point out all of WP. There's ssome obscene mess of if elses somewhere in there
<|eor|><|sor|>Let's compare it to code you wrote 10 years ago and see how it does. ;)
EDIT: Lots of people failing to realize how old this code is and that rewriting it just to be pretty and better match modern OOP standards would break many sites. The WordPress developers aren't dumb. Backwards compatibility is more important than pretty code.<|eor|><|sor|>Agreed. People are too quick to judge code bases. We don't know the time pressures, restrictions, etc that were on the developer when the code was written. It's just usually not worth the effort to rewrite it merely to make it pure to the eyes. Maybe instead of bitching about code, people should fix it and post real lolphps, not lolwordpress.<|eor|><|sor|>>> Let's compare it to code you wrote 10 years ago and see how it does. ;)
The code I wrote 10 years ago doesn't run [almost a fifth of the public internet](http://venturebeat.com/2013/07/27/19-percent-of-the-web-runs-on-wordpress/).
> We don't know the time pressures, restrictions, etc that were on the developer when the code was written.
I don't care about the pressure the devs were under. When your software is responsible for tens of millions of sites I expect you to get it right. And the problem isn't that the code is ugly and badly named (although it is); the problem is that there are performance problems collecting debugging information during imports and some developer thought this was an acceptable solution.
> Maybe instead of bitching about code, people should fix it
The problem is that people still consider Wordpress to be the default choice for making a new site. And no small number of developers end up lashing themselves to PHP primarily because it's what Wordpress happens to be written in.
There are much better tools, and if "bitching about code" helps encourage people to switch to them then both our profession and the web will be happier places.<|eor|><|sor|>The code I wrote 10 years ago would have been continually refactored if it were still in production. No excuse for this.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | _vec_ | cix8azy | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>Worth noting that `$wpdb->queries` is a "log" variable. It stores a record of every query made during that request. This depresses me for a number of reasons
1. You're logging to a variable?! Instead of, y'know, an actual log? It's not like opening a log file and shoving strings onto the end of it was a new and radical concept when WP was written.
2. How many queries does an import take? 1000 posts + ~100 comments per post + metadata should still be well south of 200k INSERT statements. Can the PHP runtime really not handle an array of 200k strings?
3. When the debugging information becomes a performance problem the solution is to **silently discard debugging information**?! Not to fix the debugging. Not to disable the feature entirely (with or without a useful warning). Not even to explode and die until debugging is manually disabled. No, they choose to truncate the data mid-request without any kind of notice that the final log isn't usable.
As someone who occasionally has to use Wordpress this actually makes me angry. It's one more piece of evidence that WP devs don't care about non-amateurs. "Want to write a fancy theme? Great, it's mostly just HTML! Want to distribute that theme? Sure; we've got a community site and installation can be done through our shiny UI! Want to make sure your theme is efficient and bug-free? Go fuck yourself!"
/rant<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Viper007Bond | cixm7ks | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|>Maybe it's used like this:
$timeout += bump_request_timeout($timeout);
I guess...<|eor|><|sor|>It's a callback function.
Explanation here: http://www.reddit.com/r/lolphp/comments/2anava/stop_the_insanity/cixm4if<|eor|><|eols|><|endoftext|> | 8 |
lolphp | wvenable | ciysa6i | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|> return 60
Magic numbers. Yum.<|eor|><|sor|>Here, I fixed it for you:
return INT_SIXTY;
<|eor|><|eols|><|endoftext|> | 8 |
lolphp | nidarus | cixc2jr | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|> return 60
Magic numbers. Yum.<|eor|><|sor|>It basically the opposite of a magic number, and it's more flexible than the usual solution to magic numbers, constants. <|eor|><|sor|>> more flexible
How is a hardcoded integer flexible at all?<|eor|><|sor|>That's the point, it's not hardcoded. The whole point of the function is to provide a symbol instead of that number. This is basically equivalent to define('bump_request_timeout', 60), but you could override it with something that performs more complex logic.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | allthediamonds | cizes3t | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>It's a bit easier instead of pointing out a specific line in WP as a WTF moment, to simply point out all of WP. There's ssome obscene mess of if elses somewhere in there
<|eor|><|sor|>Let's compare it to code you wrote 10 years ago and see how it does. ;)
EDIT: Lots of people failing to realize how old this code is and that rewriting it just to be pretty and better match modern OOP standards would break many sites. The WordPress developers aren't dumb. Backwards compatibility is more important than pretty code.<|eor|><|sor|>Software architecture existed ten years ago. Good code patterns existed ten years ago. Languages that were not PHP existed ten years ago.
This is not a valid excuse, nor was it ten years ago.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | svtguy88 | cixcd6v | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|> return 60
Magic numbers. Yum.<|eor|><|sor|>> "some non-obvious constant whose value [...] inserted inconspicuously in-line (hardcoded), **rather than expanded in by a symbol** [...]"
> -- ["Magic Number", Jargon File](http://www.catb.org/jargon/html/M/magic-number.html), emphasis added
This is not a magic number.<|eor|><|sor|>Sure, there is a function instead of just using the integer "60" all over the code, but it's still not documented, and, upon first glance, does nothing. If I were to go back and try to debug this code, a function simply returning an integer (that works magic) would confuse the shit out of me.
Is it a "magic number" by definition? I *guess* not, but it's still shit code.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Viper007Bond | cixm4if | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|>...what, what point is the parameter!?
What point, I ask!<|eor|><|sor|>Because it's filtering (modifying) a value. By default it doesn't care with the previous value is and overwrites it with the new value. However you could just as easily have it double the current value or whatever you wanted.<|eor|><|sor|>No it's not. It returns 60, and does nothing to $val. The calling code would be responsible for updating their variable with the return value.<|eor|><|sor|>The `bump_request_timeout()` method is registered as a callback function:
https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L181-182
That means it ends up getting called here to modify the default timeout:
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-http.php#L80
The callback function is passed a parameter that is the current timeout value (5 by default, but could be something else as you can register multiple callbacks). While `$val` is not used in this particular case, it's best practice to make callback functions accept all variables that are passed to it.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | svtguy88 | cixca3d | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|> return 60
Magic numbers. Yum.<|eor|><|sor|>It basically the opposite of a magic number, and it's more flexible than the usual solution to magic numbers, constants. <|eor|><|sor|>> more flexible
How is a hardcoded integer flexible at all?<|eor|><|sor|>That's the point, it's not hardcoded. The whole point of the function is to provide a symbol instead of that number. This is basically equivalent to define('bump_request_timeout', 60), but you could override it with something that performs more complex logic.<|eor|><|sor|>I come from a very config-driven background - I find this to be just about equivalent to hardcoding.
Sure, it's a step above littering the code with the integer "60" everywhere that this function is used, however, it's still just adding some arbitrary value. At the very least, it could be documented and explained a little. Adding seemingly random numbers is a good way to make sure no one else can debug your code...<|eor|><|eols|><|endoftext|> | 6 |
lolphp | svtguy88 | cixafuw | <|sols|><|sot|>stop_the_insanity()<|eot|><|sol|>https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-importer.php#L237<|eol|><|sor|>`/**`
`* Bump up the request timeout for http requests`
`*`
`* @param int $val `
`* @return int`
`*/`
`public function bump_request_timeout( $val ) {`
`return 60;`
`}`
Uh... what?<|eor|><|sor|> return 60
Magic numbers. Yum.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Greg_war | j28e6r | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|eoss|><|endoftext|> | 57 |
lolphp | Greg_war | g73xv7w | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
In the first loop, the iteration variable is passed as a reference to the array element. In PHP the loop variable is not scoped inside the loop scope, so when the loop is done, the $var variable is still accessible in the outer scope.
Since the variable is a reference, mutating it will actually modify the original array element.
When the next loop is executed, since the variable is available in the outer scope of the loop, it actually mutates the reference.
Yeah, it's crazy.<|eor|><|soopr|>Yes, actually this is IMO the combination of two broken things.
First the scope of variables created in foreach should ideally be only in the foreach itself. We can arguably propose some code that take advantage of that but I dont think it would be considered as good practise.
Then the "as" of the last foreach here should semantically not be like assigning into the existing reference, does'nt make any sense in any legitimate use, I would expect it to ensure its a new variable in any case.<|eoopr|><|eoss|><|endoftext|> | 24 |
lolphp | djxfade | g73xf2j | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
In the first loop, the iteration variable is passed as a reference to the array element. In PHP the loop variable is not scoped inside the loop scope, so when the loop is done, the $var variable is still accessible in the outer scope.
Since the variable is a reference, mutating it will actually modify the original array element.
When the next loop is executed, since the variable is available in the outer scope of the loop, it actually mutates the reference.
Yeah, it's crazy.<|eor|><|eoss|><|endoftext|> | 19 |
lolphp | comrade_donkey | g746nvy | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>A true lolphp. Holy shit.<|eor|><|eoss|><|endoftext|> | 17 |
lolphp | Miserable_Fuck | g749o4j | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
In the first loop, the iteration variable is passed as a reference to the array element. In PHP the loop variable is not scoped inside the loop scope, so when the loop is done, the $var variable is still accessible in the outer scope.
Since the variable is a reference, mutating it will actually modify the original array element.
When the next loop is executed, since the variable is available in the outer scope of the loop, it actually mutates the reference.
Yeah, it's crazy.<|eor|><|sor|>> This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
All of PHP's idiosyncrasies make sense to the people who are sufficiently familiar with it.<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | elcapitanoooo | g7582ph | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
In the first loop, the iteration variable is passed as a reference to the array element. In PHP the loop variable is not scoped inside the loop scope, so when the loop is done, the $var variable is still accessible in the outer scope.
Since the variable is a reference, mutating it will actually modify the original array element.
When the next loop is executed, since the variable is available in the outer scope of the loop, it actually mutates the reference.
Yeah, it's crazy.<|eor|><|sor|>That is wrong on so many levels! Who on earth would want it work like this?<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | Greg_war | g75bnos | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>Broken by design. This is why so many leave PHP and never look back. As trends show PHP has been on a massive decline for the last 6-8 years.<|eor|><|soopr|>I agree that this is broken but about PHP decline, I would be interrested in some factual figures about that
For instance this w3tech report doesnt reflect a huge drop on PHP use (I know it is biased in many ways but that is factual) for the last 10 yrars it is quite steady, arguably even increasing
https://w3techs.com/technologies/history_overview/programming_language/ms/y<|eoopr|><|eoss|><|endoftext|> | 6 |
lolphp | Greg_war | g75bw7v | <|soss|><|sot|>Tutorial: replace the last item of an array<|eot|><|sost|> <?php
$array = [1, 2, 3];
foreach ($array as &$var) {}
foreach ([9] as $var) {}
echo $array[2]; // 9<|eost|><|sor|>This looks crazy, but actually makes some kind of sense if you know how PHP scopes variables.
In the first loop, the iteration variable is passed as a reference to the array element. In PHP the loop variable is not scoped inside the loop scope, so when the loop is done, the $var variable is still accessible in the outer scope.
Since the variable is a reference, mutating it will actually modify the original array element.
When the next loop is executed, since the variable is available in the outer scope of the loop, it actually mutates the reference.
Yeah, it's crazy.<|eor|><|soopr|>Yes, actually this is IMO the combination of two broken things.
First the scope of variables created in foreach should ideally be only in the foreach itself. We can arguably propose some code that take advantage of that but I dont think it would be considered as good practise.
Then the "as" of the last foreach here should semantically not be like assigning into the existing reference, does'nt make any sense in any legitimate use, I would expect it to ensure its a new variable in any case.<|eoopr|><|sor|>I have fallen into this trap many times before. That is why I always explicitly set the loop variable as NULL before a loop<|eor|><|soopr|>When I saw that I actually opened a bug report on PHP and they told me this was expected behaviour, and that there is a warning about that on the foreach manual
https://www.php.net/manual/en/control-structures.foreach.php
This seems like it was easier to document it than fix it, even though I see no legitimate use of assigning something using foreach with a reference after "as" :'-)<|eoopr|><|eoss|><|endoftext|> | 5 |
lolphp | hashkitten | cssext | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|eols|><|endoftext|> | 52 |
lolphp | shaql | exh06ov | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>Wat.
I remember a similar thread, https://www.reddit.com/r/lolphp/comments/pi1gy/php_silently_converts_any_spaces_in_field_names/ , and at first I thought it's the same... Nope, it's yet another layer of lolphp. How deep can this go?!<|eor|><|eols|><|endoftext|> | 15 |
lolphp | Altreus | exhinmm | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>But the function returns an array. The reasoning behind the conversion doesn't even apply to the operation being performed.
But that's just more lolphp<|eor|><|eols|><|endoftext|> | 12 |
lolphp | shitcanz | exhe0s7 | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>Wat.
I remember a similar thread, https://www.reddit.com/r/lolphp/comments/pi1gy/php_silently_converts_any_spaces_in_field_names/ , and at first I thought it's the same... Nope, it's yet another layer of lolphp. How deep can this go?!<|eor|><|sor|>It goes deep. Real deep. I have found lols in so obscure places in PHP codebases its unreal.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | Altreus | exhhkud | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>The conversion happens because dots and spaces are not legal characters in an identifier (key name). The issue with the unmatched square bracket seems to be a bug.<|eor|><|sor|>But nobody is asking for identifiers.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | andsens | exhs59s | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>The conversion happens because dots and spaces are not legal characters in an identifier (key name). The issue with the unmatched square bracket seems to be a bug.<|eor|><|sor|>But nobody is asking for identifiers.<|eor|><|sor|>Note the title of this thread. The "query keys" in question are the identifiers.<|eor|><|sor|>You're wrong. The word "identifier" has a very specific meaning and array keys are definitely not identifiers ([here is some light reading](http://phpandshree.blogspot.com/2014/02/php-identifier-rules-and-variables.html)).
Proof:
> An identifier can consist of one or more characters and must begin with a letter or an underscore.
Which means [this shouldn't be possible](https://3v4l.org/hh5Cb).<|eor|><|eols|><|endoftext|> | 7 |
lolphp | the_alias_of_andrea | exiw57q | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>But the function returns an array. The reasoning behind the conversion doesn't even apply to the operation being performed.
But that's just more lolphp<|eor|><|sor|>> But the function returns an array.
Only if a second parameter is passed.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Altreus | exj147n | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>But the function returns an array. The reasoning behind the conversion doesn't even apply to the operation being performed.
But that's just more lolphp<|eor|><|sor|>> But the function returns an array.
Only if a second parameter is passed.<|eor|><|sor|>FUCK
I'm glad I'm here to laugh<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Altreus | exk65mz | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>The conversion happens because dots and spaces are not legal characters in an identifier (key name). The issue with the unmatched square bracket seems to be a bug.<|eor|><|sor|>But nobody is asking for identifiers.<|eor|><|sor|>>But nobody is asking for identifiers.
The docs say:
\> ...and sets variables in the current scope
So presumably identifiers are required to set variables, no?<|eor|><|sor|>For fuck's sake PHP<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Sam152 | exjsiku | <|sols|><|sot|>PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted<|eot|><|sol|>https://3v4l.org/aM984<|eol|><|sor|>The conversion happens because dots and spaces are not legal characters in an identifier (key name). The issue with the unmatched square bracket seems to be a bug.<|eor|><|sor|>But nobody is asking for identifiers.<|eor|><|sor|>>But nobody is asking for identifiers.
The docs say:
\> ...and sets variables in the current scope
So presumably identifiers are required to set variables, no?<|eor|><|eols|><|endoftext|> | 5 |
lolphp | FurriesRuinEverythin | 71ymfo | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|eols|><|endoftext|> | 56 |
lolphp | coredumperror | dnf7zyr | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|soopr|>These are my results from testing over and over again.
It is probably well known, but it is *not* in the documentation and it makes no sense for these inconsistencies. I think, either change the timestamp, or don't change it. Either offset the output from format(), or don't offset it. But don't make the cunting thing do it differently depending on when the timezone is set, and FFS, if you still decide you are going to do this bullshit, then fucking document it. FFS.<|eoopr|><|sor|>then add your work to the documentation
?
I did struggle with it too but you can help others by doing that :o
http://php.net/manual/add-note.php?sect=class.datetime&redirect=http://php.net/manual/en/class.datetime.php<|eor|><|sor|>Right, because the notes added to the PHP docs by random users on the internet are *soooo* reliable.
Hell, the fact that a comment section exists on the official PHP docs is a lolphp in and of itself.<|eor|><|eols|><|endoftext|> | 30 |
lolphp | FurriesRuinEverythin | dnedkla | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|soopr|>These are my results from testing over and over again.
It is probably well known, but it is *not* in the documentation and it makes no sense for these inconsistencies. I think, either change the timestamp, or don't change it. Either offset the output from format(), or don't offset it. But don't make the cunting thing do it differently depending on when the timezone is set, and FFS, if you still decide you are going to do this bullshit, then fucking document it. FFS.<|eoopr|><|eols|><|endoftext|> | 18 |
lolphp | SuperDK974 | dnejnim | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|soopr|>These are my results from testing over and over again.
It is probably well known, but it is *not* in the documentation and it makes no sense for these inconsistencies. I think, either change the timestamp, or don't change it. Either offset the output from format(), or don't offset it. But don't make the cunting thing do it differently depending on when the timezone is set, and FFS, if you still decide you are going to do this bullshit, then fucking document it. FFS.<|eoopr|><|sor|>then add your work to the documentation
?
I did struggle with it too but you can help others by doing that :o
http://php.net/manual/add-note.php?sect=class.datetime&redirect=http://php.net/manual/en/class.datetime.php<|eor|><|eols|><|endoftext|> | 15 |
lolphp | Various_Pickles | dnf5jgx | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|sor|>[Tom Scott described the issues with programming with timezones](https://www.youtube.com/watch?v=-5wpm-gesOY) better than I ever could.
Also, have fun working with Unix timestamps in PHP, the natural solution to avoiding timezones altogether: the output of microtime(false) does not match the output of microtime(true), and the latter is only as accurate during string conversion as the global hurr durr php.ini setting for float precision.
Working with time in PHP is like using your rectal cavity for storing lightbulbs.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | coredumperror | dnf80l3 | <|sols|><|sot|>PHP's DateTime inconsistent behaviour regarding timezones fucked my day and I spent more time than I care to admit testing until I could consistently reproduce its behaviours.<|eot|><|sol|>https://www.dropbox.com/s/2ah1nomu1i3l5ac/how%20not%20to%20get%20bitten%20by%20fucking%20shitty%20php%20dates.pdf?dl=0<|eol|><|sor|>[deleted]<|eor|><|sor|>Amen to that. pytz is a fucking godsend for python programmers.<|eor|><|eols|><|endoftext|> | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.