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

3:01 PM
@PeeHaa not showing now
 
@Andrea In that case there must be some other issue with them
Maybe it was that compilers used to generate crap code for them?
 
@NikiC bitfields are kinda awkward
they're one of C's rough edges
like enums
ooh
if I have a signed bitfield of size 1, can it only contain -1 or 0?
tests
$ ./a.out
bitfield.bit: 0
++bitfield.bit: -1
AHA!
C is fun
 
@PeeHaa they removed that may be
 
Tagged string would not have a precomputed hash...
@Andrea Actually, I don't see how ZSTR_LEN assignments can be supported even when using bitfields
 
@NikiC why not?
 
3:11 PM
@NikiC why not?
 
Show sample code
 
Okay.
 
I just don't see it
imho we'd need a separate setter
 
struct zend_string_packed {
    char val[7];
    struct {
        uint8_t len : 4;
        uint8_t padding : 4;
    };
};
going from most- to least-significant, bitwise
this means you can have, at most, 6 bytes
the seventh has to be a null terminator
the eighth is the pointer tag and length
problem would be overflow, I guess
 
@Andrea why would you overflow?
 
3:17 PM
@NikiC Does this make sense?
@bwoebi say someone tries to make the length > 15
or, heck, > 6
struct zend_string_packed {
    char val[7];
    struct {
        uint8_t len : 3; // better: length can be 6 at most
        uint8_t padding : 5;
    };
};
 
@Andrea which anyway isn't allowed. when you allocate a string, you give it the max length it will have…
or you'll need to realloc.
 
yeah
so let's take a hypothetical case of a string of length 6, containing 6 newlines (because I can remember its hex value :p)
that would be 0x0a0a0a0a0a0a00c1
 
0a isn't space?^^
 
\010\010\010\010\010\010
 
@bwoebi oh, right, that's newline
 
3:20 PM
but yup
 
the "1" at the end is an odd bit so we know it's a tagged pointer
 
Yes, yes, that part is clear
The question is how you practically realize this in a language that does not have overloaded assignment operators, without adding explicit setter macros
 
@NikiC I've just read your last internals mail… Are you sure you'd like to add typeErrors only on new functions?
 
@bwoebi Well, we can't add them on old ones
Outside of strict mode
 
@NikiC why do we need those?
 
3:23 PM
But we can add them for new ones in all modes
 
@bwoebi that sounds like a bad idea...
a function beginning with array_ should behave like its fellow functions
POLS etc.
 
@NikiC You mean like #define ZSTR_LEN(str) (((str) & 0x1) ? ((struct _zend_string_packed*)(str)) : str)->len ?
 
^
 
@NikiC We can't? Sure, it'd be a break, but would that break really be that important?
@Andrea probably needs an uintptr_t cast so that compiler doesn't complain, but that's just a detail…
 
@bwoebi yeah
 
3:30 PM
#define ZSTR_LEN(str) ((0x1 & (uintptr_t)(str)) ? ((struct _zend_string_packed *)&(str)) : (str))->len
better now.
 
#define ZSTR_LEN(str) (0x1 & (uintptr_t)(str))
    ? ((struct _zend_string_packed *)&(str))->len
    : (str)->len
 
won't work.
@Andrea that's then an expression … which isn't assignable.
 
@bwoebi oh! yes, good point
Now I see why you did it that way ^^
#define IS_TAGGED(ptr) (0x1 & (uintptr_t)(ptr))
#define AS_PACKED(str) ((struct _zend_string_packed *)&(str))
#define ZSTR_LEN(str) (IS_TAGGED(str) ? AS_PACKED(str) : (str))->len
 
basically.
The only issue is that many places in code are assuming that zend_string* is refcountable
and are e.g. directly using Z_ADDREF_P()/++GC_REFCOUNT() on it or similar.
 
which is bad, you should check the flags :p
 
3:44 PM
It's a comparison saved :-P
well, probably not that bad because branch predictor knows the result, but still.
 
well
we could add a check to Z_ADDREF_P() etc. without adding a branch :3
 
without branch?
how does that work without branch?
 
4:00 PM
@bwoebi How's that supposed to work?
You'd have a ternary with different-type arms
 
@NikiC and does that matter?
 
yes
I'm 98% sure code like that doesn't compile
 
I know such things don't work in Java, but C… need to try.
 
@bwoebi bitwise magi- oh right, pointer deref :/
 
yea
 
4:03 PM
@bwoebi There shouldn't be many places that do that
 
I've seen enough… can't quantify though.
zstr_tag.c:23:15: warning: pointer type mismatch in conditional expression [enabled by default]
zstr_tag.c:23:15: warning: dereferencing ‘void *’ pointer [enabled by default]
zstr_tag.c:23:15: error: request for member ‘len’ in something not a structure or union
you're right, @NikiC
 
:)
Which is why I'm saying that we need that separate len setter macro
One might even deign to say that Francois was right
 
and the other issue is that one cannot take an address from a bitfield…
though, if we disallow zero-length strings here, it'd work…
 
@bwoebi You mean under assumption of 16bit alignment?
And just say the whole lower byte is the length?
 
yes, but why 16 bit alignment?
 
4:11 PM
sorry, I mean 16 byte
And you're right, 8 byte alignment is enough
 
yep
 
but anyway, I don't see how that would help anything
 
how to get children from this [{"id":13},{"id":14},{"id":15,"children":[{"id":16},{"id":17},{"id":18}]}]
how to get children ids from this [{"id":13},{"id":14},{"id":15,"children":[{"id":16},{"id":17},{"id":18}]}]
 
struct _zend_string_packed {
        char val[7];
        uint8_t len;
};

#define IS_TAGGED(ptr) (0x7 & (uintptr_t)(ptr))
#define AS_PACKED(str) ((struct _zend_string_packed *)&(str))
#define ZSTR_LEN(str) *(size_t*)(IS_TAGGED(str) ? &AS_PACKED(str)->len : &(str)->len)
^ @NikiC (that one works)
the only thing disallowed would be ever setting length to 0, but don't think that'd matter too much.
 
@bwoebi It will overwrite everything if you set the length...
 
4:15 PM
@madu What have you tried?
@madu What have you tried?
 
i tried like this $data='[{"id":1},{"id":2,"children":[{"id":3},{"id":4},{"id":5,"children":[{"id":6},{"id":7},{"id":8}]},{"id":9},{"id":10}]},{"id":11},{"id":12}]';
$data1=json_decode($data,true);

foreach($data1 as $key =>$value)
{
$child_data = json_decode($value["children"],true);
echo 'id'. $value["id"];

echo 'children'. $child_data["children"];

}
@PeeHaa
 
obviously that gets compiled to a mov and what we'd need is conditionally mov or movb… which won't work.
 
@madu Read up on what json_decode does and debug your code with var_dump
 
@madu Or with an actual debugger.
Jul 28 at 11:59, by Danack
The sane way to figure out how to read data out of arrays, if you don't already know their structure is to use a debugger to see what the arrays actually contain, by stepping through the code.
Jul 28 at 11:59, by Danack
PHPStorm has a free trial - please use it - and here is a tutorial on how to debug with it https://www.youtube.com/watch?v=LUTolQw8K9A
 
4:22 PM
array(4) { [0]=> array(1) { ["id"]=> int(1) } [1]=> array(2) { ["id"]=> int(2) ["children"]=> array(5) { [0]=> array(1) { ["id"]=> int(3) } [1]=> array(1) { ["id"]=> int(4) } [2]=> array(2) { ["id"]=> int(5) ["children"]=> array(3) { [0]=> array(1) { ["id"]=> int(6) } [1]=> array(1) { ["id"]=> int(7) } [2]=> array(1) { ["id"]=> int(8) } } } [3]=> array(1) { ["id"]=> int(9) } [4]=> array(1) { ["id"]=> int(10) } } } [2]=> array(1) { ["id"]=> int(11) } [3]=> array(1) { ["id"]=> int(12) } }
 
Please stop bashing your head against a brick wall, and use the tool that has already recommended to you.
 
Quick poll: Canceled or Cancelled?
 
why should that have only one l? Though… is that something like british vs. american English?
 
@Trowski I was typing cancelled, but now that also looks stupid
@bwoebi Yeah it is
 
stupid microdifferences
 
4:27 PM
@bwoebi Yep, both are technically correct.
 
@Trowski Pick one and stick with it =\
 
It's sort of like color and colour, but not as strong. My Mac is underlining colour in red because it thinks it's wrong, but it doesn't underline cancelled.
 
FWIW I implemented canceled
 
@Trowski Well that's because colour is wrong ;)
 
I suppose you could argue that you don't have to type as much with just 1 l. But that's a pretty shitty argument and I wouldn't actually use it ;)
But really I think as long as everywhere you use it is the same I don't think it matters.
 
4:30 PM
this user user4920811 has been removed, how can I see his question ?
 
@Sajad Do you mean your own sock puppet account?
 
@Trowski how do you spell 'cancellation' ?
 
@Sajad questions with positive score usually aren't deleted (?)
 
@PeeHaa yes, this user4920811 was my second account, now modirator deleted it, But I need my questions, how can find them ?
 
Not going to help you find you your self upvoting sock puppet account
 
4:33 PM
@Danack Apparently cancellation with one l is incorrect.
 
Abe
@Trowski wikitionary says they are both correct
 
Stupid language and it's inconsistencies, bah. I guess we've always been bad at language design.
 
Abe
cancelled = uk, canceled = us
 
here is one of my question, how can I find other question asked by user4920811 (myselfe)
 
@Sajad Step i) invent time travel ii) Go back in time and stop yourself from abusing this website.
 
4:39 PM
@Danack there is not any abuse. I had 2 account ! that is abusing ?
 
yes it is abusing
 
@PeeHaa why ????
 
@NikiC will it?
 
You upvoted your own posts with a dupe account
 
bitfields are supposed to leave the rest of the struct alone
 
4:39 PM
The rep was reverted and you continued resulting in a ban
Once banned you created yet another account
And now you are asking us to help you...
 
@PeeHaa that's not true ! I aksed php and sql on my main account and asked html, css question in the second account !
 
And you upvoted your own accounts
 
@PeeHaa look, now my second account is remved, I don't want any rep! just I want to see my questions !!! is it possiblt to find them ?
 
@Sajad here's the answer on all your questions. Please read it and understand it
4
 
@kodeart ok tnx
 
4:42 PM
@Sajad you are welcome!
 
and still I believe having two account is not abusing!
 
Quick question, in math you can do 10/1+1 as 10/(1+1). Can this be used in PHP?
`if (isset($_POST['submit']) && (!empty($_POST['name']) || !empty($_POST['email']) || !empty($_POST['message']))) {`
Or do I even need it?
 
Abe
@Sajad how can that not be abusing? it's like having a fake ID card to vote twice. which is aggravated in your case by voting donald trump yourself
 
@Abe PHP chat rooms and talking about account pyh.
 
The only difference being that voting for donald trump would be a crime against humanity @Abe
 
Abe
4:54 PM
lol
 
lol silly
 
If you had to pick one HTTP status code to represent the response when the request is acceptable, but the resource that it refers to is still being generated, what would it be?
 
Abe
@Danack 202?
 
204 no content?
Or 206 partial content
Although that probably refers to stuff being send as response
 
5:10 PM
@Abe So mote it be.
 
Abe
if the resource will eventually be available, i'd say 202
 
@Abe So, voting to my question is abusing, not having two account !
 
Imo http status codes failed as hard as SPL exceptions :P
 
@Abe So, voting to my own question is abusing, not having two account !
 
1 message moved to bin
 
5:15 PM
@Abe So, voting to my own question is abuse, Not having two account.
 
...
 
@flagger Please stop flagging. @Sajad please stop spamming
 
@PeeHaa alright
 
Never thought I'd see the day I have to use "hide this user" option :|
 
Abe
@Sajad was clear already the first time you said that
@JaakKütt i would have "nuke this user"
$ curl --head http://phpfashion.com HTTP/1.1 200 OK Date: Sat, 01 Aug 2015 00:40:59 GMT X-Powered-By: PHP/3.0.17 #php3 #hardcore
7
 
5:20 PM
Yeah. Saw that. Pretty amazing people still are running that
 
I think technical people are always surprised at how long people will run old versions of stuff for.
And that php5.x is going to be around a loooooong time.
 
Yeah that may be true. But I mostly feel bad for the developers who need to work on that thing that died 14 years ALMOST 15 YEARS ago
Oh wow. MD actually did work on that last edit
 
Abe
@PeeHaa NO WAY
 
Yes way. It did totally just apply not one, but TWO bold tags AND a strike through to text without failing!
 
Abe
lol
 
5:29 PM
@NikiC @bwoebi I think the setter thing can be resolved by making a separate macro, ZSTR_SETLEN() oder so.
 
Abe
want to fake my x-powered-by header now. PHPFI
 
@Abe fake it? nah
use PHP/FI 2.0. IN PRODUCTION.
ON WINDOWS 95
 
Abe
lol
 
Running in the 90s yeaaaa
 
Abe
#nostalgia
 
5:31 PM
@Abe win95.ajf.me :3
 
Abe
seen that :D so cool
did they solve that bug?
this: Emulation aborted due to nested emulation timeout
 
@DavidGraham that magic no-reflection-hydration thing was meant for D2 internals, not for the general public.
 
I made it, and no, it's not something that can be fixed any time soon
Due to limitations of emscripten/asm.js at the moment, paired with the awful way DOSBox implements paging
:(
 
Abe
:(
 
:(
 
Abe
5:39 PM
):
 
5:51 PM
Hello, I want to get the whole table of a mysql database back as an array. This is my code: hastebin.com/dotawosasa.mel I want to bind the result to only one variable and echo it, but it keeps complaining that I have to use a separate variable for every column. Is that true?
 
@Andrea yeah…
 
@bwoebi it'd not be the only place we do this!
 
@Andrea hah
 
6:21 PM
Um
 
@NikiC herum?
 
What would be a good way to get N unique random elements from an array
And by "good way" I mean something that is not totally stupid and slow like what PHP does in array_rand
 
@NikiC random_int(0, array length)
 
The obvious way is to do a partial Fisher-Yates, but I'm looking for some non-destructive mechanism
@Andrea Multiple random elements
 
hmm
the hard part is tracking which you already picked, I guess?
 
6:24 PM
I'm not totally sure what the hard part is
Just generating numbers until you hit one that isn't taken yet is a bad idea if N is close to the size of the array
And well, you'd also have to track which you already used. I am hoping there is some elegant way to do an out-of-place partial Fisher-Yates
 
hmm
 
And FYI PHP solves this problem by looping through the array and generating a random number at each step. Which is horrible.
 
shuffle the array and take the first N elements
 
Which is destructive
 
No
Shuffle a list of pointers.
Or, heck, indices
 
6:28 PM
In which case you'd still end up with something working in O(M) where M is the size of the array
this should be doable in O(N) where N is the size of your sample
 
actually that means we just need to pick N random unique integers
 
essentially
 
preshing.com/20121224/… is interesting...
 
tombstones might interfere, but basically that should be an equivalent formuation
 
phpdbg uses ->val and ->len everywhere :(
I renamed the struct entries to weed out the places not using ZSTR_ macros.
Huh, and that's it, for --disable-all at least :D
 
6:37 PM
@Andrea yeah, I always forget the macro. It's that uncomfortable to write…
 
no moreso than Z_STRVAL(...)
 
at least compared to ->val, I mean.
bugs.php.net/bug.php?id=70179 … that was some nice actually exploitable one… (use after free)
 
is "bwoebi" a scrambled version of "bobwei"?
 
yes
 
:D
 
6:40 PM
There doesn't exist a lot of people who realize that ^^
 
user1804599
Does PHP 7 allow scalar types in instanceof checks? E.g. 'x' instanceof string.
 
no.
 
user1804599
:'(
 
@rightfold why?
 
@rightfold there are is_* functions for that. anything wrong with them?
 
user1804599
6:43 PM
@Andrea Seems consistent with allowing scalar types in type hints.
 
user1804599
@bwoebi Consider $x instanceof $t.
 
@rightfold there was array before, but instanceof array never was allowed…
 
@rightfold scalar types aren't classes
 
user1804599
I know.
 
I'd like to change that, but that's how it is
 
6:44 PM
@Andrea do you… really?
 
@bwoebi I'd like there to be a shadow class hierarchy for the scalar types
 
@Andrea why?
 
so 2 instanceof Number, 2 instanceof Integer would work
also allows nice things:
Array::split(...) or something
 
@Andrea that's theoretically already possible today… just would need a minor parser change. (or lexer…)
 
user1804599
@Andrea An Array namespace would suffice.
 
6:45 PM
@bwoebi the class has to exist somewhere
Oh wow, this actually works: #define ZSTR_LEN(zstr) *(const size_t*)&((zstr)->len)
Clang outright errors if you try to assign to that :3
 
@Andrea why shouldn't that work? (as long as you don't assign, obviously)
 
@bwoebi I didn't expect it would prevent assignment
 
7:01 PM
it's const, so why shouldn't it?
 
I... dunno
I'm just used to C compilers being very lax
Z_STRSETLEN_P(..., ...)... I'm a monster.
 
wtf
mcrypt was removed from PHP 7?
 
@Sherif it's been unmaintained for years
which is a serious problem for a crypto library
 
@Andrea STRSETLEN … aaaaaargh
 
@bwoebi well...
 
7:12 PM
@Sherif why is that a wtf?
 
I made it ZSTR_SETLEN
so...
maybe it should be ZSTR_LEN_SET :p
 
^^
 
@bwoebi I had no idea it was going to be removed. I must have missed that discussion.
 
7:25 PM
one english question:
"I have no idea" means "I have not a good think" or "I don't know" ?
 
@Sajad the latter, the first is gibberish
 
ugh
okay, I admit it. I wish I was using C++ here. @Sara, did you hear that?
 
@Andrea pssssssscht!
 
phew that was a lot of code to change
 
7:46 PM
What is a brand color of PHP? in HEX ;)
 
@VeeeneX #8892BF
 
@Andrea Thanks! :D
 
7:59 PM
@Andrea That doesn't work over arbitrary ranges, probably
 
@VeeeneX I would say it's closer to #777BB4 actually.
 
@NikiC yeah :/
@Sherif I'm using the website's colour
 
@Sherif It's not being removed
 
@NikiC Well, when I tried compiling --with-mcrypt it gave me an mcrypt.h not founderror even though it was there.
Perhaps something wrong with the beta2 release?
I was able to build it with mcrypt from master though.
Which is strange.
 
I broke exec() and I don't know how
 
8:02 PM
Could be a PEBKAC!
 
@Sherif Very likely PEBKAC
 
problematic ElePHPant between keyboard and chair
 
Good to know I'm slipping :)
This thing is going to be either really awful or really awesome by the time I'm done with it.
There's just no inbetween.
OK, here goes my very first test run of project Skittles! crosses fingers
 
@Sherif It looks good but thanks :D
 
Went on a wild goose chase. Looked like I'd broken exec()'s whitespace-stripping. No, it's just that OS X's /bin/echo is weird
 
8:19 PM
@MarcelBurkhard ok !
 
So yeah, I got --disable-all barebones PHP compiling with constant ZSTR_LEN and without doing any direct struct member access
:3
Oh, wait, I need to ensure it's not touching ->h
 
Hi, can I ask some help in my code. I use php version 5.5.12 .the problem is that the result is null if I have 2 or more than fields in select statement but if I only select id it will show the result. see pastie.org/10324432 , I don't know why it will return null if more than field to be selected
I run that query in sql editor it shows the result but in my php it will not show
 
@jemz Check the actual result instead of your json_encode attempt
 
I remove the json_encode there is a result.
@PeeHaa, what is wrong with my code ?
 
Idunno. If you say there is an actual result the shared code should never result in null so pretty much impossible AFAICS
 
8:33 PM
that is why I'm wondering why this only function of code returning null but my other function having the same structure of code works fine.
 
Tbh sounds like it should be easy to debug
 
I tried to debug still don't have idea why it return null, I also tried to select only one column like the id, it return the result.
 
At what specific point does it fail?
 
stackoverflow.com/a/31765990/2224584 - I hope this doesn't come across as too rude :P
 
@ScottArciszewski I had one of those talks again with a client this week about "protecting images from being downloaded from their site"
 
8:39 PM
@PeeHaa, it fails if I use this select id,emp_name FROM employee where emp_id = ? or this select * FROM employee where emp_id = ?
wrong typo emp_id must be project_id
 
At what specific point in your code does it break? Up to what line do you still have data?
 
lol. I was planning on updating one of my high traffic accepted answers with a much better db and script. After realising the new db was 2 GB large I'm like.. ye, perhaps not xD
 
Because AFAICS there is nothing in your code that can return null
@icecub Mogguh
 
@PeeHaa, why is that if I removed the json_encode there is a result ?
 
@PeeHaa Evening for me :P
 
8:42 PM
@jemz I asked you a question
@icecub And what a shitty evening. They promised us better weather!
 
@PeeHaa Hmm pretty nice weather out here.
 
@icecub It is?
 
@PeeHaa, only in this line return json_encode($emp);
 
And what is the data before that line?
 
@PeeHaa Ye it's dry and around 24 C outside here. Nothing to complain about
 
8:48 PM
@PeeHaa, an array containing the result of my query ?
 
@jemz What is the data?
 
Andreas-Air:php-src ajf$ git log -3
commit 7ce8fe713317b4c6a65c1e6c2971c01e56a878cb
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Aug 1 21:55:19 2015 +0100

    Make ZSTR_H unassignable, add ZSTR_SETH instead

commit 87a84388612ae4cc05c15e522bc766b7b17cab85
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Aug 1 20:38:41 2015 +0100

    Make ZSTR_LEN unassignable, add ZSTR_SETLEN instead

commit a67db4dcbd49a4c41cd4ee5e42f907074bf170d4
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Aug 1 19:50:31 2015 +0100
:3
 
yay
 
This is with --disable-all, but...
 
@PeeHaa, here is the sample output see pastie.org/10324485
 
8:58 PM
hmm ... I am trying to do this "documentation thing" and am wondering about one issue: should I have an "examples" folder in a repo?
 
@tereško I think yes, and maybe use .gitattributes to exclude it from being packaged when it's downloaded as a zip from github.
 
@jemz That can never be the result of PDO::FETCH_ASSOC
 

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