17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1965 Views |
-
Is this code threadsafe? -- Director::urlParams()

16 March 2007 at 2:15pm
Hi all, I'm a java guy by background and this worries me a little, unless I'm fundamentally misunderstanding the scope of statics in PHP?
Director.php: ‘Director::$urlParams = $arguments;’.
This is effectively a global variable. In java you’d die if you did this. Surely there’s only one instance of static (:
variables?
This is used by currentPage. Why is there a STATIC called currentPage?
This is then used in SiteTree::currentPage. I.e. a pretty significant function.This is a concurrency issue. Stress testing should reveal request corruption as the first request is being filled with the second request's page info.
Anyone able to offer some insight? It's not hard to fix; you hang urlParams off $_REQUEST instead right? I'm (blindly) assuming $_REQUEST is thread-scoped.
This may well be showing my 'Java guy tries to do PHP' naivete.. any insight greatly appreciated.
-
Re: Is this code threadsafe? -- Director::urlParams()

16 March 2007 at 2:29pm
PHP doesn't have threads. Each HTTP request is a different process, with its own set of globals. So it's not a problem.
Every time someone requests a page, main.php starts up, and runs through it threadlessly. Any shared data between requests needs to be put into the database or the session.
Good to see you're giving our code a good working over though.
| 1965 Views | ||
|
Page:
1
|
Go to Top |


