Problem/Motivation
While generating PDF document Drupal logs contain next notice:
Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in print_pdf_wkhtmltopdf_print_pdf_generate() (line 103 of /.../sites/all/modules/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc).
The notice appears while running the module with PHP 7.4.33. While investigating the issue it became known that proc_open() works with pipes in "r" or "w" mode. The module uses stderr pipe in "a" mode. Regarding PHP documentation in this case it's treated as "r", https://www.php.net/manual/en/function.proc-open.php:
An array describing the pipe to pass to the process. The first element is the descriptor type and the second element is an option for the given type. Valid types are pipe (the second element is either r to pass the read end of the pipe to the process, or w to pass the write end) and file (the second element is a filename). Note that anything else than w is treated like r.
Related task: https://www.drupal.org/project/print/issues/1645464.
Proposed resolution
Use stderr pipe in "w" mode.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | pipe-mode-3336199-1.patch | 778 bytes | aprogs |
Comments
Comment #2
aprogs commentedAttaching the patch.
Comment #3
leducdubleuet commentedI can confirm this simple patch is working well under PHP 8.1 as well!
Thank you very much!
Comment #4
leendertdb commentedJust tested this patch, works for us as well. The notices are now gone when running on PHP 7.4.30. Thank you!
Comment #6
jcnventura