File permissions on file upload under HHVM

Hello!
I have some truble with redactor and HHVM.
When I upload image by drug’n’drop in content of resource, image upload, but file permission set is 0600, and my nginx server dont have permission to read it.
It strangely, because my HHVM process have umask 022 and if I create file by standart file manager in modx it set file permission 0644 - it good permission, and nginx may have read this file.

I check redactor processor in assets/components/redactor/connector.php and add in it:
require_once dirname(dirname(dirname(dirname(FILE)))).’/config.core.php’;
require_once MODX_CORE_PATH . ‘config/’.MODX_CONFIG_KEY.’.inc.php’;
require_once MODX_CONNECTORS_PATH . ‘index.php’;
file_put_contents(MODX_CORE_PATH.‘test.txt’, ‘tester’);

And it create file in “core” modx directory with name “test.txt” and content “tester” with permission 0644 - it work good. But it create image file, downloaded by drug-n-drop, with mode 0600 - it not good!

Any idea how solve it?

Just to cross-post the solution from the support ticket here, you identified this as a potential bug in HHVM: https://github.com/facebook/hhvm/issues/6788

A workaround is a plugin on OnFileManagerBeforeUpload with content:

chmod($files['file']['tmp_name'], 0644);

And over solution: add in file hhvm.ini this string:
auto_prepend_file = hhvm_intercept.php
And file hhvm_intercept.php contain:
<?php umask(022);
It automatically run before every file .php load to hhvm and set right umask.