« first day (1749 days earlier)      last day (3199 days later) » 

10:00 PM
nah, it does nothing interesting
 
nope
 
it has standard zpp
I wonder what === does for arrays
that might be the trick
 
It'd been obvious if it were compared $input === $user[1] … but that array… no way.
 
huh what
the manual already has <=> and ??
and intdiv!
and the documentation is even incorrect!
> Warning: intdiv(): Division by zero in %s on line 9
> bool(false)
> %s
 
that's outdated, not incorrect.
 
10:02 PM
> Warning:
@bwoebi Note the %s.
 
@Andrea If you're wondering whether the strictness propagates: It does
 
I suppose the file was named %s :-D
 
@NikiC no, not that
arrays compare by order
not by keys
 
the keys are also checked
 
ah, hmm, yeah
$ php -r 'var_dump([1 => 0, 0 => 1] === [0, 1]);'
bool(false)
 
10:04 PM
notwithstanding the issue posted above
 
issue?
 
Ah
hmmm
does explode produce weird arrays, I wonder?
Nope.
 
looool
we're all thinking too complicated
06e2b745f3124f7d670f78eabaa94809 reverses to hund
Which means we at least have a valid user ^^
 
that doesn't get us in as admin
 
10:10 PM
It doesn't, but we at least reach that codepath with the suspicious +0 ^^
 
there's nothing we can do there
thanks to the ===
 
@NikiC yeah, but $input[0] must be equal to "5" because the ===
 
we can't do 0x5 or something
 
@bwoebi Which is where my trick comes in
 
hmm
if ($uid == 0) {
 
10:12 PM
We submit [0x100000000 => "5", md5("hund")]
It will pass the === and $uid, but the $input[0] lookup will be null
So we get uid = 0
 
ooh
 
let me try that...
 
OK, I'll try that
 
Actually, I don't have PHP 5.4 :D
 
@NikiC try 3v4l?
 
10:14 PM
oh, right, ancient PHP
@bwoebi I will
 
yep, it works
 
oh.
heh, it doesn't on 3v4l ^^
 
@Andrea drop the md5
 
oh, right :p
 
^^
 
10:20 PM
sent a mail to stefan...
 
well, that took an embarrassingly long time
 
nah, it's a tricky one
 
actually… Nikita is the only one to know about that issue … and nobody tried to reverse-check any of the hashes…
 
congrats @NikiC... you can haz SECRETS...
Please use your powers wisely
 
10:24 PM
Enjoy..
 
Also, one offs like that with arrays are crazy rare
I remember that array overflow issue took me like a month to debug
 
> * Becoming any other user is not good enough, but a first step.
^ Oh, stefan added a hint in the meanwhile…
I got one correct solution so far and I am not surprised at all by who submitted it…
 
Hi all, I'm trying to generate a random 6digit code per user and this is my code pastebin.com/DXxZzN0Y - so far it generates and saves to db etc but how can I make it so that if a user_id on the table has a unique_code don't generate a new one?
 
@Ekin What is the code used for?
 
You could use a composite key
 
10:29 PM
@bwoebi I wonder if the fix shouldn't be backported to 5.4
 
the and part in the query doesnt do anything. I'm trying to generate a random unique code when someone fills a form. Then it will be added to the url for social sharing etc and the user will gain a point in the system per share
 
It is kinda a security problem...
 
@NikiC well, at least with that challenge you have a demonstration why it's a security issue.
so, yes, good idea.
 
@Sherif Are you referring to something like this? pastebin.com/SgrjTDhu
 
@Ekin That would be a composite key, yes, but upon looking at your code I don't think that's what you're looking for. I think you just want a unique constraint on that firstID field and a timestamp to check when it was last generated.
 
10:36 PM
@bwoebi okay, sent stas a mail
 
@NikiC thanks :-)
 
unique and random are kind of disparate concepts
 
Oh right, that makes sense, thanks @Sherif
 
You can randomly select a value from a unique set, but you can't randomly generate a value that is guaranteed to be unique to a given set.
 
would it be better to use uniqid() then?
 
10:42 PM
Kind of, not really. You still have no guarantee it will be unique.
Given enough concurrent requests to the server in a narrow enough window, you still have a very tiny possibility of collision. The "Good Enough" approach is to set a unique constraint on the schema and have a retry attempt if the UPDATE fails then ensure more remote failure by increasing the entropy/key-space
The better approach would be to generate a finite set, which is then guaranteed to be unique, and randomly select a value from that. i.e. removing the value from the set and thus preventing its reuse.
 
Alright I think I'll go with the better approach , about unique code per user I was thinking I can do like if the userID is already on the table then dont generate a new one
Anyway, thanks a lot for clarifying again
 
You have to be careful with that. A primary key serves a very different purpose in your database though. It's meant to uniquely identify that user's row in the table. If suddenly you need to change whatever this token is being used for you could put yourself into a logical inconsistency scenario or break a transitive functional dependency.
It's best to steer clear of those, especially early on.
The rule of thumb is generally to not use the same column for more than one thing. If a single column has more than one meaning to the entity, it's not 1NF.
 
11:01 PM
The table will be only for the userID and the unique_code and I'll be only using it to retrieve those columns. For any other functionality etc I'll be only using the retrieved value of userID from there and match it in the main users table etc. If the userId is the primary key on the table, and the unique_codes won't change after they are created then it should be okay?
 
@Ekin why are you not using prepared statements ?
 
looks like Harry Potter for adults.
 
It's not for production yet I'll be using it, now I'm just on the points etc part
 
@tereško I did not really like the books
 
hmm , that's troubling
 
11:09 PM
But I've been told that those books have a split where people either go "this is crap" or "this is totally awesome"
 
@NikiC well .. so were Twilight
you see the problem
@Ekin why should it be random key? It's not like there would be any harm from someone populating a user-link by making it
it would be easier just to make the "random strong" from encoded userID + postID
or you could just do it like StackOverflow: add the userID in plain text to the link
 
I have a requirement to use 6digit numbers for the codes so cant use userIDs, plus that code was my first try
 
you can pad the code
 
you mean padding the user id?
 
str_pad($userId, 6, "0", STR_PAD_LEFT);
 
11:22 PM
Yeah that would solve the unique generation, right right right
 
I think your right key is stuck
 
@PeeHaa how's your beer?
 
Empty. I switched to whisky an hour ago
 
it was, actually lol a wiseman
 
is "Scalar Type Hints, Episode V: A New Hope" a good talk title
 
11:30 PM
you should name it "Scalar Type Hints: Phantom Menace" ... and claim it that you named it after your favourite star trek movie
5
that would leave an impression
 
@tereško lol
@Andrea Make that Episode VII
 
@NikiC because v5!
Scalar Type Hints, Episode V: The ____ Strikes Back
What would the blank be?
 
Zeev
 
that's a little too personal :p
 
eevz ?
 
11:34 PM
Also, I misread those roman numerals (oh dear). I was thinking V for v5. VII also makes sense, for 7
@tereško No
OH
Scalar Type Hints, Episode III: Revenge of the Strict
 
"The Wrath of Zeev"
.. though that would imply that he's superhuman
"Nemesis"?
 
heh
 
I've heard nothing from Zeev since May…
 
"PHP catches the STD bug... how to deal with it"
perfect title
 
I was trying to work out something containing "getting a hint"
 
11:43 PM
@Andrea what's std referring to now?
 
"Temporary title here"
 
@bwoebi Scalar Type Disease
No, Sexually Transmitted Declaration
 
too complicated .. you would end up trying to explain the title
 
no... I'm sure I'm somewhere close
hmm
declare(strict_types=1);
perfect title
:p
 
What exactly are you really going to talk about?
 
11:46 PM
the current idea is to talk about scalar type hints
the story, and the usage
 
"take a hint"
 
@tereško hah! I like that one
 
How many RFCs were there about the scalar types? 5?
 
More.
 
I mean during PHP 7 development time.
 
11:50 PM
Er, probably around that number
Dual mode (adopted), weak mode, Anthony's old one which I had ruined, that weird docblocks monstrosity, some other one
 
@Andrea the "some other one" is mine?
so… 5.
 
I forget how yours worked
 
@Andrea basically Anthonys old one with a few minor changes I think.
 
ah
I'm not sure I'd count it, I mean, Zeev revived the weak one IIRC
 
"Chronicles of Salt" seems quite fitting too
 
11:55 PM
heh
also perhaps a bit too provocative
 
... and thus would bring more people
 
hah
maybe I should play it up
"In this talk, you'll hear the TRUE STORY of how PHP defied its principles and became like Java. It's a story of big egos, backroom dealings, and public outrage."
or something
 
people outside of internals "orbit" only have a slight notion that there was some drama going on, but majority was basically in the dark
 

« first day (1749 days earlier)      last day (3199 days later) »