php-pm / php-pm-drupal

Drupal adapter for use of Drupal 8 with PHP-PM
43 stars 2 forks source link

Drupal 7? #12

Open alex-moreno opened 8 years ago

alex-moreno commented 8 years ago

would that be possible? Has anyone tried? I understand for the patches that this one is just for D8

kentr commented 8 years ago

I don't personally plan to try it or put other effort into it. I don't know whether or not it would be possible.

alex-moreno commented 8 years ago

I don't mind to give it a go, although I wanted to make sure that, given the similarity of D8 and symfony architecture, is something that couldn't be achieved in D7. Thanks

On Mon, 21 Mar 2016 18:32 KentR, notifications@github.com wrote:

I don't personally plan to try it or put other effort into it. I don't know whether or not it would be possible.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/php-pm/php-pm-drupal/issues/12#issuecomment-199416224

kentr commented 8 years ago

I suspect that lack of Symfony won't be a deciding factor. @marcj would know better. As I see it, PHP-PM is somewhat like a bridge between the ReactPHP event loop and other code (Drupal, Symfony, etc…).

If global users is actually the cause of the authentication problems that I found with D8, you’ll probably have the issue with D7 as well.

bertrama commented 8 years ago

For what it's worth, I have tried this, and I've gotten to a point where I can render a page. There are an indeterminate number of drupal_static() variables that will need to be reset before it works correctly. Global variables like $user, etc will have to be reset too. Also I encountered questionable practices, like defining functions in template files, that caused it to crash.

kentr commented 8 years ago

Global variables like $user, etc will have to be reset too.

Can you describe what you're thinking WRT "reset"?

My understanding is that the app itself is running continuously, and so all requests would access the same global variables. I'd expect this to cause concurrency problems.

Example:

  1. One request comes in.
  2. $user is set to that request's user.
  3. Another request comes in before the first finishes and either:
    • The second request erroneously gets the first request's $user and uses it, causing problems for request 2.
    • The second request changes $user, causing errors in subsequent processing of request 1.
bertrama commented 8 years ago

Sure. I didn't mention it, but I assume that each php-pm worker is single threaded so that no two requests run in parallel on the same worker. That should keep all of Drupal's global state separate between calls. I just have to unset the variables between requests. There are probably going to be problems with anything that depends on Drupal registering shutdown functions for the php runtime. I haven't gotten that far yet.

bertrama commented 8 years ago

in terms of actually "resetting" a variable, I mostly have been calling unset() on the globals. drupal_static(), on the other hand, can be cleared with drupal_static($name, NULL, TRUE);

kentr commented 8 years ago

Ah, you’re probably right about a single worker only handling one request at a time. I didn’t think of that.

I’m looking forward to the results.

kentr commented 8 years ago

@bertrama, are you actively working on this? I need to merge in the upstream changes eventually (such as #11 ), but don't have a lot of time for testing or fixing new problems. I want to make sure it won't interfere with what you're doing.

bertrama commented 8 years ago

It's a side project that I don't get to spend much time on. Drupal 7 has a very different structure from Drupal 8, so I've pretty much started it from scratch. So your changes here won't affect anything I've done. Thanks for checking, though!

bertrama commented 8 years ago

I've uploaded my code:

https://github.com/bertrama/php-pm-drupal-seven

Very experimental, and needs cleaning up.

alex-moreno commented 8 years ago

amazing Albert :-), I'll try to play with that in the next days and give some feedback

On Mon, 9 May 2016 at 05:08 Albert Bertram notifications@github.com wrote:

I've uploaded my code:

https://github.com/bertrama/php-pm-drupal-seven

Very experimental, and needs cleaning up.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/php-pm/php-pm-drupal/issues/12#issuecomment-217772204