Fwd: Re: [kronolith] reminder.php and @localhost email problem

Chuck Hagenbuch chuck at horde.org
Fri Apr 2 08:06:47 PST 2004



----- Forwarded message from tasin at fhm.edu -----
    Date: Fri, 02 Apr 2004 14:52:34 +0200
    From: "W. Tasin" <tasin at fhm.edu>
Reply-To: "W. Tasin" <tasin at fhm.edu>
 Subject: Re: [kronolith] reminder.php and @localhost email problem
      To: Chuck Hagenbuch <chuck at horde.org>

Hi Chuck,

unfortunately I was tricked out by the cache. AFAICS that patch doesn't
harm, but it also doesn't correct the problem.
After deleting all session files and cache files I had the same problem.

So here is my second version, but I consider this as a patch to discuss,
because I cannot check all preference backends (e. g. LDAP).

Here's the explanation to the problem again:
Inside the horde_prefs sql database the identities entry is corrupted:
a:1:{i:0;a:14:{s:2:"id";s:18:"Standardidentität";s:8:"fullname";s:8:"W.
Tasin";s:9:"from_addr";s:13:"tasin at fhm.edu";.....}

The conversion from UTF-8 to iso-8859-1 (for the mysql database}, is
done with the serialized string, so the string length of the "id" value,
doesn't match anymore.

I found useless code inside framework/Identity.php and I consider this
as part of the solution, but not done completely or revoked, because it
caused trouble:

framework/Identity/Identity.php LINE  75:

        if (is_array($this->_identities)) {
            String::convertCharset($this->_identities,
$this->_prefs->getCharset());
        }

and the same in LINE 94.
----

The String::convertCharset() is a function and the return value isn't
assigned to an array, so it does nothing I can see.

I think these are the points where the array was intended to be
corrected, so I did the following patch (see at the attachment).
This is the tricky version and I don't know if this didn't affect any
other backend.

IMPORTANT note: There is an other side effect is that the actual saved
identities doesn't work anymore, they have to be reentered or corrected.

Should I repost this message to kronolith@ or to horde@/imp@?

BTW: Your patch

RCS file: /horde/cvs/kronolith/lib/Driver/sql.php,v
retrieving revision 1.113
retrieving revision 1.114
diff -p --unified=3 -r1.113 -r1.114

has two typos in it: $start->corrrect() instead of $start->correct()

BTW2: with the actual CVS version reminder doesn't get an alert event,
with the version of 2004-03-31 it still works. I will have a look at it
and tell you more later.

Ciao

Walter

Chuck Hagenbuch wrote:

> Quoting "W. Tasin" <tasin at fhm.edu>:
>
>> The problem - in my case using preferences from sql backend - is the
>> character conversion call in Prefs_sql::_convertFromDriver($value)
>> respectively the last parameter inside String::convertCharset(...).
>
>
>> My patch correct this behaviour, but I don't know if this should be done
>> in String::convertCharset(); I leave this decision to one of the horde
>> developer team...
>
>
> Committed, thanks.
>
> -chuck
>
> --
> "Regard my poor demoralized mule!" - Juan Valdez


--
oohhh sveglia.... il mondo e' ammalato, ma x colpa di chi.........
(Zucchero)
:-------W._Tasin,_FB_04,_FHM-------------------PGP-KeyID:0x7961A645---:
<Key-Fingerprint: 1610 835F 0080 32F4 6140  6CF7 A7D0 44CD 7961A645>
<http://wwwkeys.pgp.net:11371/pks/lookup?op=index&search=0x7961A645&fingerprint=on>

----- End forwarded message -----


-chuck

--
"Regard my poor demoralized mule!" - Juan Valdez
-------------- next part --------------
--- framework/Identity/Identity.php	Sat Feb 21 18:24:00 2004
+++ framework/Identity/Identity.php	Fri Apr  2 11:54:20 2004
@@ -70,10 +70,15 @@
             $this->_prefs->retrieve();
         }
         $this->_default = $this->_prefs->getValue('default_identity');
-        $this->_identities = @unserialize($this->_prefs->getValue('identities'));
 
         if (is_array($this->_identities)) {
-            String::convertCharset($this->_identities, $this->_prefs->getCharset());
+            // convert the string back to the original charset of the backend
+            $serialized_identities=String::convertCharset($this->_prefs->getValue('identities'), NLS::getCharset(), $this->_prefs->getCharset());
+            $this->_identities = @unserialize($serialized_identities);
+            // now do the correct conversion with every element of the array
+            $this->_identities=String::convertCharset($this->_identities, $this->_prefs->getCharset(), NLS::getCharset());
+        } else {
+            $this->_identities = @unserialize($this->_prefs->getValue('identities'));
         }
 
         if (!is_array($this->_identities) || (count($this->_identities) <= 0)) {
@@ -91,11 +96,17 @@
      */
     function save()
     {
+        $serialized_identities=serialize($this->_identities);
         if (is_array($this->_identities)) {
-            String::convertCharset($this->_identities, NLS::getCharset(), $this->_prefs->getCharset());
+            // convert every element of the array with the correct charset
+            $prefs_identities=String::convertCharset($this->_identities, NLS::getCharset(), $this->_prefs->getCharset());
+            // now convert the string back to the charset actually used,
+            //  because the backend is doing the conversion of the serialized
+            //  string
+            $serialized_identities=String::convertCharset(serialize($prefs_identities), $this->_prefs->getCharset(), NLS::getCharset());
         }
 
-        $this->_prefs->setValue('identities', serialize($this->_identities));
+        $this->_prefs->setValue('identities', $serialized_identities);
         $this->_prefs->setValue('default_identity', $this->_default);
     }
 



-------------- next part --------------
--- kronolith/lib/Driver/sql.php	Thu Apr  1 06:17:35 2004
+++ kronolith/lib/Driver/sql.php	Fri Apr  2 14:17:10 2004
@@ -53,7 +53,7 @@
             if ($event->getRecurType() == KRONOLITH_RECUR_NONE) {
                 $start = &Kronolith::dateObject($event->start);
                 $start->min -= $event->getAlarm();
-                $start->corrrect();
+                $start->correct();
                 if (Kronolith::compareDateTimes($start, $date) == -1 &&
                     Kronolith::compareDateTimes($date, $event->end) == -1) {
                     $events[] = $eventId;
@@ -62,7 +62,7 @@
                 if ($next = $this->nextRecurrence($eventId, $date)) {
                     $start = &Kronolith::dateObject($next);
                     $start->min -= $event->getAlarm();
-                    $start->corrrect();
+                    $start->correct();
                     if (Kronolith::compareDateTimes($start, $date) == -1 &&
                         Kronolith::compareDateTimes($date, Kronolith::dateObject(array('year' => $next->year,
                                                                                        'month' => $next->month,



More information about the kronolith mailing list