« first day (1867 days earlier)      last day (3075 days later) » 

5:05 PM
posted on November 26, 2015 by nlecointre

/* by aurelien */

 
5:18 PM
Structs in PHP – cannot extend any other struct or class – can implement interfaces – can have methods. Thoughts? /cc @Andrea @bwoebi @NikiC @ircmaxell @rdlowrey @Danack
And do you think copy on write could work with the "can implement interfaces" aspect?
 
user895378
what's the point in having them if they can have methods?
 
user895378
Also: happy thanksgiving
 
@rdlowrey Same to you, mate.
 
@rdlowrey also: morning
 
My thinking is that they could have value semantics (like arrays). This has a number of benefits.
 
5:20 PM
@LeviMorrison why can't they extend?
@LeviMorrison copy on write could work with all of it. look at PHP 4
it lacked interfaces, sure, but only for lack of imagination
 
@Andrea I can't really explain it right now (haven't completely formed it all out in my mind) – but at least you can look at C# and they chose that route.
But I think they probably did that because value types are stack allocated.
 
Abe
@LeviMorrison isn't that a final class, basically?
 
Being able to extend (or be extended) makes that difficult.
@Abe That list is, I guess.
But not value semantics.
 
I FOUND A NEW HOUSE
13
 
@LeviMorrison I don't really see why but okay
 
5:24 PM
@JoeWatkins :D Congratulations!
 
sorry for shouting ... but but ... it has a river in the back garden ...
 
I mean C++ lets you do inheritance and it has stack allocs
@JoeWatkins yay!
 
Abe
@LeviMorrison field type declarations?
 
@JoeWatkins make little paper boats for your elePHPants
 
5:25 PM
@Andrea It has a lovely feature called type slicing too ;)
 
or jetskis ...
 
@LeviMorrison I'd just explicitly clone then when needed instead of this?
 
@JoeWatkins Congrats!
 
@JoeWatkins where? :-)
 
on the island still ...
 
5:26 PM
@bwoebi Perhaps.
 
Congratulations @JoeWatkins
 
@JoeWatkins you don't have a house currently?
 
Abe
congrats @JoeWatkins :D
 
river at the bottom of the garden means you can have rubber duck races, or play pooh sticks
 
yeah but we got notice to move by end of January, and I thought better to get it sorted, so started looking a couple of weeks ago
 
5:29 PM
@JoeWatkins ah congrats then :-)
 
@LeviMorrison type slicing?
hmm
 
@rdlowrey Your life's busy? :-)
 
we should make a standalone $ be a valid variable
the $_ of PHP
 
user895378
@bwoebi It has been very busy :/
 
user895378
5:30 PM
I'm trying to finish up this one work thing ... it's been sucking up all of my time.
 
@Andrea Well, I misspoke: it's object slicing.
 
what is that and how does that work?
 
user895378
@bwoebi Next (after this weekend) I'm hoping to start in on a work project with aerys. Will have to finish up the postgres lib to do so.
 
@rdlowrey /me waits for further amphp/pgsql commits ;-) … Yeah, it's annoying to have to finish something and not being able to push it to later…
 
@Andrea This is exciting! Just a second!
Bah, I haven't found any resources that I particularly like.
Oh well:
365
Q: What is object slicing?

FrankomaniaSomeone mentioned it in the IRC, but google doesn't have a good answer.

 
Abe
5:36 PM
@LeviMorrison is that a reference type change only, or object gets copied and excess data stripped off?
 
Anyway, object slicing occurs because of the base class and subclass mismatch. If you allocate space on the stack you have this issue. You can avoid it by using pointers or references or by forbidding subclasses.
In PHP we don't have pointers and our references are a different thing.
So forbidding subclasses (and superclasses) like C# does seems like a good idea if we pursue structs.
 
@LeviMorrison ah, now I understand the problem
@LeviMorrison we don't have objects on the stack, I don't think we need to forbid subclasses
 
It would allow some optimizations (but this may not matter)
@Andrea But it would prevent us from actually doing that.
There's been a decent amount of talk about a JIT in our future, so it may actually matter.
But maybe not.
 
eh
I mean it's not like this prevents optimisation entirely
we can just only do it for final classes
 
Anyway, the more and more I use value types in C++ the more I like them.
So it was just an idea.
 
5:44 PM
@LeviMorrison I like them because they're very PHP
in a good way
arrays and strings in PHP are nice
anyway, afk
 
I wasn't participating in the PHP 4 to PHP 5 days.
I'm not completely sure why we moved away from value classes.
I suspect it was actually a problem with references.
Anyone know?
 
I've forgotten how php5 works ...
I think it was consumption actually, but don't quote me on it @LeviMorrison
see niki has been busy fixing stuff ... stuff most of us (probably, me, at least) hadn't thought of ...
 
6:04 PM
'morning
 
Anonymous
evening
 
@LeviMorrison playing annoying internals thread-shitter devil advocate, how would this be different from just using final on a class that doesn't extend another class?
 
wow, wait, when did this little gem php.net/manual/en/closure.call.php got in :D
 
@LeviMorrison to avoid having to use references everywhere, AIUI
 
6:21 PM
hai. how compile php with opcache
is it just --enable-opcache and then I just need a php.ini specifying the opcache.so location?
 
user895378
6:53 PM
@AwalGarg @Andrea was kind enough to add that for us
 
^^
 
thanks @Andrea!
 
user895378
It's pretty great if you're microoptimizing closure rebinds for max performance
 
I mostly just like its convenience
$foo->call($bar, $qux) could have been written $foo->bindTo($bar)($qux) in PHP 7 anyway
 
I saw it on the "php migration" page. Initially I was awestruck (because this points us slightly in the FP direction :P), then I was scared because it didn't mention the args list. Then I saw the full documentation page and felt really happy for this addition :)
 
7:00 PM
@Andrea not quite… It'd be $foo->bindTo($bar, get_class($bar))($baz) … (first baz, then qux :-P)
 
7:20 PM
@Andrea - Thanks, looks like it could be useful
 
Very useful ^ cc @PeeHaa @DaveRandom
 
7:37 PM
Can someone here who has the access update the docs for 'header' secure.php.net/manual/en/… so instead of saying it is a string say it can be a string or an array?
 
@crypticツ You can edit on edit.php.net
 
@kelunik do I edit 'doc-base' or just 'en'?
 
I don't know. ^ @salathe?
 
Deadly sins if you work with buffers… concatenate everything (especially if the two strings might be larger than 1 KB…) and using substr() after every few bytes to shrink a larger buffer…
github.com/amphp/aerys/commit/… … I wouldn't be surprised when this speeds header parsing up by more than 100%…
 
@crypticツ My last contribution was editing "en" (and it worked)
 
7:51 PM
@crypticツ en.
 
<varlistentry xml:id="context.http.header">
 <term>
  <parameter>header</parameter>
  <type>array</type>
  <type>string</type>
 </term>
 <listitem>
like that?
 
shouldn't it be mixed? (I have very little experience with this, so I am most likely wrong)
 
@bwoebi I have an issue in scalar_objects, not sure how to solve
 
@AwalGarg I have no idea. Are there docs on the docs?
 
I use an indirection function (similar to how closure __invoke is handled and how __call etc used to work) to convert $scalar->method($x) to ScalarHandler::method($scalar, $x). For that I need to pass the $scalar to the indirection function somehow
In PHP 5 I could just pass it through EG(This). In PHP 7 EX(This) has to be an object. So now I'm passing it as part of the indirection function (appended to the internal function structure). The problem with this is that the value will not be destroyed if an exception is thrown during argument passing
 
8:02 PM
@crypticツ not that I know off. my guess is that the currently existing docs serve as the "watch and learn" meta-docs.
 
It doesn't really matter for practical purposes, but I wonder if you know some way to avoid that leak @bwoebi
 
Wonder if somebody could help me please (not sure if it can be done using PHP or not)

I'm trying to store input from a text field as a variable without having to pass the variable through another page? Can someone please direct me to how this is possible
 
@methhead This is unclear, are you talking about dirty global variables ?
 
Sorry, basically I have an input field and submit button. I also have SQL queries on the same page depending on a variable (from text field) to run the queries. So I want a way for a user to be able to enter a string and submit, which would then save the string on the same page under the variable which will allow the queries in SQL to run. If that makes sense?
 
@methhead have you tried using sessions? php.net/manual/en/session.examples.basic.php
 
8:10 PM
@NikiC you're working on scalar methods again?
 
@NikiC Can you point me to how the indirection method looks like?
 
No @danack I havn't looked at sessions before. I'll take a look now, thanks :)
 
@Andrea I guess he's just talking about his ext
 
yeah, but...
 
@bwoebi github.com/nikic/scalar_objects/blob/master/… I warn you upfront that this is mixed 5&7 code
 
8:11 PM
oh right that reminds me I still need to figure out how to compile opcache
#ifdef ZEND_ENGINE_3
 
@NikiC crisis :-D
 
@kelunik You rang?
 
:)
 
31 mins ago, by cryptic ツ
@kelunik do I edit 'doc-base' or just 'en'?
 
@crypticツ an " or " between the two types would read better :)
Oh you changed it to mixed
I'd change it back to the two types, mixed is only commonly used for the function prototypes.
so, "<type>array</type> or <type>string</type>" would be fab
 
8:15 PM
:/
 
@NikiC uhm, why don't you just push $scalar as first arg to the vm stack?
 
@bwoebi Because stack offsets are hardcoded
Or not hardcoded, but the offsets in the send opcodes are fixed
It's not based off top of the stack or something
 
right…
 
hmm
here's an alternative implementation strategy
create a dummy proxy object which you keep around
rewrite (123)->foo(...) to $dummy->foo(...) and give it (123) somehow by a side-channel
(yes this is a giant hack :p)
 
8:25 PM
@MadaraUchiha looks cool
 
well, you could have an object to put into EX(This) … with a destructor freeing the held scalar @NikiC … but well, it'd mean an extra emalloc()…
 
Happy almost friday close enough room 11
 
=) \o/ yeah!
thanks and to you too @PeeHaa
 
@NikiC something else… your hashdos patch… it's not possible to throw an exception inside zend_hash_find_bucket(), because it might be inside code relying on some entry existing or similar… right? And a hard fatal isn't an option too, I guess.
 
@bwoebi Yeah, that would be possible. But sounds like too expensive for this kind of edge case
@bwoebi I don't think we can throw an exception there. There's just too many places where it might happen. Why is a hard fatal not an option?
 
8:30 PM
@NikiC See my response, issues with long running scripts.
 
@NikiC Niklas mentioned it on list… things like Aerys.
 
@bwoebi I see... Still seems like you'd be better off
Restarting a worker is cheaper than hashdos ^^
 
but server is still unavailable either way :-P
not much a difference from an user perspective ^^
Also, how much of a complication are self-balancing btrees?
Also… how expensive are they (their constant factor I mean) compared to lists?
 
@bwoebi I didn't try, but self-balancing trees are usually pretty damn ugly by themselves. I can only imagine how they'll look combined into a hashtable implementation...
 
@NikiC Why are those lists O(n) on insertion? Isn't it just a prepend to the head of the list?
 
8:35 PM
@kelunik You have to check if the element already exists
 
@NikiC well, the btree API would be obviously in a separate header file… mixing it in directly would be cruel, definitely…
 
@salathe it won't let me save the changes, does it lock the file if someone else has it open?
 
@crypticツ Yes it does. That's probably the main pain point of edit.php.net
 
@bwoebi Which is okay by me, in first approximation. As long as the issue is only "Aerys is still vulnerable" rather than "makes Aerys vulnerable in the first place"
 
@crypticツ Yes it does which is horrific. But at least it says that when opening a file
 
8:39 PM
@NikiC but I admit, I've only ever implemented a fast fixed binary tree (that phpdbg_btree thing) … can't tell how ugly it really is…
 
@PeeHaa oh that's what that popup was that I clicked out of without really reading =oP
 
;-)
@crypticツ I don't think I can unlock a file unless I change it myself
IIRC I asked about that once
 
Could someone help me please;
Im creating a student records card which uses database to drag all information into html tables.

I've prepared an SQL statement containing a query and made a while loop to loop through the results and print accordingly but nothing seems to be printing on my screen.

My PHP code:

$query = mysqli_prepare($link, "SELECT enrl.ayr, enrl.status, prog.ptitle, enrl.lvl
FROM enrl, prog
WHERE enrl.sid =?
AND enrl.pid = prog.pid
ORDER BY lvl DESC"
);
mysqli_stmt_bind_param($query, "s", $sid);
 
@methhead Up arrow -> ctrl+k
Or use a pastebin service (better)
Or keep using meth (bestest)
 
I am found of the last option PeeHa
fond*
 
8:43 PM
@NikiC Well, it makes it crash instead of just hanging if you want to see it like that.
 
Are there any starter bugs for php-src?
 
@kelunik Yes. Is it not designed to crash?
 
Here is my code pastebin.com/afwcG5ap PeeHaa
 
If you think that would be an issue, the limit could be made configurable through an ini option
 
@NikiC also… what type of self-balancing tree are you usually using?
 
8:44 PM
Goddamn son. mysqli is soooo terrible
Let me read back your actual question
You never echo $scap
 
@NikiC Obviously it's not designed to crash. :P I don't know who fast worker restarts are and what's the bigger issue.
 
You are just storing stuff in a variable
 
I have echo'd $scap it was just at the bottom of the page, sorry should of included it
 
@kelunik currently about 100 ms until next restart
 
@bwoebi I haven't ever implemented one for practical purposes. Usual ones are Red-Black and AVL
@kelunik Ah right, you loose other clients in some cases?
 
8:47 PM
I don't use poop mysqli to access my databases, but I doubt you need to run query after executing a prepared statement
query (I hope) is to run raw queries instead of prepared statements
 
@NikiC You loose other clients, you loose all websocket connections, you break requests in the middle, etc.
 
@kelunik TL;DR: You're fucked
 
So what should i change for it to work?
 
Holy fuck what the hell is this
 
It's all ogre now
 
8:50 PM
@PeeHaa Right, that's why it's really critical that we can catch as many errors as possible to prevent such crashes and leave other requests untouched if another one fails.
 
I am drunkish, so please correct me when I say something stupid. But WTF is this example doing towards the end?
@kelunik /me agrees
It's the mysqli::execute man pages
 
Oh right ok thanks you
 
Why the fuck does it run those queries?
 
You still talking to me?
 
@methhead Sorry. Was distracted by docs...
 
8:52 PM
@PeeHaa You're talking about $mysqli->query("DROP TABLE myCity");? ^^
 
@kelunik It's the docs of execute, but it shows how to make coffee, runs queries and change a tire on your car
@kelunik So yes a.o. that part
Why is it creating and dropping tables just for the example?
 
@NikiC Anyway, the E_ERROR you proposed after all feels like a temporary solution… :-/
 
Yes, the second part can probably be removed.
 
Looks like noise to me
 
@bwoebi only for the web sapi, yeah :-/
 
8:54 PM
@bwoebi It is. I expect it to be a very permanent temporary solution.
 
@NikiC
 
BTW @methhead I'll be right at you once I stop being annoyed by the docs :P
 
Like the current max_input_vars has been a very permanent temporary solution as well :D
 
@NikiC that setting is stupid ^^
 
but it works.
 
8:55 PM
I'd be much happier with siphash, but that didn't work out. With more work one could make it less bad, of course...
 
except that it doesn't solve anything but a very small subset of the issues
 
ok. I think I managed to read and understand your question
 
switching the a crypto hash function seems to be the best solution then?
 
@salathe file still locked can't edit. I'll hand the reins over to you to finish it. =o)
 
@kelunik E_PERF…
 
8:57 PM
This is what you want to do @methhead php.net/manual/en/mysqli-stmt.fetch.php#example-1910
 
We should measure the impact in real world applications and decide then.
 
@kelunik did you read his mail completely?
 
No idea WTF that other example was written on. Either meth or acid is my best guess
 
@bwoebi Sure, he said it doesn't matter that much for wordpress as it seems, non-trivial but small.
 
Thanks @PeeHaa, i should really read the manuals thoroughly before posting. Thanks
 
8:59 PM
@JoeWatkins I FIND A NEW HOUSE EVERY DAY. NOT THAT SPECIAL! OR ARE YOU ACTUALLY ARE GOING TO MOVE AGAIN?
 
@PeeHaa he is…
 
STILL SOMEWHERE AT THE SAME PLACE?
Sorry that was caps still being on
@methhead Imo that specific part of the docs suck
BTW is this a new project / new code @methhead?
 
Yes i'm a computer science student and I have to make a student record page for an assignment
 
Because if you are still able to I would urge you to use PDO instead
 
@NikiC TBH, I'd seriously like to see the self-balancing btree approach, and if it's only to study it, regardless whether we're going to use it or not…
 
9:02 PM
@methhead Using PDO would be infinite times nicer so if there is no pressure yet I would change
Otherwise calling $stmt->fetch() in a loop would also do the trick in mysqli
 
I would change it but it's due in tomorrow morning so I dont really have the time xD but i'll defiantly look into it for future projects
 
Yeah. If it's due tomorrow keep doing what you are doing.
The gist of it is:
 
I've only just started looking at PHP and MySQL i've only ever really studied HTML, CSS, JS
 
1) prepare query 2) execute statement 3) (awkwardly) bind the result because mysqli 4) loop through result 5) profit!
 
Thanks, the PHP manual link you sent me pretty much explains it also!
 
9:05 PM
@methhead Cool
@methhead Awesome
 
Thanks for your time anyway! Have a very methy christmas :)
 
Np. You have a sleepless christmas too :P
 
I'll be in the yard digging holes xD
 
heheh
brb, trolling android
 
@NikiC Also, in general, an always ordered data structure exposed to userland wouldn't be a too bad thing either…
 
9:18 PM
@methhead how extensive were your studies of JS?
if your skills in native JS is are good or exceptional, you might find node.js a better fit as a serverside solution instead of learning PHP
@JoeWatkins awesome, congrats !!
 
@bwoebi I don't have a problem with it if it can be implemented reasonably. I don't have time to do myself
@bwoebi Do you have any more ideas about the exception leak?
 
nope … :-(
 
Ok. That means I just skip the test on PHP 7 :P
 
hehe
 
lol
 
9:25 PM
It actually didn't work before 5.6.8 either because of a PHP bug, so...
 
XFAIL :)
 
Feb 26 at 19:49, by Danack
The code was 'working' before it was tested, therefor tests break code.
 
@Andrea We have no XFAILIF
 
@NikiC Add one.
 
@PeeHaa are you still about?
 
9:35 PM
yea
 
@Andrea eh
 
I've looked through the link you've sent me and incorporated into my code, still something seems to be not working and i can't figure it out. Would you be able to check it out for me :)?
 
@NikiC I'm really annoyed about the issue with the arg cleanup patch and fetch_r most definitely is too expensive :-(
 
@bwoebi Instead of doing a fetch_r, try a qm_assign ;)
 
9:39 PM
@methhead Let me see whether I am still sober ebough to read it
 
Lol, sure!
 
@NikiC well, that doesn't change anything, except that the one is probably slightly faster…
the issue is that I have to add an extra opcode at all
 
@bwoebi It should be significantly faster. But yeah
 
Uhm… I have some idea…
We could collapse all the individual sending opcodes into a single big one and then do the ZEND_QM_ASSIGN
 
@methhead You are preparing twice:
query = mysqli_prepare($link, "SELECT enrl.ayr, enrl.status, prog.ptitle, enrl.lvl...
and
if ($st = mysqli_prepare($link, $query)) {
 
9:42 PM
@bwoebi You mean send a range of consecutive temporaries?
 
because now we eventually don't have to do individual sends as everything is already in temps… then what we save there we just can send
 
Ok so i should just define variable for the query and prepare in my if
 
@NikiC something in this direction… having consecutive temps might be a bit too much of a requirement/adding complexity (esp. in opcache)
 
Change to (minor code dump incoming sorry all in advance):
$query = "SELECT enrl.ayr, enrl.status, prog.ptitle, enrl.lvl
                                       FROM enrl, prog
                                       WHERE enrl.sid =?
                                       AND enrl.pid = prog.pid
                                       ORDER BY lvl DESC";
 
Yup changed that
 
9:45 PM
Does it work after that?
 
Nope, would I also bind params and execute within the statement or before the if
at the moment I have them both in the if statement
Because part of my query relies on my binding a variable as part of its argument
 
@NikiC this should then be in every case at most as expensive as what we currently have, and in most cases less expensive (when > 1 arg and args being temps)
 
Also sounds somewhat complicated
 
I don't think it's very complicated, it just rather much change
 
how do I test opcache's optimizer
 
9:52 PM
(minor code dump):
 
how do I get it to like, run on some code
 
if ($st = mysqli_prepare($link, $query) === TRUE) {
mysqli_stmt_bind_param($st, "s", $sid);
mysqli_stmt_bind_result($st, $ayr, $status, $ptitle, $lvl);
mysqli_stmt_execute($st);

while (mysqli_stmt_fetch($st)) {

This is what i have so far
 
@NikiC @bwoebi ?
 
@Andrea hm?
 
@NikiC I have a test script. I'm trying to trigger an optimisation the opcache optimizer does. How do I make sure the optimizer is running? Can I just run the script with PHP CLI and it will work?
 
9:54 PM
@Andrea -dopcache.enable_cli=1?
I keep a php.ini around for running with opcache
 
ah, that's my other problem
how do I get the CLI to actually look at my INI file? :p
it seems to ignore it
 
@Andrea -cphp.ini?
 
I guess I'll do that.
 
@NikiC urgs… the other issue is the ref/not ref…
which is why a fetch_r won't work :s
 
@bwoebi refs ftw
 
9:57 PM
everything would be more simple when we required an & on callee and caller side…
 
hmmmm
the optimisation isn't being triggered :/
 
@Andrea Which one you trying?
 
@NikiC zend_optimizer_update_op2_const which does a HANDLE_NUMERIC, similar to the compiler I think
 
@Andrea Okay. Which code you trying?
 
I'm not sure of the specific circumstances this is called in, but I assume either $foo["123"] or $foo[SOME_CONSTANT] would work, and yet neither of those did
$test = new Test;

isset($test['0']);
isset($test['123']);
unset($test['0']);
unset($test['123']);
$test['0'] = true;
$test['123'] = true;
$foo = $test['0'];
$foo = $test['123'];
current code
 
9:59 PM
@Andrea Try $foo[(string) "123"]
 

« first day (1867 days earlier)      last day (3075 days later) »