« first day (3324 days earlier)      last day (911 days later) » 

1:07 AM
2:06 AM
Good morning Panda
I was curious about it that possible to make function within a object use $this to initialize object in PHP?
can't understand what you are asking
Lack of support for LZW / LZ78 – #78854
2 hours later…
4:21 AM
@LeviMorrison you register new opcodes above ZEND_VM_LAST_OPCODE, then set the opcode of the specific opline in the hook and the engine will setup your handler during pass two ...
what you can't do is change the handler in the hook, because pass two will overwrite it, you must register new instructions
other details also matter, not everything has a handler set, and not everything that does have a handler set will use the handler, recv is often skipped ... when you backup the opline, you want to retain the original opcode and the original handler ... then we need some logic to decide whether to dispatch via DISPATCH_TO | opcode or executing the handler directly, which I haven't figured out yet ...
(dispatch to | opcode is not compatible with jit)
4:51 AM
@DarrenFelton Going to MidwestPHP next year?
1 hour later…
6:03 AM
@Levi some code: github.com/krakjoe/zi, I might have some time to develop the idea over the weekend
6:16 AM
Ayup Joe, how's it going?
not too shabby
@Levi ...
function foo($a) {
    if ($a) {
        return 1;

    return 2;

6:29 AM
I'm considering putting myself forward to MC the PHPYorkshire stuff for half a day, but it'd be a first for me
I dunno, and I'm out of time for this morning now ... it's friday so it might be a slow day and I might get to work on it during today ...
2 hours later…
8:00 AM
usageaster a self-styled authority on language usage.
8:20 AM
9:13 AM
9:30 AM
@Girgias, could you show me the code?
1 hour later…
10:54 AM
Native PHP types in database fetches – #78855
11:28 AM
And the segfault only happens when passing count($countableObject, $someRandomMode)
Oh and null basically throw me a type error as if it didn't get intercepted.
11:44 AM
@Girgias, well, you're hitting github.com/php/php-src/blob/master/Zend/…
$count = 'count';
Huh, I was expecting to be able to change the VM bit later when I had finalized that bit
yes, you can do. You just have to avoid the engine recognizing count() (e.g. like done above).
Wait can I make some assumptions in the VM? or does it completly by passes the ZPP checks ?
VM doesn't know about ZPP. Maybe compiler looks at arginfo?
Han, well that's going to be challenging then, will try changing the stubs
But thanks for the info, I know what's going wrong at least lol
12:12 PM
@cmb so using that trick does work to test for null, however I still have the segfault
So I suppose something is indeed deeply broken with my code or it ignores the VM (haven't tested arginfo yet because I need to go)
@Girgias, indeed. Passing the 2nd arg also circumvents the VM optimization. I'm currently looking at that segfault.
Cheers :)
I have a popup window that automatically goes into fullscreem, I have the button to exit fullscreem and a button to exit(close), if the window is fullscreem the exit button works perfect, but if there is not in fullsceem the button to exit bug  whole page
$(document).ready(function () {
		var count = <?php echo $_POST['id123']; ?> ;
		$(".dr" + count).parents('.panel').toggleClass('fullscreen');
document.getElementById("detalhes" + count).outerHTML = '';
how can i fix this? see if is in fullscreem? how?
12:34 PM
@Girgias, the O specifier returns a zval* (not a zend_object*)
aka. fun with void*
true void
12:54 PM
@cmb well that explains it ... And it's kinda surprising that it returns a zval .. should have read the doc better
Is this bug tracker working? – #78856
@Girgias, np (actually, I'd prefer to get a zend_object*)
@Jeeves ... Is this guy paying full price for PHPro? :P
1:20 PM
Preload: PHP Fatal error: Cannot redeclare – #78857
1:32 PM
1:55 PM
@cmb me too but I don't think we can just change what it returns?
I'm afraid we can't for BC reasons
could perhaps add some new specifier (but that might be even more confusing)
OTOH, converting to zend_object* manually isn't that hard :)
1 hour later…
3:03 PM
@JoeWatkins I see. Did you have any more ideas on exceptions?
Notably, is there a way to know where it will unwind to?
If so, we could register the throw exception hook and trigger the .error endpoints. Of course, it would matter which order instruments + xdebug were loaded in...
For userland code we could just use an opcode handler for THROW, but if the throw originates from an internal call (e.g. PDO) then we'd need still need to handle it.
Do we really need the CFG? I was just thinking that after skipping RECV, we'd change the first opcode, then we'd just inspect the rest for RETURN/RETURN_BY_REF. Although, what happens if there is only one opcode because it's a no-op?
function noop(...$args) {}
dude, that's like a million questions ...
@LeviMorrison yes, I've a rough idea to push to a stack the corresponding end handlers when executing start handlers, then pop them off and execute them on exception paths ...
how exactly, I dunno yet
@JoeWatkins Ahahaha, sorry.
Exploring new stuff brings up a lot of questions for me :)
the cfg is useful for block info, which seems useful if we want more detail then start/exit, like begin/end try/catch/finally
I hadn't thought about no-ops, they will have to be a special case ...
3:19 PM
The try-catch-finally bits could maybe be used to know where we might jump to, I suppose.
So when the catch block executes we'd know how far back in our stack to pop to?
Finally makes things complicated, though.
well I'm thinking we expose that as part of instruments api, then it's use is application specific, there's more than that we could do, such as iteration handlers, and maybe some other stuff ... I want at first to get a reasonable start/exit, that manages exceptions in some reasonable way ,,, then we can look at extending the capabilities of the instruments api beyond what has been discussed already
And what if there are no try-catch blocks? We'd have to have something at the global level.
eventually we get access to the cfg for free, it's already being built by opcache, so it's not an additional expense, and analizing opcodes directly is really difficult to get right ...
I think maybe a combo of AST hook plus this might be where we want to go.
also, the thing is wicked fast, read it ... so while we are having to rebuild a cfg, it's not a huge deal ...
3:25 PM
The ast would add try { /* orig body */ } catch (Throwable $ex) { throw $e; } to each instrumented function, then we only have to do opcode trickery for that root try-catch.
Or something.
try-finally might be better.
the problem with ast processing is you have to know in advance that you want to modify the code
@JoeWatkins Same with this, yes?
this (with support from opcache) can be executed at any time
no, you can do it whenever, it happens to do everything right now, but you can run zend_instruments_setup at runtime on any op array - it breaks the rules of opcache right now (will try to modify code in the shm), so we'll have to fix that ... but it's in principle doable ..
In .NET, there is a notification when a function is being compiled that gets sent to interested parties. We could do the same to ask instruments if they want anything, and then we can instrument it. It's a Just-In-Time instrumenting API :)
which compilation are you talking about ... there are up to five ...
3:29 PM
I was thinking AST level. Is there anything prior to that?
we have no good apis for ast though ... and it's even more complicated than opcodes ...
Walking the tree looking for functions and methods isn't too bad, it's the other bits like getting fully qualified names that is annoying.
no, there's script -> ast, ast -> opcodes, opcodes -> pass two (executable), pass two (executable) -> opcache, opache -> filecache, opcache->jit ...
oh +a bunch of optimizer passes that also change the code ... 12 or 13 or whatever it is ...
let's not provide hooks for that, it would be too hard, as an ext dev, to use them ...
For AST, need to track:
1) namespaces
2) use statements
3) Whether we are compiling a class/interface/method (to know if we are in a method decl)
I'm not sure why ?
3:35 PM
1 + 2 are for getting fully qualified names.
Actually, 2) isn't needed.
you know that ops always have fully qualified names
there's no such thing as scope that isn't fully qualified, I'm confused
For an AST "should we instrument this?" query, we have to provide the fully qualified name of the class. IIRC it's not fully qualified in the AST and is resolved by the compiler.
from an api perspective, you will call zend_instruments_register and don't need to care about the rest, your instrument will be registered when the target becomes available ... and so I'm not sure what you need from ast ?
Ah, but that's a bit restrictive.
how so ?
well let me interject with a thought actually before you answer
the ability to query, or otherwise somewhat select in some smart way a target is a problem for the api itself, not the user of it ...
3:40 PM
For instance, CodeIgniter has a db function. Let's say we want to instrument it; there's no way we'd want to register every db function out there. If we were asked at compilation time "are you interested?" we can go look for signs that we're in a code igniter app (such as looking for its version info constant) and then say yes/no.
so if you're thinking what if I want to target the implementations of some method from some interface, that's a problem for the api ...
I see
although you still don't need ast
At the moment it's the only mostly-reliable way I can think of to handle the unwinding.
we can have an instrument for such notifications, and it will be passed the compiled op array and can check function_name and scope as it needs ...
unwinding what exactly ?
Oh, I just meant reliable exception notifications.
that's an api problem again, not your concern ...
3:46 PM
How expensive is a try-catch that doesn't fire? Ever measured it?
the api will provide the guarantee that any instrument registered with an end handler and started shall be ended
you don't need more than that, right ?
You need to know if it was a successful end or an exception. You can't inspect return value if there was an exception, and if there was an exception you probably want to mark that somehow.
you can tell from the opcode
I don't see how.
because one is ZEND_RETURN and the other is ZEND_THROW
return value in op1, exception in op1, where's the problem ?
3:50 PM
Yeah, but if I'm instrumenting function1 that calls function2, and it's function2 that throws, how will function1's exception endpoint get triggered?
that's a problem for the api
My point is that with this opcode stuff, at least at the moment, I don't see how we'd ever implement the exception bits.
That's where the AST comes in.
sorry, I don't know what you mean by we here, you mean datadog has some requirements that I don't understand ?
There are 3 hooks: .begin, .end, and .error.
oh no
well, yes,
tell me why that matters ?
3:53 PM
Why what matters? .end vs .error ?
I was thinking we just have begin and end
you can tell from the state of the vm in end what has happened (by looking at the opcode)
then the guarantee is not so hard to provide, and makes it easier to actually use, doesn't it ?
.end may inspect return value; .error may not. Additionally, knowing what exception triggered .error provides opportunity to add value, such as reporting stack traces in a UI.
It also helps to ensure that times are accurate, and that all resources are freed.
I think you're missing some information but I don't know what exactly, but you seem confused about how you will access exceptions or return values
this isn't a problem
let my rough ideas form into code that works, and we'll have a meeting again soon and discuss it until we understand each other ...
4:18 PM
@JoeWatkins Which person do you think best understands how exceptions are implemented today?
a few people, you could ask me whatever you're thinking but I'm about to go afk ... ask and cc nikita and bob, if I see if before they answer I'll do it ... but for now, afk ...
I don't know how the engine actually stores which frames need processing, such as which ones have catch and finally or even just destructors that need run.
For destructors I imagine it happens in some generic way when the function ends, not some explicit thing related to exceptions, but there's surely a structure for catch/finally?
/cc @bwoebi
/me waves
4:38 PM
@Trowski I definitely should. Have not signed up yet. And yourself?
Hi there! I have an idea sharing section on my application made in codeigniter where people can share their ideas and make them either public or hidden. I'm trying to filter this query, currently it's conditioned if the user is an administrator the $brain_status variable is empty so it shows everything, but if the user is not an administrator then I define this variable to only show ideas that are public.

I want to make it to show everyones public ideas and only the hidden ideas if the user logged in matches the author of this idea. What's the best way to approach this?
public function index($page = 0) {
$brain = new Entities\Brain();
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
$this->data['breadcrumbs'][] = anchor("manage/brain", lang('Brain'));
$this->data['breadcrumbs'][] = lang('List');
$this->data['meta_title'] = lang('List') . " | " . lang('Brain');
$this->data['brain_status_options'] = array(
$brain::PUBLIC_STATUS => lang('Public'),
To define the current user logged in I have:

@DarrenFelton Yes, I'll be going. If you buy your ticket before the 30th you get upgraded to the next ticket level and they still have blind bird pricing.
5:05 PM
session_set_cookie_params() can't be used with php_admin_* – #78858
6:02 PM
I have some class constants that have different data, but also the same bit of data I want to define once and reuse in other consts. There just doesn't seem to be a way within a class to set a value and reuse it in consts, either a property, another const, or even constructor etc. Any clever workarounds?
@LeviMorrison catch/finally have zend_op_array.try_catch_array
so eg
`const CONSTANT_A = 'you clicked wrong, click here <a href="SAME"></a>';`
`const CONSTANT_B = 'message is diff but link same, <a href="SAME"></a>';`
I want to reuse the href so not to dupe (I actually define it in env file)
@bwoebi Which op_array has the try_catch_array?
and frames which need processing: it's really just unwinding the stack and checks whether the current opline is within a try_catch_array range
@LeviMorrison the op array having try {} instructions
I think zend_throw_exception_hook might get called with NULL on every frame as it unwinds?
That's in addition to each time an exception is thrown.
6:09 PM
@LeviMorrison yes
So except for the part that xdebug hijacks this hook, it should be sufficient.
By hijack, I mean that it does not call any already registered exception hooks.
eih no
@bwoebi ?
was confusing the names @Levi - the exception gets rethrown,yes, but that is not going to call the hook then
@LeviMorrison php-lxr.adamharvey.name/source/xref/master/Zend/… - this is being executed
I believe there are some things which changed between versions
6:15 PM
@LeviMorrison yes, it's called only once
in master.
Do you have time for a screen share?
if you look at the 7.0 code for example, then it's multiple times
Wait, why would we change this?
... but it's literally robbing extensions of functionality?
6:17 PM
not sure
@cmb Sure, but still annoying :p
7:08 PM
Hey, @JoeWatkins, bwoebi helped me get sorted out.
1 hour later…
8:24 PM
Anybody every come across a static property that is definitely declared throwing an error when you try to assign to it that it is not declared?
8:54 PM
how to use php sessions in angular? any ideas
9:04 PM
How to use PHP sessions in a javascript framework?
Weird behavior with uninitialized typed properties and __set/__get – #78859
Hi @Dereleased yes, and I got the answer to that here somehow.github.com/pipiscrew/angular2_small_prjs
9:28 PM
3 billion dollars... that's an expensive "test." engadget.com/2019/11/22/walmart-jet-fresh-grocery-delivery
