]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Workaround for Facebook data store API behavior regression, fixes saving
authorBrion Vibber <brion@pobox.com>
Mon, 12 Oct 2009 22:36:17 +0000 (22:36 +0000)
committerBrion Vibber <brion@pobox.com>
Fri, 16 Oct 2009 21:49:46 +0000 (14:49 -0700)
of empty notice prefix text in facebook settings.

Filed bug upstream at http://bugs.developers.facebook.com/show_bug.cgi?id=7110

Per documentation, saving a pref value of "" or "0" will delete the pref key:
http://wiki.developers.facebook.com/index.php/Data.setUserPreference

which used to do what we want... Now Facebook throws back an error
"Parameter value is required" when we do this. Workaround appends a
space to empty string or "0" at save time, then trims the string when
we load it.

The input string was already trimmed at pref save time, so this won't
alter any user-visible behavior.

Thanks to ^demon in #mediawiki for pointing out the behavior regression
after testing the identi.ca Facebook app!

actions/facebooksettings.php
lib/facebookutil.php

index 84bdde9101ec227eafaabfb62e59c271b7500353..b2b1d68071a050ea7d34a02ed61227ad08220c50 100644 (file)
@@ -58,8 +58,15 @@ class FacebooksettingsAction extends FacebookAction
         $this->flink->set_flags($noticesync, $replysync, false, false);
         $result = $this->flink->update($original);
 
+        if ($prefix == '' || $prefix == '0') {
+               // Facebook bug: saving empty strings to prefs now fails
+               // http://bugs.developers.facebook.com/show_bug.cgi?id=7110
+               $trimmed = $prefix . ' ';
+        } else {
+               $trimmed = substr($prefix, 0, 128);
+           }
         $this->facebook->api_client->data_setUserPreference(FACEBOOK_NOTICE_PREFIX,
-            substr($prefix, 0, 128));
+            $trimmed);
 
         if ($result === false) {
             $this->showForm(_('There was a problem saving your sync preferences!'));
@@ -101,7 +108,7 @@ class FacebooksettingsAction extends FacebookAction
 
             $this->elementStart('li');
 
-            $prefix = $this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX);
+            $prefix = trim($this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX));
 
             $this->input('prefix', _('Prefix'),
                          ($prefix) ? $prefix : null,
index ad61b6f0a545e5f976ea413da6c799b95b21f865..c29576b64c590f723b24b195c930ebfc84659e9b 100644 (file)
@@ -99,8 +99,8 @@ function facebookBroadcastNotice($notice)
             // XXX: Does this call count against our per user FB request limit?
             // If so we should consider storing verb elsewhere or not storing
 
-            $prefix = $facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX,
-                                                                    $fbuid);
+            $prefix = trim($facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX,
+                                                                         $fbuid));
 
             $status = "$prefix $notice->content";