Re: opcache_compile_file() declares top-level functions

From: Date: Thu, 21 Nov 2024 14:17:01 +0000
Subject: Re: opcache_compile_file() declares top-level functions
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-126026@lists.php.net to get a copy of this message
On Thu, Nov 21, 2024, at 13:46, Rowan Tommins [IMSoP] wrote: > > > On 21 November 2024 10:48:46 GMT, Daniil Gentili <daniil.gentili@gmail..com> wrote: > >I speak for myself (and some others, as can be seen by pull requests on some FOSS projects, > >which made pull requests to account for this behaviour), as a user of preloading who has encountered > >this behaviour, understood the reason for it and made the required changes to keep using it. > > This is still painfully vague. What projects? What "reason for it" did you > understand? When you say projects accounted for it, do you mean they got some benefit from it, or > that they worked around the problems it caused them? > > > >There is indeed nothing wrong with the listed behaviours IMO, as they make sense for how > >the current logic is working, and aren’t a deal breaker for preloading. > > This seems to be entirely circular - "the current behaviour makes sense for the current > behaviour". > > > >In fact preloading in a way behaves as if you included the preload file before including > >the entry point > > Note that we are not talking about preloading, as a general concept; we are talking about the > specific function opcache_compile_file. That function's explicit purpose is to prime the > opcache *without* behaving the same way as including the file. > > > > functions cannot be declared twice, and already-declared classes are not autoloaded again > > Finally, we seem to get to the use case you are actually advocating: precompiling classes but > using an autoloader to actually declare them; but fully pre-declaring functions, because > there's no autoloader for them. > > That certainly makes sense as a distinction, but I then wonder why you would use > opcache_compile_file for declaring those functions, rather than a normal include. Since you > can't include the file a second time either way, is there any way to make use of the > difference? > > > > it might be a nice idea to simply ignore the redeclaration of functions (like for > > classes), instead of not preloading them at all. > > > There is nothing that ignores the redeclaration of classes; they are not declared when > pre-compiling, and can be declared exactly once by passing include/require the pre-compiled file. > Making functions match that behaviour is what Ilija is proposing. > > > Rowan Tommins > [IMSoP] > Seems like function autoloading would alleviate this use case and make this behavior easier to deprecate. — Rob

« previous php.internals (#126026) next »