facebook/facebook-php-sdk — pull request #85 by BenMorel (2013-08-03 15:43:28+00:00)
Title: Delayed reading from the persistent storage until actually needed

The current implementation of `BaseFacebook::__construct()` reads a value from the persistent storage.

This might not be a problem with the default `Facebook` class, which relies on the PHP session storage, which is always available.

However, having subclassed `BaseFacebook` myself to support a homebrew persistent storage system (we don't use the PHP ``$_SESSION`), I ran into the following problems:

- When I instantiate (actually, when my Dependency Injection framework instantiates) a service that has a dependency on Facebook, a variable is read from the storage, even if no subsequent methods are called on the Facebook class.
- When I run my tests, or CLI tools, sometimes I also need an instante of a Service that has a dependency on Facebook, even though I will never actually make a call to the Facebook class. Because I'm on CLI, no session is started, so Facebook makes everything fail.

This PR fixes this, by delaying the read of the `state` variable until it is actually needed.