afterlogic / webmail-lite

AfterLogic WebMail Lite PHP. Fast and easy-to-use webmail front-end for your existing IMAP mail server, Plesk or cPanel.
https://afterlogic.org/webmail-lite
GNU Affero General Public License v3.0
443 stars 120 forks source link

HHVM: Body of sent e-mail is blank #36

Closed aseering closed 8 years ago

aseering commented 8 years ago

I'm not sure if HHVM is supported? It mostly works, but I'm hitting this issue:

[00:18:15.04][00870624] PHP[NOTICE]: /var/www/webmail/libraries/MailSo/Base/StreamWrappers/Binary.php
 [line:230, code:2]
[00:18:15.04][00870624] PHP[NOTICE]: Error: stream_filter_append(): unable to locate filter "convert.quoted-printable-encode"
[00:18:15.10][00870624] PHP[NOTICE]: /var/www/webmail/libraries/MailSo/Base/StreamWrappers/Binary.php [line:230, code:2]
[00:18:15.10][00870624] PHP[NOTICE]: Error: stream_filter_append(): unable to locate filter "convert.quoted-printable-encode"

This appears to be due to facebook/hhvm#6440, which has a patch but the patch has some unresolved test failures. Basically, HHVM hasn't implemented any of the convert.* filters yet.

aseering commented 8 years ago

I was able to work around this issue by adding the following to the top of libraries/MailSo/Base/StreamWrappers/Binary.php (based on the patch at facebook/hhvm#6440 -- review patch (reviews.facebook.net)):

class ConvertFilter extends \php_user_filter {
  private $filterFunction;

  public function onCreate() {
    /* strip out prefix "convert." */
    $filterName = substr($this->filtername, 8);
    switch ($filterName) {
      case 'base64-encode':
      case 'base64-decode':
      case 'quoted-printable-encode':
      case 'quoted-printable-encode':
        $this->filterFunction = str_replace('-', '_', $filterName);
        break;
      default:
        return false;
         break;
    }
    return true;
  }

  public function filter($in, $out, &$consumed, $closing) {
    while ($bucket = stream_bucket_make_writeable($in)) {
      stream_bucket_append(
        $out,
        stream_bucket_new($this->stream,
                          call_user_func($this->filterFunction,
                                         $bucket->data)
                          )
      );
    }
    return \PSFS_PASS_ON;
  }
}

stream_filter_register('convert.*', 'MailSo\Base\StreamWrappers\ConvertFilter');

This feels like a total hack to me so I'm reluctant to put up a Pull Request with it, but I can if it'd be useful.

mailbee commented 8 years ago

Thank you, Adam. You're right, the patch indeed looks like a hack so that adding it into the regular version does not seem the right thing to do but we'll reference this thread for those experiencing the same issue and they will be able to fix it for the time being. Finally, I hope HHVM devs will fix the original issue and the whole thing will be no longer important.