Re: Horde_Imap_Client failed test with 5.5.21RC1 / 5.6.4RC1

Remi Collet <[email protected]>
Newsgroups gmane.comp.horde.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 10/01/2015 07:52, Remi Collet a écrit :
> Horde_Imap_Client start to fail with upcomming new PHP version.

First analysis:

See http://news.php.net/php.internals/80363
    https://bugs.php.net/68532

I try to fix the quote filter but doesn't seems really nice.


Here is a proposal
(just for feedback, probably need php upstream feedback first)


hope this helps...

Remi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlSyRf4ACgkQYUppBSnxahgAYwCeI2epD4UHvdkEj50BXNktz106
q+wAn2yW25vjdT0drM6O+ADk+0E9ryC7
=bcMp
-----END PGP SIGNATURE-----

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
quote.patch (text/x-patch, 1.6 KB)
diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Data/Format/Filter/Quote.php b/framework/Imap_Client/lib/Horde/Imap/Client/Data/Format/Filter/Quote.php
index a3f1788..6491387 100644
--- a/framework/Imap_Client/lib/Horde/Imap/Client/Data/Format/Filter/Quote.php
+++ b/framework/Imap_Client/lib/Horde/Imap/Client/Data/Format/Filter/Quote.php
@@ -27,7 +27,20 @@ class Horde_Imap_Client_Data_Format_Filter_Quote extends php_user_filter
      */
     public function filter($in, $out, &$consumed, $closing)
     {
-        stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
+        static $start = true;
+
+//         var_dump("METHOD: ".__METHOD__, "consumed=$consumed, start=$start, closing=$closing");
+
+        if (version_compare(phpversion(), '5.5.21RC1', '<')
+            || (version_compare(phpversion(), '5.6.0', '>=')
+                && version_compare(phpversion(), '5.6.5RC1', '<'))) {
+            /* see https://bugs.php.net/68532 */
+            $closing = true;
+        }
+        if ($start) {
+            stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
+            $start = false;
+        }
 
         while ($bucket = stream_bucket_make_writeable($in)) {
             $consumed += $bucket->datalen;
@@ -35,8 +48,10 @@ class Horde_Imap_Client_Data_Format_Filter_Quote extends php_user_filter
             stream_bucket_append($out, $bucket);
         }
 
-        stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
-
+        if ($closing) {
+            stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
+            $start = true;
+        }
         return PSFS_PASS_ON;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.