[sync] Patches for BlackBerry etc.

Brent J. Nordquist bjn at horde.org
Sat May 28 08:28:01 PDT 2005


On Sat, May 28, 2005 at 12:25:53AM -0400, Chuck Hagenbuch wrote:
> Quoting "Brent J. Nordquist" <bjn at horde.org>:
> > With this patch, I get farther, but am still failing at other locations
> > where $backend is properly defined as global, but is not an object
> > (has been freed by then, or something).

All right; cleaning up several more in the same way Chuck's commit did, I
arrive at the following patch (attached and inline below). Now I get no
more PHP fatal crashes; the client and server exchange one packet. So,
progress. :-)

However, my BlackBerry reports "Synchronization failed. String index
out of range: -9". I've put the packet dumps and horde log here

	http://www.nordist.net/~bjn/sync4j/

if anyone wants a look. At this point my lack of knowledge of SyncML is
my bottleneck :-) so I need to do some reading.

Index: SyncML.php
===================================================================
RCS file: /repository/framework/SyncML/SyncML.php,v
retrieving revision 1.32
diff -u -r1.32 SyncML.php
--- SyncML.php	28 May 2005 04:24:53 -0000	1.32
+++ SyncML.php	28 May 2005 15:18:23 -0000
@@ -157,7 +157,7 @@
 
         if (!isset($_SESSION['SyncML.state'])) {
             // Create a new state if one does not already exist.
-            $GLOBALS['backend-']>logMessage('New session created: '
+            $GLOBALS['backend']->logMessage('New session created: '
                               . session_id(),
                               __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
@@ -178,7 +178,6 @@
 
     function endElement($uri, $element)
     {
-        global $backend;
         switch (count($this->_Stack)) {
         case 1:
             /*
@@ -212,7 +211,7 @@
 
             $_SESSION['SyncML.state'] = $state;
 
-            $backend->logMessage($str, __FILE__, __LINE__, PEAR_LOG_DEBUG);
+            $GLOBALS['backend']->logMessage($str, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
             // Got the state; now write our SyncHdr header.
             $this->outputSyncHdr($this->_output);
@@ -450,7 +449,6 @@
 
     function endElement($uri, $element)
     {
-        global $backend;
         switch (count($this->_Stack)) {
         case 1:
             // </SyncBody></SyncML>
@@ -460,13 +458,12 @@
                 // and map.  This means, we're through! The session can be
                 // closed and the Anchors saved for the next Sync
                 $state = & $_SESSION['SyncML.state'];
-                $backend->logMessage('sync' . session_id()
+                $GLOBALS['backend']->logMessage('sync' . session_id()
                                   . ' completed successfully!'
                                   . ' Storing Client-TS '
                                   . $state->_clientAnchorNext,
                                    __FILE__, __LINE__, PEAR_LOG_INFO);
-                global $backend;
-                $backend->writeSyncSummary(
+                $GLOBALS['backend']->writeSyncSummary(
                     $state->getSyncIdentifier(),
                     $state->_clientAnchorNext,
                     $state->_serverAnchorNext);
@@ -475,12 +472,12 @@
                 foreach($log as $k => $v) {
                     $s .= " $k=$v";
               }
-                $backend->logMessage('Summary:' . $s, __FILE__, __LINE__, PEAR_LOG_INFO);
+                $GLOBALS['backend']->logMessage('Summary:' . $s, __FILE__, __LINE__, PEAR_LOG_INFO);
                 // session can be closed here:
                 session_unset();
                 session_destroy();
             } else {
-                $backend->logMessage('SyncML: return message completed',
+                $GLOBALS['backend']->logMessage('SyncML: return message completed',
                                    __FILE__, __LINE__, PEAR_LOG_DEBUG);
             }
             break;

-- 
Brent J. Nordquist <bjn at horde.org> N0BJN
Other contact information: http://www.nordist.net/contact.html
-------------- next part --------------
Index: SyncML.php
===================================================================
RCS file: /repository/framework/SyncML/SyncML.php,v
retrieving revision 1.32
diff -u -r1.32 SyncML.php
--- SyncML.php	28 May 2005 04:24:53 -0000	1.32
+++ SyncML.php	28 May 2005 15:18:23 -0000
@@ -157,7 +157,7 @@
 
         if (!isset($_SESSION['SyncML.state'])) {
             // Create a new state if one does not already exist.
-            $GLOBALS['backend-']>logMessage('New session created: '
+            $GLOBALS['backend']->logMessage('New session created: '
                               . session_id(),
                               __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
@@ -178,7 +178,6 @@
 
     function endElement($uri, $element)
     {
-        global $backend;
         switch (count($this->_Stack)) {
         case 1:
             /*
@@ -212,7 +211,7 @@
 
             $_SESSION['SyncML.state'] = $state;
 
-            $backend->logMessage($str, __FILE__, __LINE__, PEAR_LOG_DEBUG);
+            $GLOBALS['backend']->logMessage($str, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
             // Got the state; now write our SyncHdr header.
             $this->outputSyncHdr($this->_output);
@@ -450,7 +449,6 @@
 
     function endElement($uri, $element)
     {
-        global $backend;
         switch (count($this->_Stack)) {
         case 1:
             // </SyncBody></SyncML>
@@ -460,13 +458,12 @@
                 // and map.  This means, we're through! The session can be
                 // closed and the Anchors saved for the next Sync
                 $state = & $_SESSION['SyncML.state'];
-                $backend->logMessage('sync' . session_id()
+                $GLOBALS['backend']->logMessage('sync' . session_id()
                                   . ' completed successfully!'
                                   . ' Storing Client-TS '
                                   . $state->_clientAnchorNext,
                                    __FILE__, __LINE__, PEAR_LOG_INFO);
-                global $backend;
-                $backend->writeSyncSummary(
+                $GLOBALS['backend']->writeSyncSummary(
                     $state->getSyncIdentifier(),
                     $state->_clientAnchorNext,
                     $state->_serverAnchorNext);
@@ -475,12 +472,12 @@
                 foreach($log as $k => $v) {
                     $s .= " $k=$v";
               }
-                $backend->logMessage('Summary:' . $s, __FILE__, __LINE__, PEAR_LOG_INFO);
+                $GLOBALS['backend']->logMessage('Summary:' . $s, __FILE__, __LINE__, PEAR_LOG_INFO);
                 // session can be closed here:
                 session_unset();
                 session_destroy();
             } else {
-                $backend->logMessage('SyncML: return message completed',
+                $GLOBALS['backend']->logMessage('SyncML: return message completed',
                                    __FILE__, __LINE__, PEAR_LOG_DEBUG);
             }
             break;


More information about the sync mailing list