subreddit stringclasses 7
values | author stringlengths 3 20 | id stringlengths 5 7 | content stringlengths 67 30.4k | score int64 0 140k |
|---|---|---|---|---|
lolphp | Rhomboid | cywvzb0 | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>Handling of disparate memory types types should throw warnings at the *very* least. Not silently give a meaningless output. <|eor|><|sor|>NaN is a numeric type, the same as 3 and 7. It works this way in nearly all other languages, including C, C++, Java, C#, Python, etc. It is in no way a PHP-specific thing.
<|eor|><|eols|><|endoftext|> | 18 |
lolphp | phoshi | cywvtkw | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>No, it's a LOL. Either the sort should treat NAN in a consistent (and detectable) way, or the sort function should throw an error or otherwise show an error has occurred. Pretending to sort the array, essentially returning random garbage, is the worse case scenario here.
<|eor|><|sor|>You could perhaps make a case that you shouldn't be able to compare a number to NaN, as in the case of Ruby. But that should be a property of the types themselves, not of the sort algorithm. The sort algorithm should have no idea of the semantics of the types it's working with, only that it will attempt to use less-than to order them. If less-than raises an error, then the sort is a malformed operation, but if not, then it's no business of the sort algorithm to inquire further. The sort algorithm should work for any type with a less-than operator that implements a strict weak ordering, and it should have no special knowledge beyond that. You can't expect the sort algorithm to diagnose when the user has violated those requirements, because it's impossible in the general case. For example, C++'s `std::sort()` has the same requirement and the implementation has absolutely no responsibility to detect when you've managed to violate the requirement, the result is simply undefined behavior.
<|eor|><|sor|>Because you know, transitivity is not very important.
And also, comparing a number to a Nan is ok, no null returned or exception thrown.
lolphp<|eor|><|sor|>Also lol many other languages, and the floating point spec, however. PHP implementing external insanity isn't php's fault, even if it's insane. <|eor|><|eols|><|endoftext|> | 16 |
lolphp | maweki | cywojex | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>The more important issue is, that sort still returned true in this case
https://3v4l.org/mDALu<|eor|><|eols|><|endoftext|> | 15 |
lolphp | yawkat | cyx7xe8 | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>No, it's a LOL. Either the sort should treat NAN in a consistent (and detectable) way, or the sort function should throw an error or otherwise show an error has occurred. Pretending to sort the array, essentially returning random garbage, is the worse case scenario here.
<|eor|><|sor|>You could perhaps make a case that you shouldn't be able to compare a number to NaN, as in the case of Ruby. But that should be a property of the types themselves, not of the sort algorithm. The sort algorithm should have no idea of the semantics of the types it's working with, only that it will attempt to use less-than to order them. If less-than raises an error, then the sort is a malformed operation, but if not, then it's no business of the sort algorithm to inquire further. The sort algorithm should work for any type with a less-than operator that implements a strict weak ordering, and it should have no special knowledge beyond that. You can't expect the sort algorithm to diagnose when the user has violated those requirements, because it's impossible in the general case. For example, C++'s `std::sort()` has the same requirement and the implementation has absolutely no responsibility to detect when you've managed to violate the requirement, the result is simply undefined behavior.
<|eor|><|sor|>Because you know, transitivity is not very important.
And also, comparing a number to a Nan is ok, no null returned or exception thrown.
lolphp<|eor|><|sor|>Also lol many other languages, and the floating point spec, however. PHP implementing external insanity isn't php's fault, even if it's insane. <|eor|><|sor|>Comparators are a special case - IEEE floating point comparisons are *not* transitive, while sorting algorithm comparators have to be. Some languages, like java, do handle this case properly by not using IEEE floating point comp for those cases, which is a very sensible approach.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | ebvalaim | cywp6gi | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>>You get the same thing in Python
That is a bit disappointing :(<|eor|><|eols|><|endoftext|> | 13 |
lolphp | hahainternet | cyworfv | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>Interestingly, Perl 6 manages this:
> (7,NaN,3).sort
(3 7 NaN)
edit: Even more interestingly:
> say 1 <=> 2
Less
> say 2 <=> 1
More
> say 2 <=> NaN
Nil
> say (1 <=> 2).WHAT
(Order)<|eor|><|eols|><|endoftext|> | 11 |
lolphp | cb22 | cyx49tn | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>> since the sort is stable
Pretty sure [PHP sorts aren't stable](https://bugs.php.net/bug.php?id=53341&edit=1). At least not consistently.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | maweki | cywolif | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>What's going on here?<|eor|><|sor|>I guess that comparison to NaN throws off the transitivity of the <=-relationship and therefore the algorithm "breaks". It should throw an error or return false, obviously, but it doesn't.<|eor|><|eols|><|endoftext|> | 10 |
lolphp | Schmittfried | cyx691e | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>Handling of disparate memory types types should throw warnings at the *very* least. Not silently give a meaningless output. <|eor|><|sor|>NaN is a numeric type, the same as 3 and 7. It works this way in nearly all other languages, including C, C++, Java, C#, Python, etc. It is in no way a PHP-specific thing.
<|eor|><|sor|>lolprogramming<|eor|><|sor|>lolfloat<|eor|><|eols|><|endoftext|> | 9 |
lolphp | midir | cyxx3p8 | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>It is a lolphp. Although NaN is always a nuisance, it is possible, with care, to define an ordering that allows floats to be sorted coherently and will prevent it from putting 7 before 3. For example, see [`java.util.Arrays.sort`](https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#sort-float:A-):
>The `<` relation does not provide a total order on all float values: `-0.0f == 0.0f` is `true` and a `Float.NaN` value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method `Float.compareTo(java.lang.Float)`: `-0.0f` is treated as less than value `0.0f` and `Float.NaN` is considered greater than any other value and all `Float.NaN` values are considered equal. <|eor|><|eols|><|endoftext|> | 8 |
lolphp | Hacre | cz520if | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>> since the sort is stable
Pretty sure [PHP sorts aren't stable](https://bugs.php.net/bug.php?id=53341&edit=1). At least not consistently.<|eor|><|sor|>>[2015-08-13 13:31 UTC] cmb@php.net
AFAIK PHP 7 uses a stable sort algorithm for small arrays (< 16),
but for larger arrays the algorithm is still not stable.
Furthermore PHP makes no guarantee whether sorting with *sort() is
stable or not.
Hahahaha<|eor|><|eols|><|endoftext|> | 8 |
lolphp | midir | cyxxqbz | <|sols|><|sot|>Today someone said "PHP7 <3" - which is true. PHP thinks 7 < 3<|eot|><|sol|>https://3v4l.org/N5hXC<|eol|><|sor|>That's not a lolphp. It's a misunderstanding of how NaN works and the requirement for a strict weak ordering. Comparing anything to NaN results in false. The sort algorithm is going to ask "is 7 < NaN? False." Then it will ask "is NaN < 7? False." That means 7 and NaN are unorderable (i.e. equal), so they are left in their current order since the sort is stable. Then it asks "is NaN < 3? False" and "is 3 < NaN? False". That again means that 3 and NaN are unorderable, which therefore also means they should stay in their current order. It never actually checks if 3 < 7, because that's not necessaryby the properties of a strict weak ordering, if A == B and B == C, then it must be the case that A == C. By violating that requirement, the result is nonsense.
You get the same thing in Python:
>>> sorted([7, float('nan'), 3])
[7, nan, 3]
And other languages won't even let you do such a thing:
>> [7, Float::NAN, 3].sort
ArgumentError: comparison of Fixnum with NaN failed
from (irb):5:in `sort'
from (irb):5
from /usr/bin/irb:11:in `<main>'
<|eor|><|sor|>It is a lolphp. Although NaN is always a nuisance, it is possible, with care, to define an ordering that allows floats to be sorted coherently and will prevent it from putting 7 before 3. For example, see [`java.util.Arrays.sort`](https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#sort-float:A-):
>The `<` relation does not provide a total order on all float values: `-0.0f == 0.0f` is `true` and a `Float.NaN` value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method `Float.compareTo(java.lang.Float)`: `-0.0f` is treated as less than value `0.0f` and `Float.NaN` is considered greater than any other value and all `Float.NaN` values are considered equal. <|eor|><|sor|>> It is a lolphp.
It's not a lolphp. While it's possible to define an absolute ordering of floats which includes nans that's absolutely not a requirement, and that definition may be considered nonsensical: why would `0/` be greater that all values? Passing NaN to a sort (without a custom key/comparator) is a case of "garbage in", garbage out is absolutely a valid and logical position to take.<|eor|><|sor|>Garbage or not, I'd prefer a method that will always put 3 before 7 than one that sometimes puts 7 before 3.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | ealf | y8akv | <|sols|><|sot|>I tried to make a Hasse diagram for the PHP '<' operator. Turns out INF is smaller than itself, greater than itself, not equal (==) to itself, but identical to itself (===).<|eot|><|sol|>http://i.imgur.com/kuWuk.png<|eol|><|eols|><|endoftext|> | 73 |
lolphp | jmalloc | c5th2nc | <|sols|><|sot|>I tried to make a Hasse diagram for the PHP '<' operator. Turns out INF is smaller than itself, greater than itself, not equal (==) to itself, but identical to itself (===).<|eot|><|sol|>http://i.imgur.com/kuWuk.png<|eol|><|sor|>From my friend and fellow PHP developer:
"Fuck knows what a hasse diagram is, but that's obviously fucked."<|eor|><|eols|><|endoftext|> | 23 |
lolphp | ealf | c5tep7f | <|sols|><|sot|>I tried to make a Hasse diagram for the PHP '<' operator. Turns out INF is smaller than itself, greater than itself, not equal (==) to itself, but identical to itself (===).<|eot|><|sol|>http://i.imgur.com/kuWuk.png<|eol|><|sor|>Since INF isn't actually a finite number, using '<' with it doesn't really make a huge amount of sense, IMO<|eor|><|soopr|>NAN isn't a number. [INF is](http://en.wikipedia.org/wiki/Affinely_extended_real_number_system).
This is all well-defined by IEEE, and every other programming language with floats managed to get this right.
Of course, this is PHP. For NAN, PHP documents the correct behavior, that ...
> Any loose or strict comparisons of [NAN] against any other value, including itself, will have a result of FALSE.
... and then proceeds to get it wrong in the implementation, where every operation except equality returns TRUE, making NAN simultaneously smaller and larger than 1.<|eoopr|><|eols|><|endoftext|> | 18 |
lolphp | InconsiderateBastard | c5tqxki | <|sols|><|sot|>I tried to make a Hasse diagram for the PHP '<' operator. Turns out INF is smaller than itself, greater than itself, not equal (==) to itself, but identical to itself (===).<|eot|><|sol|>http://i.imgur.com/kuWuk.png<|eol|><|sor|>Since INF isn't actually a finite number, using '<' with it doesn't really make a huge amount of sense, IMO<|eor|><|soopr|>NAN isn't a number. [INF is](http://en.wikipedia.org/wiki/Affinely_extended_real_number_system).
This is all well-defined by IEEE, and every other programming language with floats managed to get this right.
Of course, this is PHP. For NAN, PHP documents the correct behavior, that ...
> Any loose or strict comparisons of [NAN] against any other value, including itself, will have a result of FALSE.
... and then proceeds to get it wrong in the implementation, where every operation except equality returns TRUE, making NAN simultaneously smaller and larger than 1.<|eoopr|><|sor|>Those other programming languages with floats probably also manage to handle division by zero in a logical manner. If PHP returned positive or negative infinity I'd be happy. The fact that it returns false, which equates to zero, makes me sad.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | phplovesong | f58jip | <|soss|><|sot|>The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.<|eot|><|sost|>[https://www.php.net/manual/en/function.openssl-x509-parse.php](https://www.php.net/manual/en/function.openssl-x509-parse.php)<|eost|><|eoss|><|endoftext|> | 72 |
lolphp | barubary | fhxb7k4 | <|soss|><|sot|>The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.<|eot|><|sost|>[https://www.php.net/manual/en/function.openssl-x509-parse.php](https://www.php.net/manual/en/function.openssl-x509-parse.php)<|eost|><|sor|>Hey, the function is less than 20 years old. Who knows how it might suddenly change in a future (minor) release?<|eor|><|eoss|><|endoftext|> | 30 |
lolphp | phplovesong | fhx5dkd | <|soss|><|sot|>The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.<|eot|><|sost|>[https://www.php.net/manual/en/function.openssl-x509-parse.php](https://www.php.net/manual/en/function.openssl-x509-parse.php)<|eost|><|soopr|>Its could return anything, and in the future probably anything\^2<|eoopr|><|eoss|><|endoftext|> | 21 |
lolphp | BadFurDay | fhx8gxh | <|soss|><|sot|>The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.<|eot|><|sost|>[https://www.php.net/manual/en/function.openssl-x509-parse.php](https://www.php.net/manual/en/function.openssl-x509-parse.php)<|eost|><|sor|>https://web.archive.org/web/20010605103837/https://www.php.net/manual/en/function.openssl-x509-parse.php<|eor|><|eoss|><|endoftext|> | 12 |
lolphp | sproingie | fhxdwhc | <|soss|><|sot|>The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.<|eot|><|sost|>[https://www.php.net/manual/en/function.openssl-x509-parse.php](https://www.php.net/manual/en/function.openssl-x509-parse.php)<|eost|><|sor|>Thought for a moment it maybe just returned an opaque data structure to be consumed by other functions. But nope, they just couldn't be bothered. Given that level of maintainership, I wouldn't put a lot of faith in the security of the openssl extension either.<|eor|><|eoss|><|endoftext|> | 10 |
lolphp | re_anon | 6mer6n | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|eols|><|endoftext|> | 70 |
lolphp | BilgeXA | dk1ebf3 | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>Have you tried contacting someone who gives a fuck?<|eor|><|eols|><|endoftext|> | 21 |
lolphp | thewells | dk2aunu | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>I like the guy who thinks "non-English" is "not very professional"<|eor|><|sor|>It's very clear that he's referring to the fact that it was referred to as a joke. And call me old fashioned, but error messages don't really feel like the place for jokes, they're to give useful data about what went wrong, and the fact that so many error messages in so many languages/frameworks are fairly shit is one of the most annoying thing I deal with when I'm trying to work<|eor|><|eols|><|endoftext|> | 21 |
lolphp | rabidferret | dk1c6ll | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>I like the guy who thinks "non-English" is "not very professional"<|eor|><|eols|><|endoftext|> | 10 |
lolphp | kosinix | dk8zyk2 | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>Ah. The good ol days. I still remember this rage inducing post by phil sturgeon back then, when he hasnt rage quitted yet from the toxic php community: [https://philsturgeon.uk/php/2013/09/09/t-paamayim-nekudotayim-v-sanity/](https://philsturgeon.uk/php/2013/09/09/t-paamayim-nekudotayim-v-sanity/)<|eor|><|eols|><|endoftext|> | 8 |
lolphp | chazzeromus | dk24oso | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>Have you tried contacting someone who gives a fuck?<|eor|><|sor|>Yeah he's been on hold for a while lmao<|eor|><|eols|><|endoftext|> | 7 |
lolphp | sproingie | dk4fp1w | <|sols|><|sot|>Double colon token, which is T_PAAMAYIM_NEKUDOTAYIM, has a spelling mistake in the parse error and should be T_PAAMAYIM_NEKUDATAYIM<|eot|><|sol|>https://bugs.php.net/bug.php?id=14492<|eol|><|sor|>The fact that PHP considers it acceptable to just spit raw bison/yacc errors with the lex token names instead of expanding them back to the actual expected syntax like every other mature language... But at least I got a free Hebrew lesson from the bug report. :)<|eor|><|eols|><|endoftext|> | 6 |
lolphp | pmodin | 50hxu3 | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|eols|><|endoftext|> | 69 |
lolphp | Regimardyl | d74avlg | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|sor|>Well, it's [documented](http://php.net/manual/en/datetime.createfromformat.php), but who the fuck ever thought that this was a good design decision o.O
> If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time.<|eor|><|eols|><|endoftext|> | 32 |
lolphp | pmodin | d74948z | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|soopr|>Link for tomorrow, but it kind of ruins the joke: https://eval.in/632554
This is how to solve the original: https://eval.in/632569<|eoopr|><|eols|><|endoftext|> | 19 |
lolphp | Regimardyl | d7569ie | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|sor|>Well, it's [documented](http://php.net/manual/en/datetime.createfromformat.php), but who the fuck ever thought that this was a good design decision o.O
> If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time.<|eor|><|sor|>Seriously, even after reading the doc I don't get it.<|eor|><|sor|>Month and Year get set to 09 and 2016, respectively. Since the day isn't specified, the current day (31) is taken instead. Now since there is no 2016-09-31, PHP "corrects" this to 2016-10-01. This enables you to always get the next day's by just increasing the day by one and relying on the libs to fix it (and I'm pretty sure there's plenty of madmen out there doing exactly that!), but it also results in the mess you see in the OP.<|eor|><|eols|><|endoftext|> | 15 |
lolphp | kr094 | d74mf50 | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|soopr|>Link for tomorrow, but it kind of ruins the joke: https://eval.in/632554
This is how to solve the original: https://eval.in/632569<|eoopr|><|sor|>What the fuck<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Regimardyl | d7e0smr | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|sor|>Well, it's [documented](http://php.net/manual/en/datetime.createfromformat.php), but who the fuck ever thought that this was a good design decision o.O
> If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time.<|eor|><|sor|>Seriously, even after reading the doc I don't get it.<|eor|><|sor|>Month and Year get set to 09 and 2016, respectively. Since the day isn't specified, the current day (31) is taken instead. Now since there is no 2016-09-31, PHP "corrects" this to 2016-10-01. This enables you to always get the next day's by just increasing the day by one and relying on the libs to fix it (and I'm pretty sure there's plenty of madmen out there doing exactly that!), but it also results in the mess you see in the OP.<|eor|><|sor|>In what circumstance would you get/use a made up date like the 31st of September for this issue to show?<|eor|><|sor|>Running `\DateTime::CreateFromFormat('Y-m', '2016-09');` on the 31st of some month.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Schmittfried | d74ogoc | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|sor|>Well, it's [documented](http://php.net/manual/en/datetime.createfromformat.php), but who the fuck ever thought that this was a good design decision o.O
> If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time.<|eor|><|sor|>Seriously, even after reading the doc I don't get it.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | Schmittfried | d757tar | <|sols|><|sot|>Date handling on the 31st<|eot|><|sol|>https://eval.in/632529<|eol|><|sor|>Well, it's [documented](http://php.net/manual/en/datetime.createfromformat.php), but who the fuck ever thought that this was a good design decision o.O
> If format does not contain the character ! then portions of the generated time which are not specified in format will be set to the current system time.<|eor|><|sor|>Seriously, even after reading the doc I don't get it.<|eor|><|sor|>Month and Year get set to 09 and 2016, respectively. Since the day isn't specified, the current day (31) is taken instead. Now since there is no 2016-09-31, PHP "corrects" this to 2016-10-01. This enables you to always get the next day's by just increasing the day by one and relying on the libs to fix it (and I'm pretty sure there's plenty of madmen out there doing exactly that!), but it also results in the mess you see in the OP.<|eor|><|sor|>Well, tbh the addition of days seems kind of sane to me. Setting todays time parts that are missing in the format string is pure madness though.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | Persism | r0eii3 | <|sols|><|sot|>PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'<|eot|><|sol|>https://news-web.php.net/php.internals/70691<|eol|><|eols|><|endoftext|> | 68 |
lolphp | metamorphosis | hlteasu | <|sols|><|sot|>PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'<|eot|><|sol|>https://news-web.php.net/php.internals/70691<|eol|><|sor|>In his defence
>This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names.<|eor|><|eols|><|endoftext|> | 16 |
lolphp | Persism | hlthd2l | <|sols|><|sot|>PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'<|eot|><|sol|>https://news-web.php.net/php.internals/70691<|eol|><|sor|>In his defence
>This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names.<|eor|><|soopr|>Ah, the legacy of Personal Home Page rears it's ugly head again.<|eoopr|><|eols|><|endoftext|> | 15 |
lolphp | jpresutti | hm2n788 | <|sols|><|sot|>PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'<|eot|><|sol|>https://news-web.php.net/php.internals/70691<|eol|><|sor|>This exact thing has only been posted about the hundred times<|eor|><|eols|><|endoftext|> | 6 |
lolphp | fuckEAinthecloaca | hlwlwml | <|sols|><|sot|>PHP creator: functions were named to fall into length buckets because function hash algo was 'strlen'<|eot|><|sol|>https://news-web.php.net/php.internals/70691<|eol|><|sor|>In his defence
>This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names.<|eor|><|sor|>I too have done terrible things, luckily I don't have enough talent for them to see the light of day.<|eor|><|eols|><|endoftext|> | 6 |
lolphp | the_alias_of_andrea | 438rm2 | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|eols|><|endoftext|> | 71 |
lolphp | the_alias_of_andrea | czgc4a5 | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|soopr|>The best bit is probably the source code:
/* {{{ proto int SplHeap::recoverFromCorruption()
Recover from a corrupted state*/
SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_SPLHEAP_P(getThis());
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
/* }}} */
It literally just unsets the corruption flag. So instead of fixing whatever bug was causing data structure corruption, PHP just adds a function to ignore the warning signs. Wow.
Edit: Ah, here's why there's a corruption flag in the first place:
if (EG(exception)) {
/* exception thrown during comparison */
heap->flags |= SPL_HEAP_CORRUPTED;
}
~~If corruption is created, why doesn't it, like, throw an exception?~~
~~I'm guessing it's not PHP's fault per se that this causes corruption. If your comparison functions are throwing exceptions, then you can't maintain the heap properly. What definitely is PHP's fault is how it handles this: it should just throw an exception to complain that you threw an exception, rather than setting a flag like this.~~
Edit 2: I'm not sure what I was thinking, it does propagate the original exception (thank you /u/nikic). What's nonsense is being able to remove the flag.<|eoopr|><|eols|><|endoftext|> | 43 |
lolphp | nikic | czhfk2g | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|soopr|>The best bit is probably the source code:
/* {{{ proto int SplHeap::recoverFromCorruption()
Recover from a corrupted state*/
SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_SPLHEAP_P(getThis());
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
/* }}} */
It literally just unsets the corruption flag. So instead of fixing whatever bug was causing data structure corruption, PHP just adds a function to ignore the warning signs. Wow.
Edit: Ah, here's why there's a corruption flag in the first place:
if (EG(exception)) {
/* exception thrown during comparison */
heap->flags |= SPL_HEAP_CORRUPTED;
}
~~If corruption is created, why doesn't it, like, throw an exception?~~
~~I'm guessing it's not PHP's fault per se that this causes corruption. If your comparison functions are throwing exceptions, then you can't maintain the heap properly. What definitely is PHP's fault is how it handles this: it should just throw an exception to complain that you threw an exception, rather than setting a flag like this.~~
Edit 2: I'm not sure what I was thinking, it does propagate the original exception (thank you /u/nikic). What's nonsense is being able to remove the flag.<|eoopr|><|sor|>> If corruption is created, why doesn't it, like, throw an exception?
Wat? Obviously it throws an exception. You know, the exception that caused the corruption bit to be set? That exception didn't go anywhere. It will still be propagated to the parent frame. Like exceptions normally are.
The point here is that if the comparison function threw an exception (which will be propagated), the heap is no longer in a consistent state and PHP will forbid you from using it (by throwing an exception in extract etc). That is, unless you go and say "I don't give a damn about it" by using recoverFromCorruption.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | BilgeXA | czh2rbg | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|soopr|>The best bit is probably the source code:
/* {{{ proto int SplHeap::recoverFromCorruption()
Recover from a corrupted state*/
SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_SPLHEAP_P(getThis());
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
/* }}} */
It literally just unsets the corruption flag. So instead of fixing whatever bug was causing data structure corruption, PHP just adds a function to ignore the warning signs. Wow.
Edit: Ah, here's why there's a corruption flag in the first place:
if (EG(exception)) {
/* exception thrown during comparison */
heap->flags |= SPL_HEAP_CORRUPTED;
}
~~If corruption is created, why doesn't it, like, throw an exception?~~
~~I'm guessing it's not PHP's fault per se that this causes corruption. If your comparison functions are throwing exceptions, then you can't maintain the heap properly. What definitely is PHP's fault is how it handles this: it should just throw an exception to complain that you threw an exception, rather than setting a flag like this.~~
Edit 2: I'm not sure what I was thinking, it does propagate the original exception (thank you /u/nikic). What's nonsense is being able to remove the flag.<|eoopr|><|sor|>SPL is generally a goldmine of fuckups, with few exceptions.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | stfarn | czgv57z | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|soopr|>The best bit is probably the source code:
/* {{{ proto int SplHeap::recoverFromCorruption()
Recover from a corrupted state*/
SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_SPLHEAP_P(getThis());
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
/* }}} */
It literally just unsets the corruption flag. So instead of fixing whatever bug was causing data structure corruption, PHP just adds a function to ignore the warning signs. Wow.
Edit: Ah, here's why there's a corruption flag in the first place:
if (EG(exception)) {
/* exception thrown during comparison */
heap->flags |= SPL_HEAP_CORRUPTED;
}
~~If corruption is created, why doesn't it, like, throw an exception?~~
~~I'm guessing it's not PHP's fault per se that this causes corruption. If your comparison functions are throwing exceptions, then you can't maintain the heap properly. What definitely is PHP's fault is how it handles this: it should just throw an exception to complain that you threw an exception, rather than setting a flag like this.~~
Edit 2: I'm not sure what I was thinking, it does propagate the original exception (thank you /u/nikic). What's nonsense is being able to remove the flag.<|eoopr|><|sor|>Baffling how they are unable to propagate an exception like any other language supporting them<|eor|><|eols|><|endoftext|> | 7 |
lolphp | Danack | czh9va8 | <|sols|><|sot|>SplPriorityQueue::recoverFromCorruption<|eot|><|sol|>http://php.net/manual/en/splpriorityqueue.recoverfromcorruption.php<|eol|><|soopr|>The best bit is probably the source code:
/* {{{ proto int SplHeap::recoverFromCorruption()
Recover from a corrupted state*/
SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_SPLHEAP_P(getThis());
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
/* }}} */
It literally just unsets the corruption flag. So instead of fixing whatever bug was causing data structure corruption, PHP just adds a function to ignore the warning signs. Wow.
Edit: Ah, here's why there's a corruption flag in the first place:
if (EG(exception)) {
/* exception thrown during comparison */
heap->flags |= SPL_HEAP_CORRUPTED;
}
~~If corruption is created, why doesn't it, like, throw an exception?~~
~~I'm guessing it's not PHP's fault per se that this causes corruption. If your comparison functions are throwing exceptions, then you can't maintain the heap properly. What definitely is PHP's fault is how it handles this: it should just throw an exception to complain that you threw an exception, rather than setting a flag like this.~~
Edit 2: I'm not sure what I was thinking, it does propagate the original exception (thank you /u/nikic). What's nonsense is being able to remove the flag.<|eoopr|><|sor|>SPL is generally a goldmine of fuckups, with few exceptions.<|eor|><|sor|>Actually, it has too many Exceptions.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | neldorling | lz0mib | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|eoss|><|endoftext|> | 69 |
lolphp | AyrA_ch | gpy1a1n | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|eoss|><|endoftext|> | 38 |
lolphp | elcapitanoooo | gpxx2n6 | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Have told this before, but it needs to be repeated. NEVER rely on PHP date/time for anything critical. Its deeply riddled in bugs and edge cases.<|eor|><|eoss|><|endoftext|> | 20 |
lolphp | Lunar_Requiem | gpz8k06 | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|sor|>There isn't even agreement between churches as to *when* easter is<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | apotheotical | gpypaqz | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|sor|>It's an Easter _egg_.<|eor|><|eoss|><|endoftext|> | 16 |
lolphp | postmodest | gq0frcd | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|sor|>Because its a c library function? And PHP is like Perl and C merged together, but with none of the best parts of C and none of the best parts of Perl?<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | 1r0n1c | gq2ar33 | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|sor|>There isn't even agreement between churches as to *when* easter is<|eor|><|sor|>They should just follow PHP's opinion. Problem solved<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | barubary | gqb56x2 | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Forget it using a different environment, why the fuck is there a `easter_date` and `easter_days` function?<|eor|><|sor|>Because its a c library function? And PHP is like Perl and C merged together, but with none of the best parts of C and none of the best parts of Perl?<|eor|><|sor|>What C library has an `easter_date` function?<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | codex561 | gpzk20v | <|soss|><|sot|>easter_date and timezones. lol<|eot|><|sost|>> easter_date() relies on your system's C library time functions, rather than using PHP's internal date and time functions. As a consequence, easter_date() uses the TZ environment variable to determine the time zone it should operate in, rather than using PHP's default time zone, which may result in unexpected behaviour when using this function in conjunction with other date functions in PHP.<|eost|><|sor|>Have told this before, but it needs to be repeated. NEVER rely on PHP date/time for anything critical. Its deeply riddled in bugs and edge cases.<|eor|><|sor|>[deleted]<|eor|><|sor|>Not PHP<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | lord_braleigh | deqzgo | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|eols|><|endoftext|> | 71 |
lolphp | SirClueless | f2yl8xv | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|sor|>Seems like the real LOLPHP is the SORT\_REGULAR. Without it, things behave as expected. See
`<?php`
`echo json_encode(array_unique(array(0, 'lolphp', '',5), SORT_REGULAR))."\n";`
`echo json_encode(array_unique(array(0, 'lolphp', '',5)))."\n";`<|eor|><|soopr|>Well, you need `SORT_REGULAR` if you want to uniquify `array(array(), array())`. Without `SORT_REGULAR`, PHP casts the elements to strings and uniquifies the strings. But arrays cant be cast to strings.
`SORT_REGULAR` works by sorting the array then comparing adjacent elements with `==`, so it doesnt have this limitation. But it has other problems...<|eoopr|><|sor|>Honestly `array_unique` acts about as reasonably as can be expected given PHP's bizarre `==` operator.
<?php
var_dump('' == 0); # bool(true)
var_dump('lolphp' == 0); # bool(true)
var_dump('' == 'lolphp'); # bool(false)
https://repl.it/repls/DescriptiveGlassDatasets
If you want a real dose of WTF, try this:
<?php
echo json_encode(array_unique(array(0, 'lolphp', ''), SORT_REGULAR))."\n"; # [0]
echo json_encode(array_unique(array('lolphp', 0, ''), SORT_REGULAR))."\n"; # {"0":"lolphp","2":""}
echo json_encode(array_unique(array('', 'lolphp', 0), SORT_REGULAR))."\n"; # ["", "lolphp"]
https://repl.it/repls/DimpledFewDatamining<|eor|><|eols|><|endoftext|> | 25 |
lolphp | fell_ratio | f2ynxuo | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|sor|>Wow, this is a pretty baffling one. I think the problem is that the strings are being coerced to integer to compare to the zero, despite that the PHP documentation says `SORT_REGULAR` will 'compare items normally (don't change types).'
If you change the order of the arguments, you get a different result:
<?php
echo json_encode(array_unique(array('lolphp', ''), SORT_REGULAR))."\n";
echo json_encode(array_unique(array('lolphp', '', 0), SORT_REGULAR))."\n";
produces:
["lolphp",""]
["lolphp",""]<|eor|><|eols|><|endoftext|> | 18 |
lolphp | orby | f2ybeur | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|sor|>Seems like the real LOLPHP is the SORT\_REGULAR. Without it, things behave as expected. See
`<?php`
`echo json_encode(array_unique(array(0, 'lolphp', '',5), SORT_REGULAR))."\n";`
`echo json_encode(array_unique(array(0, 'lolphp', '',5)))."\n";`<|eor|><|eols|><|endoftext|> | 6 |
lolphp | lord_braleigh | f2yhpdw | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|sor|>Seems like the real LOLPHP is the SORT\_REGULAR. Without it, things behave as expected. See
`<?php`
`echo json_encode(array_unique(array(0, 'lolphp', '',5), SORT_REGULAR))."\n";`
`echo json_encode(array_unique(array(0, 'lolphp', '',5)))."\n";`<|eor|><|soopr|>Well, you need `SORT_REGULAR` if you want to uniquify `array(array(), array())`. Without `SORT_REGULAR`, PHP casts the elements to strings and uniquifies the strings. But arrays cant be cast to strings.
`SORT_REGULAR` works by sorting the array then comparing adjacent elements with `==`, so it doesnt have this limitation. But it has other problems...<|eoopr|><|eols|><|endoftext|> | 6 |
lolphp | philipwhiuk | f31dbij | <|sols|><|sot|>`array('lolphp', '')` has two unique elements, but `array(0, 'lolphp', '')` has one unique element<|eot|><|sol|>https://repl.it/repls/ThisColdPackages<|eol|><|sor|>Seems like the real LOLPHP is the SORT\_REGULAR. Without it, things behave as expected. See
`<?php`
`echo json_encode(array_unique(array(0, 'lolphp', '',5), SORT_REGULAR))."\n";`
`echo json_encode(array_unique(array(0, 'lolphp', '',5)))."\n";`<|eor|><|soopr|>Well, you need `SORT_REGULAR` if you want to uniquify `array(array(), array())`. Without `SORT_REGULAR`, PHP casts the elements to strings and uniquifies the strings. But arrays cant be cast to strings.
`SORT_REGULAR` works by sorting the array then comparing adjacent elements with `==`, so it doesnt have this limitation. But it has other problems...<|eoopr|><|sor|>Honestly `array_unique` acts about as reasonably as can be expected given PHP's bizarre `==` operator.
<?php
var_dump('' == 0); # bool(true)
var_dump('lolphp' == 0); # bool(true)
var_dump('' == 'lolphp'); # bool(false)
https://repl.it/repls/DescriptiveGlassDatasets
If you want a real dose of WTF, try this:
<?php
echo json_encode(array_unique(array(0, 'lolphp', ''), SORT_REGULAR))."\n"; # [0]
echo json_encode(array_unique(array('lolphp', 0, ''), SORT_REGULAR))."\n"; # {"0":"lolphp","2":""}
echo json_encode(array_unique(array('', 'lolphp', 0), SORT_REGULAR))."\n"; # ["", "lolphp"]
https://repl.it/repls/DimpledFewDatamining<|eor|><|sor|>Wha... How?<|eor|><|sor|>Because the equality operator isn't transitive so it breaks the sort function's stability guarantee.
non-transitive equality is basically almost inevitable in weakly typed languages.<|eor|><|eols|><|endoftext|> | 5 |
lolphp | stesch | 8q3odg | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|eoss|><|endoftext|> | 70 |
lolphp | mikeputerbaugh | e0gdwkx | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|> md5('240610708') === md5('QNKCDZO')
has worked as expected since the introduction of PHP4, 18 years ago.<|eor|><|eoss|><|endoftext|> | 45 |
lolphp | Miserable_Fuck | e0gmq63 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>I mean I get it, it's stupid that this can happen.
[Type juggling is not the best for usability, but it is so easy to prevent.](https://3v4l.org/PAqjZ)
This is just low effort "Hey I'm using this not really right and it doesnt do what I expect" while its working as intended and documented.<|eor|><|sor|>> working as intended and documented
PHP's version of "technically correct"<|eor|><|eoss|><|endoftext|> | 35 |
lolphp | simon816 | e0gf7i9 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>Unless there's a good reason to ignore type juggling, always use `===`<|eor|><|eoss|><|endoftext|> | 33 |
lolphp | Schmittfried | e0hgl26 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>I mean I get it, it's stupid that this can happen.
[Type juggling is not the best for usability, but it is so easy to prevent.](https://3v4l.org/PAqjZ)
This is just low effort "Hey I'm using this not really right and it doesnt do what I expect" while its working as intended and documented.<|eor|><|sor|>Not that easy actually. There is neither are ===switch nor >== nor <==.
Edit: Wow, thanks for the gold.<|eor|><|eoss|><|endoftext|> | 33 |
lolphp | fell_ratio | e0g9mwl | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>How many of these collisions are known?<|eor|><|sor|> php > echo md5('How many of these collisions are known? 74649668');
0e574776263172735790682058574682
The odds that a md5 will hash to 0e followed by 30 digit characters is about 1 in a billion.
So they aren't hard to find.<|eor|><|eoss|><|endoftext|> | 31 |
lolphp | Joniator | e0gd7d6 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>I mean I get it, it's stupid that this can happen.
[Type juggling is not the best for usability, but it is so easy to prevent.](https://3v4l.org/PAqjZ)
This is just low effort "Hey I'm using this not really right and it doesnt do what I expect" while its working as intended and documented.<|eor|><|eoss|><|endoftext|> | 26 |
lolphp | stesch | e0g7vun | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>How many of these collisions are known?<|eor|><|soopr|>It's no collision. It interprets the strings as numbers. And both result to 0 (zero).
<|eoopr|><|eoss|><|endoftext|> | 26 |
lolphp | barubary | e0h0unl | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>`'0e462097431906509019562988736854' == '0' && print("is zero");`
wut why is PHP doing any type coercion here?<|eor|><|sor|>Because PHP [thought it would be funny](http://php.net/manual/en/language.operators.comparison.php):
> If you compare a number with a string **or the comparison involves numerical strings**, then each string is [converted to a number](http://php.net/manual/en/language.types.string.php#language.types.string.conversion) and the comparison performed numerically. These rules also apply to the [switch](http://php.net/manual/en/control-structures.switch.php) statement.<|eor|><|eoss|><|endoftext|> | 20 |
lolphp | duskwuff | e0g94sj | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>[deleted]<|eor|><|soopr|>Python:
>>> '0e462097431906509019562988736854' == '0e830400451993494058024219903391'
False<|eoopr|><|sor|>However:
>>> float('0e462097431906509019562988736854') == float('0e830400451993494058024219903391')
True<|eor|><|eoss|><|endoftext|> | 15 |
lolphp | Boldewyn | e0g80xq | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>[deleted]<|eor|><|sor|>Because thats _not_ an MD5 collision, but PHP doing type coercion around the `==` operator. `(int)"0eMANYDIGITS" === 0`.<|eor|><|eoss|><|endoftext|> | 13 |
lolphp | FlyLo11 | e0h7h1t | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>Shouldn't you use [strcmp](http://php.net/manual/en/function.strcmp.php) for string comparison ?<|eor|><|sor|>`strcmp` is better suited for sorting, as it returns three different states: lesser, equal, greater.
For verifying equality between strings, `===` is enough.
For security related stuff, [hash_equals](http://php.net/manual/en/function.hash-equals.php) should be used, as it is safe against [timing attacks](https://en.wikipedia.org/wiki/Timing_attack). Of course, md5 should never be used as a hashing choice for security stuff.<|eor|><|eoss|><|endoftext|> | 11 |
lolphp | pingpong | e0g8twu | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>[deleted]<|eor|><|sor|>Because thats _not_ an MD5 collision, but PHP doing type coercion around the `==` operator. `(int)"0eMANYDIGITS" === 0`.<|eor|><|sor|>A couple of notes.
* It doesn't need to be 0eMANYDIGITS. `0e1 === 0.0` because `0.0 * pow(10, 1) === 0.0`.
* Any `e` number like `0e1` is a double, not an int.<|eor|><|eoss|><|endoftext|> | 8 |
lolphp | SnowdensOfYesteryear | e0gkek0 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>`'0e462097431906509019562988736854' == '0' && print("is zero");`
wut why is PHP doing any type coercion here?<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | eztab | e1nbssv | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>`'0e462097431906509019562988736854' == '0' && print("is zero");`
wut why is PHP doing any type coercion here?<|eor|><|sor|>The simple answer is that they might have started off as numbers and been coerced into strings.
If strings don't match exactly but look like numbers, they're matched numerically<|eor|><|sor|>Which is a horrible idea as we can see. One problem is that 0e1234 is considered a valid way of specifying a zero. In this example this can be circumvented by using "===" as one should.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | ebvalaim | e0h72bk | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>[deleted]<|eor|><|soopr|>Python:
>>> '0e462097431906509019562988736854' == '0e830400451993494058024219903391'
False<|eoopr|><|sor|>> "0e462097431906509019562988736854" == "0e830400451993494058024219903391"
>
> false
Even JavaScript gets this one right. Why would anyone think that coercing to a type that wasn't even a part of the expression is a good idea is beyond me.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | HildartheDorf | e0h984s | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>[deleted]<|eor|><|soopr|>Python:
>>> '0e462097431906509019562988736854' == '0e830400451993494058024219903391'
False<|eoopr|><|sor|>> "0e462097431906509019562988736854" == "0e830400451993494058024219903391"
>
> false
Even JavaScript gets this one right. Why would anyone think that coercing to a type that wasn't even a part of the expression is a good idea is beyond me.<|eor|><|sor|>Exactly. Coercing one side to match the other is imo bad but understandable. Making new types up out of thin air is ridiculous default behaviour.<|eor|><|eoss|><|endoftext|> | 7 |
lolphp | Takeoded | e2b3qwt | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>I mean I get it, it's stupid that this can happen.
[Type juggling is not the best for usability, but it is so easy to prevent.](https://3v4l.org/PAqjZ)
This is just low effort "Hey I'm using this not really right and it doesnt do what I expect" while its working as intended and documented.<|eor|><|sor|>it's _NOT_ that easy to prevent. how do you prevent type juggling with `$i < $x` or > or any of the arithmetic operators? they silently cast _anything_ to a number, i believe.
`var_dump( curl_init() > 3 );` > `bool(true)`<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | eztab | e1nbe62 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>Here's one for python:
import hashlib
def md5(data):
m = hashlib.md5()
m.update(data)
return m.digest()
print(
md5(b'M\xc9h\xff\x0e\xe3\\ \x95r\xd4w{r\x15\x87\xd3o\xa7\xb2\x1b\xdcV\xb7J=\xc0x>{\x95\x18\xaf\xbf\xa2\x00\xa8(K\xf3n\x8eKU\xb3_Bu\x93\xd8Igm\xa0\xd1U]\x83`\xfb_\x07\xfe\xa2') ==
md5(b'M\xc9h\xff\x0e\xe3\\ \x95r\xd4w{r\x15\x87\xd3o\xa7\xb2\x1b\xdcV\xb7J=\xc0x>{\x95\x18\xaf\xbf\xa2\x02\xa8(K\xf3n\x8eKU\xb3_Bu\x93\xd8Igm\xa0\xd1\xd5]\x83`\xfb_\x07\xfe\xa2')
)<|eor|><|sor|>This is not python specific. The same would happen in every language, since those two md5s are actually the same.<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | thewells | e0gutlx | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>I mean I get it, it's stupid that this can happen.
[Type juggling is not the best for usability, but it is so easy to prevent.](https://3v4l.org/PAqjZ)
This is just low effort "Hey I'm using this not really right and it doesnt do what I expect" while its working as intended and documented.<|eor|><|sor|>> working as intended and documented
PHP's version of "technically correct"<|eor|><|sor|>> PHOs version of totally correct
FTFY<|eor|><|eoss|><|endoftext|> | 6 |
lolphp | Plastonick | e0gf0z6 | <|soss|><|sot|>md5('240610708') == md5('QNKCDZO')<|eot|><|sost|> $ php -a
Interactive shell
php > md5('240610708') == md5('QNKCDZO') && print("equal");
equal
php > echo md5('240610708');
0e462097431906509019562988736854
php > echo md5('QNKCDZO');
0e830400451993494058024219903391
php > '0e462097431906509019562988736854' == '0e830400451993494058024219903391' && print("equal");
equal
php > '0e462097431906509019562988736854' == 0 && print("is zero");
is zero
php > '0e462097431906509019562988736854' == '0' && print("is zero");
is zero
**EDIT:** Added the zero part.
<|eost|><|sor|>How many of these collisions are known?<|eor|><|sor|> php > echo md5('How many of these collisions are known? 74649668');
0e574776263172735790682058574682
The odds that a md5 will hash to 0e followed by 30 digit characters is about 1 in a billion.
So they aren't hard to find.<|eor|><|sor|>This is a really nice way to demonstrate that point!<|eor|><|eoss|><|endoftext|> | 5 |
lolphp | jesseschalken | 810h2o | <|sols|><|sot|>Being in Amsterdam causes you to lose a year<|eot|><|sol|>https://3v4l.org/DF5QE<|eol|><|eols|><|endoftext|> | 69 |
lolphp | fizzy_tom | dv0ca2e | <|sols|><|sot|>Being in Amsterdam causes you to lose a year<|eot|><|sol|>https://3v4l.org/DF5QE<|eol|><|sor|>To be fair, that's because it starts with a leap year which are difficult to deal with.<|eor|><|sor|>It would piss me off no end if I encountered this in the wild. Leap years or not, this is awful.
The problem is not that it's calculated as 9 years 11 months for the Amsterdam timezone... as taking leap years into account you can make an argument that's the correct answer (although I'd expect the answer here to be here 10 years).
The problem is that the result is different depending on what timezone you use.<|eor|><|eols|><|endoftext|> | 22 |
lolphp | OmnipotentEntity | dv15e2g | <|sols|><|sot|>Being in Amsterdam causes you to lose a year<|eot|><|sol|>https://3v4l.org/DF5QE<|eol|><|sor|>Python version: https://repl.it/repls/GrandioseRedBrowsers<|eor|><|sor|>Saving a click, it actually works correctly.<|eor|><|eols|><|endoftext|> | 13 |
lolphp | fizzy_tom | dv0k5dd | <|sols|><|sot|>Being in Amsterdam causes you to lose a year<|eot|><|sol|>https://3v4l.org/DF5QE<|eol|><|sor|>To be fair, that's because it starts with a leap year which are difficult to deal with.<|eor|><|sor|>It would piss me off no end if I encountered this in the wild. Leap years or not, this is awful.
The problem is not that it's calculated as 9 years 11 months for the Amsterdam timezone... as taking leap years into account you can make an argument that's the correct answer (although I'd expect the answer here to be here 10 years).
The problem is that the result is different depending on what timezone you use.<|eor|><|sor|>I am not sure if UTC has leap years because it's technically not a time zone but a standardized reference. If you think about it, unix time doesn't cares for leap seconds either.
UTC is not an alias for GMT but I would not be surprised if it still is in PHP because of backwards compatibility.
Our way of keeping time is notoriously difficult with different calendars, leap seconds, leap years and DST. I am not surprised that the date component fails somewhere. After all apple had multiple years where the iOS alarm broke after DST change.<|eor|><|sor|>Sorry, but I think you're confused.
A Unix timestamp has no concept of days, months, years, timezones, daylight savings, leap years, etc. It's just the number of seconds since 00:00:00 on 1/1/1970 (based on your current timezone). It gets adjusted for leap seconds, but that's a different thing.
It's only when a timestamp is converted into a date that all those concepts come into play, because a date in general needs to know about that stuff. So I'm not sure where timestamps come into this problem?
UTC does have the concept of leap years as it is just a standardized way of expressing the time. If you tried to create 29th Feb 2008 using UTC as the timezone, it would obviously be just fine. Otherwise all those unlucky people born on 29th Feb who only get their birthdays every 4 years would have even more reason to be upset, as the agreed international standard for time wouldn't even think they were born. :(
Like you say, date and time calculations are tough, but the least you expect is some consistency. Doing the same calculation with different timezones should yeild the same result. The dates used here won't be bringing in complexities around daylight saving times and such like, so there's no [good] reason for the results to be different.
<|eor|><|sor|>> It gets adjusted for leap seconds, but that's a different thing.
It doesn't really gets adjusted but simply ignores them completely due to how it has been designed. The last time a leap second was added was on 2016-12-31 23:59:59 UTC (1483228799), which makes `2016-12-31 23:59:60 UTC` a valid time that really happened, yet if we add 1 second to the given timestamp it will report `2017-01-01 00:00:00` on every computer, effectively ignoring the leap second.
I see in your account that you probably were not on reddit in 2012. [Thanks to a leap second major websites crashed](https://www.wired.com/2012/07/leap-second-glitch-explained/). This is such a major problem that [google reprogrammed their NTP servers to no longer perform a leap second at once but rather stretch it across 24 hours](https://developers.google.com/time/smear).
> So I'm not sure where timestamps come into this problem?
They're the internal time keeping mechanism of about everything that is designed to work on linux. At least internally they are always involved when working with dates which makes everything that causes a day to not be 3600*24 seconds complicated.<|eor|><|sor|>You're quite determined that timestamps are the issue here rather it being some weird PHP bug, so I'll leave you with that.
But for your own learning, consider how differently (or not) you'd expect timestamps to behave depending on which timezone is being used when converting them to dates.<|eor|><|eols|><|endoftext|> | 7 |
lolphp | fizzy_tom | dv0eynv | <|sols|><|sot|>Being in Amsterdam causes you to lose a year<|eot|><|sol|>https://3v4l.org/DF5QE<|eol|><|sor|>To be fair, that's because it starts with a leap year which are difficult to deal with.<|eor|><|sor|>It would piss me off no end if I encountered this in the wild. Leap years or not, this is awful.
The problem is not that it's calculated as 9 years 11 months for the Amsterdam timezone... as taking leap years into account you can make an argument that's the correct answer (although I'd expect the answer here to be here 10 years).
The problem is that the result is different depending on what timezone you use.<|eor|><|sor|>I am not sure if UTC has leap years because it's technically not a time zone but a standardized reference. If you think about it, unix time doesn't cares for leap seconds either.
UTC is not an alias for GMT but I would not be surprised if it still is in PHP because of backwards compatibility.
Our way of keeping time is notoriously difficult with different calendars, leap seconds, leap years and DST. I am not surprised that the date component fails somewhere. After all apple had multiple years where the iOS alarm broke after DST change.<|eor|><|sor|>Sorry, but I think you're confused.
A Unix timestamp has no concept of days, months, years, timezones, daylight savings, leap years, etc. It's just the number of seconds since 00:00:00 on 1/1/1970 (based on your current timezone). It gets adjusted for leap seconds, but that's a different thing.
It's only when a timestamp is converted into a date that all those concepts come into play, because a date in general needs to know about that stuff. So I'm not sure where timestamps come into this problem?
UTC does have the concept of leap years as it is just a standardized way of expressing the time. If you tried to create 29th Feb 2008 using UTC as the timezone, it would obviously be just fine. Otherwise all those unlucky people born on 29th Feb who only get their birthdays every 4 years would have even more reason to be upset, as the agreed international standard for time wouldn't even think they were born. :(
Like you say, date and time calculations are tough, but the least you expect is some consistency. Doing the same calculation with different timezones should yeild the same result. The dates used here won't be bringing in complexities around daylight saving times and such like, so there's no [good] reason for the results to be different.
<|eor|><|eols|><|endoftext|> | 6 |
lolphp | ThisIsADogHello | 5e9l4r | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|eols|><|endoftext|> | 67 |
lolphp | redwall_hp | dab00ug | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>This OpenCart one is egregious too: http://i.imgur.com/V3u9E5l.png<|eor|><|eols|><|endoftext|> | 37 |
lolphp | ThisIsADogHello | daaqjvn | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|soopr|>[This reddit thread where I found this](https://www.reddit.com/r/netsec/comments/5e7222/wordpress_download_server_is_a_single_point_of/daaewkx/) contains even more lolphp.<|eoopr|><|eols|><|endoftext|> | 20 |
lolphp | graingert | dabs022 | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>This OpenCart one is egregious too: http://i.imgur.com/V3u9E5l.png<|eor|><|sor|>https://github.com/opencart/opencart/issues/1308
https://github.com/opencart/opencart/issues/1286
https://gist.github.com/uppfinnarn/9956023<|eor|><|eols|><|endoftext|> | 17 |
lolphp | Yo-Yo-Boy | daayod0 | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>But where is the lolphp in this case?<|eor|><|sor|>> Error No: ' in /home/user/domain/system/library/db/mysqli.php:10 Stack trace: #0 /home/user/domain/system/library/db.php(9): DB\MySQLi->__construct('localhost', 'opencart', 'pass123', 'opencart', '3306')
It's also filled with a lot of loldevelopers in the thread, arguing that it's ok to output source code "because error reporting should be disabled"<|eor|><|sor|>I'm not a PHP dev, but I know that if you run any Django or Flask app in debug mode it will do the exact same thing. Sounds like PHP error reporting is the equivalent of that setting. So this seems like more of a case of "lol code deployment" more than lolphp.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | Yo-Yo-Boy | dab1xwp | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>But where is the lolphp in this case?<|eor|><|sor|>> Error No: ' in /home/user/domain/system/library/db/mysqli.php:10 Stack trace: #0 /home/user/domain/system/library/db.php(9): DB\MySQLi->__construct('localhost', 'opencart', 'pass123', 'opencart', '3306')
It's also filled with a lot of loldevelopers in the thread, arguing that it's ok to output source code "because error reporting should be disabled"<|eor|><|sor|>I'm not a PHP dev, but I know that if you run any Django or Flask app in debug mode it will do the exact same thing. Sounds like PHP error reporting is the equivalent of that setting. So this seems like more of a case of "lol code deployment" more than lolphp.<|eor|><|sor|>> but I know that if you run any Django or Flask app in debug mode it will do the exact same thing.
Are you sure? I've done lots of both and I don't remember any credentials being dumped in a stack trace. Not trying to be antagonistic here, just maybe I missed it?<|eor|><|sor|>It seems I'm only partially right.
It seems that Django's [debug mode](https://docs.djangoproject.com/en/1.10/ref/settings/#debug) stack traces do their best to filter out variables with names that may include secret info. But they do dump a huge trace with the ability to read any variable that doesn't match their "sensitive" patterns. They warn to *never* deploy with debug on because there are still terrible things that can be done with such info.
Flask's [debug mode](http://flask.pocoo.org/docs/0.11/quickstart/#debug-mode) in their development server has a full REPL, so you can execute arbitrary code in it. Although, this would be much harder to "accidentally" deploy because most deployed Flask apps are behind a UWSGi gateway and wouldn't be using the development server to begin with.
All that said, in many deployment scenarios, a database password would be harmless, because the database server can be configured to only accept connections locally (if on the same machine) or within the site's private network. I've seen deployment scenarios where there is no password thanks to this.
TL;DR Programming and deployment is complicated and you need to know what you're doing regardless of whether you're using Python or PHP.<|eor|><|eols|><|endoftext|> | 14 |
lolphp | Cuddlefluff_Grim | daatu4q | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>But where is the lolphp in this case?<|eor|><|sor|>> Error No: ' in /home/user/domain/system/library/db/mysqli.php:10 Stack trace: #0 /home/user/domain/system/library/db.php(9): DB\MySQLi->__construct('localhost', 'opencart', 'pass123', 'opencart', '3306')
It's also filled with a lot of loldevelopers in the thread, arguing that it's ok to output source code "because error reporting should be disabled"<|eor|><|eols|><|endoftext|> | 13 |
lolphp | bj_christianson | dabd7l1 | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>This OpenCart one is egregious too: http://i.imgur.com/V3u9E5l.png<|eor|><|sor|>Oh, I knew there was a different issue that OpenCart had. Forgot what it was, though. Thanks for reminding me.<|eor|><|eols|><|endoftext|> | 12 |
lolphp | BobisOnlyBob | dac42tc | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>PHP ecommerce apps are a fucking joke. I've done a lot of work in them and they're terribly insecure, terribly written, and terribly documented.
Case in point: Magento *still* emails users a new, valid password rather than a confirmation link. But I'm sure there's premium plugins that will let you do things correctly...<|eor|><|sor|>Fuck Magento so many ways. I'm too tired to even go into right now but it really needs to be said: Fuck Magento so, so, so much. Even if it hadn't been completely misused at my last job it would've been terrible, but jesus christ it was truly an abomination by the time I started working there and it was even worse when I left. Fuck Magento! <|eor|><|eols|><|endoftext|> | 10 |
lolphp | redwall_hp | dabumja | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>This OpenCart one is egregious too: http://i.imgur.com/V3u9E5l.png<|eor|><|sor|>https://github.com/opencart/opencart/issues/1308
https://github.com/opencart/opencart/issues/1286
https://gist.github.com/uppfinnarn/9956023<|eor|><|sor|>Wow. That was insane.<|eor|><|eols|><|endoftext|> | 9 |
lolphp | Matt3k | daaxkio | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>Lots of web languages output the last few lines of source code when an unhandled exception is hit. It's a valuable troubleshooting tool that many server administrators leave on in production, despite the tradeoff in risk.
Applications should consider this potential and at least have credentials stored in a configuration file somewhere that can't directly expose an error. Then, at worst the user would see an error like db_connect_real_mysqli($user, $pass, $server)<|eor|><|eols|><|endoftext|> | 7 |
lolphp | jms87 | daix0kv | <|sols|><|sot|>Opencart, a PHP-based e-commerce platform, will expose DB passwords to users if the MySQL server is down and error reporting hasn't been turned off<|eot|><|sol|>https://github.com/opencart/opencart/issues/5027<|eol|><|sor|>This OpenCart one is egregious too: http://i.imgur.com/V3u9E5l.png<|eor|><|sor|>https://github.com/opencart/opencart/issues/1308
https://github.com/opencart/opencart/issues/1286
https://gist.github.com/uppfinnarn/9956023<|eor|><|sor|>I'm at a complete loss for words and have no idea how that guy develops anything having to do with real money.<|eor|><|eols|><|endoftext|> | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.