« first day (3198 days earlier)      last day (1741 days later) » 

2:56 AM
Uploading 8TB over a 20Mbps connection :/ no fun
ETA: 5 weeks, 3 days, 23 hours, 11 minutes, 19 seconds
 
@Sherif why would you inflict such pain upon yourself
 
@Tiffany Don't really have a choice. Migrating a now decommissioned server to S3.
That's all access log data
 
carrier pigeon would be faster
 
Indeed. I could I literally drive down to the data center, yank the harddrive, mail it to amazon via fedex, and it would take less time.
 
can a patch which just adds an optional arg to a function and doesn't break BC target 7.2? (i.e. all current branches)
 
3:06 AM
@DaveRandom I don't see why not. We've done it before.
This is PHP. There are no rules? [except for rule #1, of course, which says there are no rules]
 
specifically I want to add an additional int arg to php.net/manual/en/function.socket-get-option.php which specifies the size of a block of memory to alloc, which will be used as optval and returned as a string
which I concede is a little insane
but atm there's no way to retrieve arbitrary options unless they are ints
 
In the middle of a minor release?
Sounds like it'd be better
 
it's not a BC break in any way though
 
@DaveRandom what are you doing
(genuinely curious, though mildly confused)
 
trying to get the uid of the remote end of an AF_UNIX socket
to answer your next question... because reasons :-P
 
3:12 AM
morning
 
@JoeWatkins the very man... thoughts on chat.stackoverflow.com/transcript/message/46805384#46805384 ?
also hello :-P
<3
du
ffs
 
yes
it's a function, not a method ?
 
10 mins ago, by DaveRandom
specifically I want to add an additional int arg to https://www.php.net/manual/en/function.socket-get-option.php which specifies the size of a block of memory to alloc, which will be used as optval and returned as a string
9 mins ago, by DaveRandom
which I concede is a little insane
 
you're being crazy
 
do you have a better suggestion for how to do that for arbitrary opts?
(genuine question)
 
3:22 AM
there is no such thing as arbitrary options, the function will refused unrecognized ones, so fix the internal implementation of sockopt to use the correct optlen, the required lengths are documented
 
@JoeWatkins nope
and there's just too many possibilities to implement everything
plus a crapload of non-standard stuff
 
@DaveRandom what am I supposed to see ?
 
yes, I absolutely could implement the specific thing I want, but that's one of thousands
> the function will refused unrecognized ones
^ it won't
it just assumes they are ints
 
man setsockopt
ENOPROTOOPT
 
give me 10 mins, code will make it clearer I think (plus I want to test my theory)
 
3:27 AM
> An option that is directed to the SOL_SOCKET level always completes successfully.
oh
still, if it's complex to do internally, I don't know what you think you achieve by handing that complexity over to user land ?
 
@JoeWatkins ext/sockets is inherently extremely technical and not very portable... I agree that it's a pretty niche thing, but nevertheless this is not the first time I have wanted it...
also I think it's simpler than you think
5mins
 
the complexity I'm talking about is not in the implementation
you said it was difficult to do internally because there are so many options
there are the same number of options in user land
 
Good morning
 
yes but that's already true - you can already retrieve arbitrary options, but atm they have to be ints. All I'm doing is providing a way to get non-int values
 
can you give me an example where this would be useful ? aren't non integers typically structs ?
 
3:41 AM
moment
let me make sure it actually works how I think it will then I will explain
 
3:58 AM
@DaveRandom this is a really long moment
 
oi
 
How should one be dealing with exceptions thrown on trying to insert duplicate value in unique field in mysql? Do I have better options than checking the error code? And how do I find the offending unique field name?
 
4:52 AM
You can do an SQL rollback stackoverflow.com/questions/18502802/…
 
5:35 AM
morns
 
@JoeWatkins /me waves
 
hi
 
@mega6382 how do I notify the user that a field like email already has been used?
 
Gently
 
6:10 AM
@bwoebi \o
 
@JoeWatkins o/
@JoeWatkins you had any love for ptrace() recently?
 
I've worked on it a little, but got a couple of work projects on at the moment that are taking up lots of time
 
That's cool to hear
 
 
1 hour later…
7:14 AM
word
 
7:39 AM
@2dsharp if email exists, send an error message to front-end: email already exists or something of that variation. Granted, I don't know how efficient it would be.
Database queries can be...performance heavy, and I have no experience in optimizing them
There's also the security concern: do you want the user to know that the email exists already? are you giving a potential hacker useful information?
@Tiffany I think the term I was looking for its database transaction, not query. But it's late and well past bedtime.
 
8:00 AM
gnomic characterized by aphorism
 
@Tiffany The problem with this approach (which I am currently using) is that it can cause potential race conditions. The database should instead be enforcing the constraint while inserting - which is fine when I am working on the console, but PHP doesn't seem to have a bridge to handle the generic exception.
The only solution I have found till now is error codes, but they are confusing and to figure out the field name I would have to do some regex magic on the error message, which just doesn't feel correct.
 
Wes
8:30 AM
mornings
we'll soon be useless twitter.com/aruslan/status/1151914744053297152 ide auto completition trained with github repos writes code almost automatically
 
@Wes Sounds like the beginning of the Epilogue to Life 3.0
Also, it doesn't support PHP. Boo!
 
Wes
i'm pretty sure that would end up creating skynet
 
If skynet were written in php it would be so easy to defeat
 
Wes
9:21 AM
:D
btw edward furlong will be in the next terminator movie
 
Oh look at that. Another child actor that looks 20 years older than they really are and 60 lbs overweight.
The guy looks like a meth addict and his girlfriend looks like she just got out of rehab
 
Wes
dude had problems with drugs, the new terminator movie means he's fine now
 
Are they really sure about casting this guy?
 
Wes
drugs can do that, but he looks ok now pbs.twimg.com/media/D_yI9nTXoAA6Ezo?format=jpg&name=large
 
9:46 AM
@Sherif after hollywood cast Robert Pattinson as the new BatMan, I am pretty sure they don't know jack about casting
 
Robert Pattinson is the new Batman?
dafuq is happening to the world
 
Yes. Their line of thought must be like: BatMan -> Bat -> Vampires -> Pattinson
there are multiple online petitions to remove him, but we all know it won't happen
 
Wes
10:09 AM
they are trying everything to gain new audiences... except audiences just want good entertainment
for example there is this thing of women taking roles historically associated to men. i don't think they did any good to egalitarianism when they rebooted ghostbusters with women. maybe they should focus on writing good stories before trying to shook us with casting
 
10:24 AM
Yea, Ocean's 8 was sorely disappointing.
 
Wes
10:34 AM
*shock
 
Wes
10:45 AM
that said, i don't have anything against robert pattinson. maybe he's a good actor that has had the bad luck of getting associated to twilight. maybe he will do a good batman. it can't be worse than ben affleck :B
 
That's what I said about Ben Affleck
 
@bwoebi So, how badly do you think will github.com/php/php-src/pull/4433 break things?
 
11:10 AM
Hi , help in AWS?
 
11:32 AM
@Sherif they have a service for that - aws.amazon.com/snowball/disk/details
 
@NikiC I think this should be pretty safe.
@NikiC is this in preparation to properly exposing the return code of stream write ops?
 
@bwoebi for now not
Though we should also do that
 
@NikiC because that is quite absymal currently - you basically have to parse the error message to get any information...
 
11:47 AM
I also looked into propagating read errors, but the situation there is quite a bit more complicated, I'm afraid to do that in 7.4.
@bwoebi yeah, that sucks. like everything about streams :)
 
@NikiC I'd prefer to have both at once though - hm
 
yeah
I'll try to do the reads as well ... I think we can always relatively easily revert this by dropping errors at the stream_read level while keeping the internal API changes, if it turns out that it causes too many issues.
 
Wes
12:09 PM
earthquake in athens
 
Good morning
 
12:42 PM
Different results between 7.3.7 and 7.4 – #78312
 
> Expected result:
----------------
-

Actual result:
--------------
-
 
12:59 PM
so the actual results meet the expectation. great.
 
people being lazy. I've actually considered adding a 'report as bug' on the 3v4l output (with correctly filled example/expected/actual output) but I'm afraid too many people will abuse it
 
1:49 PM
What's wrong with people... metro.co.uk/2019/07/18/…
 
Wes
\o
 
2:09 PM
can anyone recommend a faster/small ORM package?
 
@bwoebi What would the correct behavior of fread on end of file be? Returning an empty string, right?
 
@NikiC that#s what I expect on EOF, and only on EOF, yes
 
@bwoebi What about a non-blocking read where no data is available?
 
false = failure, empty string = eof, non-empty string = data
@NikiC that case shall also be eof, right
 
@bwoebi Is there a good way to test that case?
Because I don't think I handle it right now but things aren't failing ^^
 
2:18 PM
@NikiC stream_socket_pair(), set to blocking=false and read from it?
 
hm yeah, returns false instead of "" right now
will have to special-case that
 
2:30 PM
@bwoebi Any way to test the same for plain files?
I'm also wondering if EINTR should also fall under the same exception?
And also, can this be tested for write operations?
 
Wes
2:49 PM
TIL levi is not a kitten
 
Nope, not a kitten.
Surprise!
 
@NikiC uh, plain files and non blocking? avoid that :-D
@NikiC the only possibly interesting case are stdio fds - i.e. stdin/stderr etc. (pipes)
 
3:10 PM
yeah, I think stdio is the main interesting case there
@bwoebi What do you think about EINTR handling?
 
@NikiC I'm not sure - sometimes I expect syscalls to be restarted, and sometimes it annoys me
 
Anyone recently used asan on PHP 7.3 successfully?
 
@bwoebi Assuming they are not restarted, should EINTR return false or ""?
 
$ php -v
PHP 7.3.6 (cli) (built: Jul 19 2019 12:30:30) ( NTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
==6891==LeakSanitizer has encountered a fatal error.
==6891==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==6891==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
 
@NikiC false
with the possibility to inspect
I want "" to be unique to non-blocking and EOF
 
3:14 PM
@bwoebi why false though? It feels like a similar case to EAGAIN
 
so that I can trivially check
 
huh looks like we currently do a single retry on EINTR read ^^
 
because EAGAIN is expected, EINTR usually is not
i.e. when you operate on a non-blocking socket, you do expect "" if not triggered by a stream_select()
when you are using fread() after stream_select reported your fd as readable or on a blocking socket, you expect "" to be EOF
 
I see
 
Ah, my issue appears to be because I was in an unprivileged docker container.
 
3:19 PM
@LeviMorrison Use php 7.4
 
Will do, as soon as I figure out how to add this to my team's complicated (at least to me) docker compose setup.
 
@JoeWatkins I ended up having to sleep, my brain wasn't working
 
It looks like this one file can build numerous versions and option combos of PHP, which is why it's a bit more complicated. Now I need to make it more complicated due to s/--enable-maintainer-zts/--enable-zts/, probably among other things.
 
I will finish it up later though
 
@LeviMorrison yeah, that one is annoying, should've been an alias and removed in a couple of years
 
3:26 PM
It's not too late to alias it, right?
 
I'm not opposing
 
Alias sounds reasonable ... we did rename some other stuff as well though
@bwoebi If you want to review... github.com/php/php-src/pull/4442
@LeviMorrison If you're on 7.4 you can pass --asan to run-tests
 
@NikiC will do soon
 
There's also -DZEND_TRACK_ARENA_ALLOC to get more coverage, though if you don't use the arena allocator then it won't matter
 
" 0 / 56 files viewed" :-D
 
3:53 PM
php needs a code review ki like linux does with c++ ;_;
 
ki?
 
oh sorry AI
It does the very basic things but good enough to skip some work
 
4:07 PM
@LeviMorrison you change your avatar on the day that cats trailer is released......coincidence or something more sinister?
 
Coincidence :)
 
@Danack I know. I wasn't kidding about that :)
 
4:38 PM
@NikiC LGTM :-)
 
4:50 PM
Anyone know of a potentially better way to do this with Intl? gist.github.com/srgoogleguy/1f17d1eed2f4967e71d563fe8e0f5b7b
 
Is there a reason that returning a value from a constructor doesn't throw an Error? 3v4l.org/B6Thg
 
I read a post about names on reddit. They got crazy with "did you assume the case of my name?"
 
@AllenJB Is there a reason it's supposed to?
 
@Sherif It doesn't do anything useful - as far as I can tell there's no way to retrieve a value returned from a constructor
 
@AllenJB If not doing something useful were a reason to give an error we should have a lot more errrors
Empty statements are also not useful, but NOOP sounds more reasonable than giving an error to me
$foo = 1; return 1; is equally unuseful, but the compiler can now just optimize that out
No reason to give errors
 
4:58 PM
Its not a common error someone tries that.? I never saw that.
 
I mean, it's also not like any reasonable person would /expect/ a constructor to return a value anyway.
 
Granted it's not something I recall seeing people try to do often, but apparently people do do it: old.reddit.com/r/webdev/comments/cf9l3h/…
 
I never put it past people on the Internet to do crazy things
 
wtf
that is horrible copy paste code and he wants someone to fix it so he has no work todo
"This has to move to a class"
 
They're getting no error - which I'm guessing is because the curl request is failing in some way, trying to return a string error message, but the code constructing the object will never receive that string - just an object with missing information
 
5:03 PM
Probably they should be read a tutorial about classes instead an error.
 
Yes, this person is clearly not very well versed in software design. They should have thrown an Exception, but hey, they're on Reddit... what'd you expect?
 
If they are on that level no error would fix that
 
News flash: Most developers aren't very well versed in software design. Those who are newbies even more so.
 
Trying to return error information as a string from a function is bad enough. Expecting it to return from a constructor is just icing on the cake.
 
An error on return from a constructor would tell them "this code can't possibly do what you intend it to"
 
5:04 PM
Would it though?
 
ReactJS has some pretty good learning exceptions but php is not like that
 
I posit that a little testing and common sense would do the same, but ¯_(ツ)_/¯
... who tests code these days
 
sherif is right. it would mean that there are a lot of exceptions missing.
how is he even receiving the return value? at that point he should have looked up a tutorial in the internet
 
@AllenJB I don't actually think there is any major harm in PHP giving a WARNING in this case, but I don't actually think there's a major benefit either.
I'd venture a wild guess that the percentage of people this would actually help is statistically negligible.
 
@AllenJB Possibly because it's theoretically possible to directly call a constructor
Though I would agree that returning from a ctor warrants a warning
 
5:11 PM
PHP will error if you try to declare a return type: 3v4l.org/rsikK
 
That makes sense since it can't enforce the return type check
 
you have to return string!
:D
im more for not allowing to call a constructor like that
 
hello
what's wrong in this code guys
<?php
//Enter your code here, enjoy!
/* Write your PHP code here */
class Person{
private $name;

public function getName(){
return $this->$name;
}

public function setName($name){
$this->name = $name;
}
}



//Instantiate the Person object.
$person = new Person();

//Set the name to "Wayne"
$person->setName('Wayne');

//Get the person's name.
$name = $person->getName();

//Print it out
echo $name;
?>
 
@EduardoHerrera be specific
what do you mean "what's wrong" with it?
 
@EduardoHerrera return $this->$name;
 
ThW
5:15 PM
@EduardoHerrera your error reporting is to low or disabled.
 
> How should one be dealing with exceptions thrown on trying to insert duplicate value in unique field in mysql? Do I have better options than checking the error code? And how do I find the offending unique field name?
Still haven't found an answer to this yet. Much appreciated if someone helps me find a nice solution. :/
 
hahahhaa
i got it
 
ThW
@EduardoHerrera 3v4l.org/oiUhP
 
@2dsharp I have a PDO wrapper (actually it extends to Aura.Sql) that converts exceptions into more specific ones (eg. I have one for deadlocks). This at least keeps that code centralized
 
5:20 PM
@2dsharp Umm, better how exactly? Not sure I follow how retrieving error information can be improved upon. Also, I think your understanding of SQL is flawed if you're trying to handle a duplicate key insert failure at runtime. SQL schemas are a way of providing an answer before we've asked a question. By that logic, you should already know which field is the constraining requirement before the INSERT even happens.
The idea that you wish to figure this out at runtime (and not for debug purposes) is rather alarming.
 
@Sherif If I am trying to insert a record that needs two unique fields, PDO throws an exception with a message that one of those fields have a unique constraint and I am trying to enter a duplicate key. In that case, I haven't really figured out another way to find the offending field out of the two without running some regex on the exception message.
 
@2dsharp Why do you have two unique constraints in the same row?
 
@Sherif For eg: username, email
 
How is username different from email?
 
5:25 PM
@Sherif My stackoverflow username is "2dsharp", my email address is something else.
 
@2dsharp But your stackoverflow username is not unique
Only one of those things uniquely identifies you
Do you see my point?
 
@Sherif I don't think I understand you. Could you please elaborate?
 
return from constructor should trigger an error or warning – #78313
 
@2dsharp Are you familiar with database normalization 1NF/2NF/3NF?
 
@AllenJB I gave it a thought, but I was wondering if extending PDO would really be a good idea or not.
@Sherif Yes, to some extent.
 
5:29 PM
@2dsharp OK, well there is a basic premise in relational theory that there should only be one way to find the prime attribute (that is one primary key whether it's composite or not).
What you have done is created two distinct prime attributes in the same row.
If I can say for sure that both your username and your email are unique then I can find you by either one, right?
 
@Sherif Right.
 
There can only be one user1 and there can only be one user1@gmail.com
So then you have to ask yourself, why do I need both?
If the purpose of having a unique email or unique username is to uniquely identify the user (prime attribute of user), then surely we only need one of those?
Right?
Makes no sense to have two of them. That's just redundant.
 
Yes, so when we are looking at allowing logins through both username and email address, how should I structure my table in that case?
 
@2dsharp You separate it into two tables.
This is called 1NF
But again, I posit that you don't need both. You're only making things more complicated for yourself and for your users unnecessarily.
Why should I have to remember two different ways to login?
 
Well, many websites do provide (including twitter, facebook, github etc.) a way to log in using username/email/phone number these days.
 
5:39 PM
@2dsharp facebook doesn't have a concept of usernames.
 
@Sherif Phone numbers and email addresses for Facebook.
I think.
 
Yes, they started with email because it's tied to your identity. When they acquired whatsapp (who didn't store emails/usernames) they had to also take in phone numbers.
Both of those things are tied to your identity though a non-redundant way.
 
@Sherif I am pretty sure they allowed phone numbers long before Whatsapp.
 
What you're doing is entirely redundant, however.
@2dsharp Nope.
You couldn't log in with your phone number, but you could store it in your profile.
 
@Sherif imgur.com/a/nndEgqi: Aug 2019. Facebook didn't acquire Whatsapp until 2014 iirc.
Also that's part of the problem. I was trying to find a better way than use magic numbers that are thrown MySQL via PDO exceptions to handle and inform the user.
 
5:52 PM
The better way is to split it up into two tables.
 
@Sherif What does it have to do with MySQL error codes in the PDO exception?
 
I feel lie we're going in circles here.
 
I understand that I need to change the DB design while to accommodate the unique fields in separate tables. But that still does not change how PDO will throw an exception when there's a uniqueness constraint violation, I will have a message and a code.

My question still remains the same: Is there a better way than checking the error code for handling that exception and reporting to the user accordingly?
 
@2dsharp Better how, exactly? What about the error handling requires improvement here?
What needs to be made better in your opinion?
 
Wes
7:24 PM
the stock market is crazy
 
Growth stock mutual funds are more stable and reliable for growth.
 
8:00 PM
Is there a general name for the following problem (not sure what to google when looking for solution): There are 2 models - e.g. order and order item. Each order item has a price and you want to always keep the price of the order synchronized with its child items. What should I google when looking for solutions? I.e. how would you formulate a search query for a general variant of the problem?
I can think of some solutions - e.g. database triggers, model observers with laravel, observers + stored database procedures, etc. I'm just not sure what to search for when looking for a good solution
 
@PeterTheLobster The price of the order should be derived from the sum of the prices from its order items (children). Otherwise you have what's called a transitive dependency, i.e. violation of 3NF.
 
@Sherif Not sure what you mean. I want it to be derived from the children but I want it to be stored on the order so that I don't have to calculate it every time I need to see it.
i.e. I want it to be recalculated every time a child is created or updated. That shouldn't violate 3NF, no?
 
@PeterTheLobster You update the value each time you write to order items.
@PeterTheLobster No, if you're asking how to do it autonomously, perhaps you want to look into database stored procedures. But realistically, you're just performing a transactional write on update/create, which you can do from code.
 
8:17 PM
Yes that's what I mean. I'm looking for a good solution to do that but I don't know what to search for. i.e. I can't decide how to achieve that but don't know what to search for in terms of the general problem name.
 
@PeterTheLobster Look into database transactions
It's like this: You start a transaction -> you write to the order items table -> you update the order table -> then you commit the transaction if and only if everything was successful.
 
Yeah that's what I figured - db triggers / model observers / observers + stored procedures. But I wanted to see if there is some sort of a state of the art solution or implementation pattern but didn't know what to search for.
 
This prevents things like race conditions and such.
I mean, stored procedures are certainly one way to go about it, but they have their caveats.
Personally I'd just roll this into a transactional statement.
 
Yeah but I wanted something more automatic so I can rely on it always executing and not having to remember in every place in code where it might occur.
 
That should tell you that your code might need some better abstraction
 
8:22 PM
That's why I figured model observers in Laravel are a good choice but wasn't sure if there is a more appropriate solution.
 
No idea about Laravel, but transactions are definitely what you're after.
 
Yeah I figured as much. thanks
Now for a slightly different question. Prestashop used to have a warehouse managment system where they tracked stock movements in a table where each row recorded the quantity by which the stock changed. The weird thing was that the increase or decrease was tracked in one column with +1/-1 and the quantity was in a separate unsigned integer column. Why would one want to separate the +/- in it's own column?
 
To retain a source of truth.
In information systems design and theory, single source of truth (SSOT) is the practice of structuring information models and associated data schema such that every data element is mastered (or edited) in only one place. Any possible linkages to this data element (possibly in other areas of the relational schema or even in distant federated databases) are by reference only. Because all other locations of the data just refer back to the primary "source of truth" location, updates to the data element in the primary location propagate to the entire system without the possibility of a duplicate value...
 
Not sure how SSOT relates to it. I mean what's the benefit of storing e.g. -1 in one column and 451 in a second column instead of just storing -451
in a single column
 
Ah, I see. I might have misunderstood your question.
@PeterTheLobster 1NF states that we should not store more than one type of data in a single column. So if your business logic needs an increase or decrease in inventory means something, then it makes sense to keep it in its own column.
For instance, let's say we only want to ask the question "How many times has this item been taken OUT of inventory"
This does not involve information about the total quantity taken out.
@PeterTheLobster BTW, I strongly recommend the book SQL and Relational Theory: How to Write Accurate SQL Code By C. J. Date while we're on the topic.
> The real point I’m getting at here is that the notion of atomicity has no absolute meaning; it just depends on what we want to do with the data. Sometimes we want to deal with an entire set of part numbers as a single thing; sometimes we want to deal with we want to think about the subatomic particles (i.e., the protons, neutrons, and electrons) that make up those atoms.
> What’s more, protons and neutrons, at least, aren’t really indivisible, either—they contain a variety of “subsubatomic” particles called quarks. And so on, possibly (?).
- SQL and Relational Theory, How to Write Accurate SQL Code – C.J. Date -- Chapter 2, Page 50
@PeterTheLobster ^
 
8:50 PM
Alright, thanks :) I'll check it out
 
 
2 hours later…
10:42 PM
@PeterTheLobster storing events can also make systems be less vulnerable to fraud, and other types of bugs: youtube.com/watch?v=JHGkaShoyNs
 
11:22 PM
@Danack do you whatsapp? Could do with a brief private convo (not as ominous/exciting as it sounds)
would rather not twatter this specific thing
 
@DaveRandom I think I do.....technology like that scares me. I'll dm my number.
 
I have it unless you have changed it
ends 865?
 
yep.
but speak tomorrow lunch time when I'm more capapble of both thought and speech?
 
kk cool, I'll put messages in there and just pick it up whenever, not super urgent
 

« first day (3198 days earlier)      last day (1741 days later) »