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.

CommentFileSizeAuthor
#2 pipe-mode-3336199-1.patch778 bytesaprogs

Comments

aprogs created an issue. See original summary.

aprogs’s picture

StatusFileSize
new778 bytes

Attaching the patch.

leducdubleuet’s picture

Status: Active » Reviewed & tested by the community

I can confirm this simple patch is working well under PHP 8.1 as well!

Thank you very much!

leendertdb’s picture

Just tested this patch, works for us as well. The notices are now gone when running on PHP 7.4.30. Thank you!

  • jcnventura committed 8651614d on 7.x-2.x
    Issue #3336199 by aprogs, LeDucDuBleuet, leendertdb, jcnventura:...
jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.