« first day (1742 days earlier)      last day (3428 days later) » 

23:00
Unfortunately that's ended up telling me what I already knew.
So, I've figured out the dependency chain, but I don't understand what's broken.
So the last thing it's trying to create has a dependency on some interface. According to the error message, you haven't told Auryn how to create that interface.
That's the thing though, it should never be seeing that interface as a thing that should be created. Gimme a sec to type this out.
This code uses Aura Session. Auryn has a delegate registered for Session that invokes a SessionFactory. Session is marked as shared. SessionFactory invokes a CsrfTokenFactory with a newly created Randval, which implements RandvalInterface. Auryn is complaining about RandvalInterface, but it's never being asked to resolve it, because the CsrfTokenFactory creates a concrete instance of something that implements it...
I'm trying to figure out why and where and how Auryn is getting the idea that it needs to pass a RandvalInterface.
Can you copy pasta the $ie->getDependencyChain(); ?
The backtrace from the uncaught exception isn't helpful, and getDependencyChain() on the exception only lists the classes, not the calling lines.
array (size=3)
0 => string 'aura\session\session' (length=20)
1 => string 'aura\session\csrftokenfactory' (length=29)
2 => string 'aura\session\randvalinterface' (length=29)
@Fabor I would have been surprised if it wasn't. Machines don't white-screen like that unless it's a gfx fail, mobos/core components fail either with a stop error or with and instant safety reboot. What I saw was a gfx card failing and the mobo taking a second or two to realise. But yeh, live and learn I suppose, and you could always build another workhorse machine off the back of it, you've already got the most expensive bits.
Cheapo case, medium-grade RAM, cheapo HDD and you have another machine for distributed computing or just a torrent slave/seedbox or sth
23:06
So I mean, it's clearly trying to create a new Session, but I've marked Session as shared, so wtf?
lemme make sure the delegate is being called to begin with...
I still think it's worth looking at the gfx cooling though, it definitely had the feel of something overheating
ffs, the delegate is never being called...
@Charles I don't understand what you're saying. CsrfTokenFactory does need a randvalinterface. github.com/auraphp/Aura.Session/blob/2.x/src/…
Or firmware, but tbh I've not owned a high-end gfx card for so long that I'm not even sure if that makes sense any more, some of them basically seem to be self-contained computers, almost ASICs
@Danack Yeah but it's being called through SessionFactory in the delegate, which I now believe is never being called.
(and SessionFactory provides Randval.)
Yup, confirmed it, the delegate is never being called.
What the hell
23:12
It's f***ing annoying to have travis fail with SIGSEGV and not being able to reproduce any failure locally :x:x:x
@NikiC Could you please try to run the sapi/phpdbg tests with opcache active and tell me if it segfaults for you? [and ideally fix it^^] … I have nothing to repro it…
Ahahahahaha I'm passing the injector into the delegate via injection and it's creating a new, empty injector.
@Charles When I hit "wtf this can never happen" things, the solution is usually an 1-char typo. Either you mistyped a class name or (depressingly common) reflex-typed a $ where one doesn't belong, resulting in a var var/var prop you weren't expecting.
@Charles Or just an epic fail because I wasn't paying attention to what I was writing :-P
@Charles The first line of code I write in any project today:
$injector->share($injector); //yolo
@DaveRandom In this case, it's because the code I relied upon was unstable and under rapid change, and I didn't keep up.
@Danack Yup, that did it. Man, that was a pain.
@Danack You know, one of things I was thinking to myself when this was being discussed in you talk was "surely that should be the default behaviour, there are almost no situations where having multiple injectors makes sense"
If you have more than one injector you're probably using it as a service locator
It's wouldn't work very well as a server locator
23:16
@DaveRandom or "encapsulating context"
@Charles Ahh, so you mean you were using something that @rdlowrey wrote. Yeh, that happens.
2
/me hides
which is basically passing specialized service locators
@DaveRandom That was answered in the questions, briefly. There are valid usages for having multiple teams working on the same code base, with one of those teams having to work in a more strict security context.
@FlorianMargaine This. In the general case (to which I'm sure there are edge-case exceptions), if the injector leaves the bootstrap then you are Doing It Wrong™
I need to learn more alt codes
Also, there are differences between things that can be shared across all of an application, vs things that can only be a shared across a 'scope'. e.g. if you have a background task that processes stuff, some things (like database connections) can be shared for all of the task processing.
For things that depend on user data, they can't be shared across the whole application. They can only be shared across the scope that deals with that user data.
23:21
@Danack Note the "almost". I didn't/don't really get that, can't visualise it, don't understand why that requires more than one injector (at least, don't get why such problems couldn't be resolved at the application design layer rather than wiring) but I'm very confident in saying that most people don't have that problem in first place
that will help visualize the problem.
maybe.
And yes, I think resolving it in the application through code (rather than trying to solve it through config/annotations) is the best solution.
I've read that before but I will re-read, brb
My response to @Ocramius raising that after the talk: gist.github.com/Danack/af51e941ce705f66d756
@Danack This is my point. I understand the problem, I don't understand why solving it at the DI level is the right way to do it (or even an easier/quicker way to do it, which is the usual reason for experienced people doing things badly)
huh, github makes you log in for private gists, irrelevant but seems a little strange
> I don't understand why solving it at the DI level is the right way to do
I don't think it should be solved in config.....but you might need to manually clone the injector to be able to handle it programatically.
23:27
@Danack I got to sentences in and: this. There's just no reason, esp. in the context of the process isolation of PHP, where this should be an issue. If you think it's an issues it's because your design is bad.
The flip side i.e. real-world caveat to this is that everyone has legacy code where you need to solve these problems
But that still doesn't detract from my original point, which is that the inject should be shared by default. Defaulting to the case where you are doing things badly is not the right way even if it is the most common situation /cc @rdlowrey
It's a very mild incarnation of it, but in a small way it is perpetuating the problem, and it also causes issues like @Charles just had - in a sense you a slightly punishing people who are writing new, good code by making them add that line.
@DaveRandom "If you think it's an issues it's because your design is bad." No....There are cases where I need to share an object/data that is shareable for a context, but isn't shareable universably.
And yes, I realise it's technically global state, but the injector is essentially stateless in the context of an application - it has state, but the state is set and bootstrap and doesn't (shouldn't) change throughout execution
Did you get to the end? where I said you should do it programmatically:
function createContext(Injector $injector, $contextObjects) {

    $injector = clone $injector;
    foreach ($contextObjects as $contextObject) {
        $injector->alias($contextObject->name, get_class($contextObject->instance));
        $injector->share($contextObject->instance);
    }

    return $injector;
}
because that leaves the original injector stateless....and move the required statey-ness off into a separate object.
@Danack In the context of the web, I don't buy that. The water becomes a lot muddier in the context of things with long-lived running space, but the web is "get it out the door asap and die" and these problems can be solved better with context-specific implementations
IMHO, YMMV
22 hours ago, by DaveRandom
(IMHO, YMMV, WTF, contents may differ from image shown, slippery when wet, fire kills children, insert other disclaimers here)
I should probably stop coming in chat in the middle of the night
@Danack No, but I will actually read the whole thing... tomorrow, when I've not had a few beers.
@DaveRandom why not?
23:35
@bwoebi Because the probability of me making an arse of myself is massively higher. The fact that I've done it in person, with the person I'm conversing with, is not relevant. I still fear his beard.
@DaveRandom well, next time you meet him, bring a shaver…
I would never defile such awesome facial furniture, in that same way as it would take a lot for me to cut my hair
Even in the context of webservers, being able to setup an injector that doesn't know how to create any objects that are 'dangerous' to use, can be useful for large projects where some people one the team might be 'special'.
@NikiC nevermind, travis somehow magically reported a green build …
In many ways I admire @Danack's beard all the more, simply for the fact that it's more socially contentious (in general). Hipsters have pony tails, UNIX programmers have insane unkempt beardage
@Danack yeah, and I've heard your beard wasn't long enough.
@Danack Yes, but my point is that the "special" people are the ones who should have the extra cognitive overhead of remembering to disable sharing of the injector.
Imagine you had never heard of a DIC before and you are playing with it for the first time. What would you expect?
IMO, you would expect it to be shared, something that is designed to wire your application up would work the same everywhere.
Again, very much YMMV
user895378
@DaveRandom I don't necessarily agree that it should be shared automatically.
user895378
I don't feel that strongly about it, though.
@rdlowrey I'm quite sure you don't, other wise it would be :-)
23:43
Meh - it'd be annoying to program if nothing else. As soon as one thing needs to be 'unshared', it would enable a whole chain reaction of bug related to being able to unshare other things.
user895378
I think "empty" is a sensible default.
(which existed before, but no-one complained (loudly) when it was removed)
@rdlowrey I don't feel strongly enough that I'd go out of my way to fight for it, just saying that's what I would do if I wrote it. I suppose to sum up my thoughts in a sentence: The most common case is not necessarily the default, the most logical case is.
Why the hell would you want to share the injector?
But even then, it's highly subjective
user895378
23:45
@bwoebi makes sense to do it if you're using it in factories
don't use factories…
user895378
Not always possible or advisable :)
I've found myself using factory methods…
@bwoebi When you need delegates to use the injector that's calling them, as in my case.
but factory classes? go away.
I have no idea whether I'm just naïve or people like to write code as it fits best to them…
23:47
How do you allow one class to be able to create another class without either hard-coding what class gets created or doing funky magic?
@Danack pass in a callable creating the class for that class.
as said, yes to factory functions, no to factory classes.
mopping white/light coloured floors is one of the least rewarding things one can do in terms of job satisfaction
And how do you know which callables need to be created, other than just hard coding all of them?
@Danack what's that a question? You somewhere will have to hardcode the class name.
@bwoebi For very specific use cases where you need to create a lot of related things in one place (usually siblings, always some kind of VO) I don't see the harm in grouping said factory functions into a class so that the consumer has a single dependency.
ffs, brain no longer working, bed
nn
23:53
Yeah, but then I can just do $injector->execute(['SomeController', 'foo'); without having to worry about creating any factory that it might depend on.
How do you know that ['SomeController', 'foo'] might need a particular factory function?
Sure, but what do you need the injector in here for?
what?
Why would you want to inject the injector in such an environment?
That's a different conversation, related to security and/or 'variable dependencies'. You were telling us how people shouldn't use factories.

« first day (1742 days earlier)      last day (3428 days later) »