[packages/php-facebook-sdk] add FacebookNPS (No Persistent Storage or No PHP Session) class
glen
glen at pld-linux.org
Wed Aug 22 10:01:29 CEST 2012
commit 8c6921becd0d028a06f3ad4227bf20af04fb61dc
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Wed Aug 22 11:00:45 2012 +0300
add FacebookNPS (No Persistent Storage or No PHP Session) class
class-nps.patch | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
php-facebook-sdk.spec | 7 ++++--
2 files changed, 75 insertions(+), 2 deletions(-)
---
diff --git a/php-facebook-sdk.spec b/php-facebook-sdk.spec
index 68380db..ee2746d 100644
--- a/php-facebook-sdk.spec
+++ b/php-facebook-sdk.spec
@@ -7,11 +7,12 @@
Summary: PHP SDK for the Facebook API
Name: php-facebook-sdk
Version: 3.1.1
-Release: 3
+Release: 4
License: Apache v2.0
Group: Development/Languages/PHP
Source0: https://github.com/facebook/facebook-php-sdk/tarball/v%{version}#/%{name}-%{version}.tgz
# Source0-md5: 3e23cbda87e68f95f3b222cbb868e5d1
+Patch0: class-nps.patch
URL: https://github.com/facebook/facebook-php-sdk
BuildRequires: rpm-php-pearprov >= 4.4.2-11
BuildRequires: rpmbuild(macros) >= 1.461
@@ -26,8 +27,8 @@ BuildRequires: php-session)
Requires: php(curl)
Requires: php(hash)
Requires: php(json)
-Requires: php(session)
Requires: php-common >= 4:%{php_min_version}
+Suggests: php(session)
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -42,6 +43,8 @@ social.
%prep
%setup -qc
mv facebook-facebook-php-sdk-*/* .
+cp src/facebook.php src/facebook.nps.php
+%patch0 -p1
%build
%if %{with tests}
diff --git a/class-nps.patch b/class-nps.patch
new file mode 100644
index 0000000..30ecc0f
--- /dev/null
+++ b/class-nps.patch
@@ -0,0 +1,70 @@
+Add FacebookNPS class that allows to use Facebook SDK without initializing php
+session storage.
+
+This makes api calls possible, but no login support for users.
+
+--- php-facebook-sdk-3.1.1/src/facebook.php 2011-08-09 03:32:07.000000000 +0300
++++ php-facebook-sdk-3.1.1/src/facebook.nps.php 2012-08-21 19:00:15.841768544 +0300
+@@ -19,29 +19,16 @@
+
+ /**
+ * Extends the BaseFacebook class with the intent of using
+- * PHP sessions to store user ids and access tokens.
++ * internal class storage for persistant data. Limited functionality!
+ */
+-class Facebook extends BaseFacebook
++class FacebookNPS extends BaseFacebook
+ {
+- /**
+- * Identical to the parent constructor, except that
+- * we start a PHP session to store the user ID and
+- * access token if during the course of execution
+- * we discover them.
+- *
+- * @param Array $config the application configuration.
+- * @see BaseFacebook::__construct in facebook.php
+- */
+- public function __construct($config) {
+- if (!session_id()) {
+- session_start();
+- }
+- parent::__construct($config);
+- }
+
+ protected static $kSupportedKeys =
+ array('state', 'code', 'access_token', 'user_id');
+
++ protected $kPersistantData = array();
++
+ /**
+ * Provides the implementations of the inherited abstract
+ * methods. The implementation uses PHP sessions to maintain
+@@ -55,7 +42,7 @@
+ }
+
+ $session_var_name = $this->constructSessionVariableName($key);
+- $_SESSION[$session_var_name] = $value;
++ $this->kPersistantData[$session_var_name] = $value;
+ }
+
+ protected function getPersistentData($key, $default = false) {
+@@ -65,8 +52,8 @@
+ }
+
+ $session_var_name = $this->constructSessionVariableName($key);
+- return isset($_SESSION[$session_var_name]) ?
+- $_SESSION[$session_var_name] : $default;
++ return isset($this->kPersistantData[$session_var_name]) ?
++ $this->kPersistantData[$session_var_name] : $default;
+ }
+
+ protected function clearPersistentData($key) {
+@@ -76,7 +63,7 @@
+ }
+
+ $session_var_name = $this->constructSessionVariableName($key);
+- unset($_SESSION[$session_var_name]);
++ unset($this->kPersistantData[$session_var_name]);
+ }
+
+ protected function clearAllPersistentData() {
More information about the pld-cvs-commit
mailing list