From aa92bc43ef7abc6b0166320e5146061694dbc224 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Tue, 27 Nov 2018 20:31:08 +0000 Subject: [PATCH 1/2] feat: use new json column type for json fields --- php-classes/SQL.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php-classes/SQL.class.php b/php-classes/SQL.class.php index e81acf316..984581b80 100644 --- a/php-classes/SQL.class.php +++ b/php-classes/SQL.class.php @@ -140,8 +140,9 @@ public static function getSQLType($field) return sprintf(!$field['length'] || $field['type'] == 'varchar' ? 'varchar(%u)' : 'char(%u)', $field['length'] ? $field['length'] : 255); case 'clob': case 'serialized': - case 'json': return 'text'; + case 'json': + return 'json'; case 'blob': return 'blob'; From d21402fa4d7c1ffba038b3469924b4ed24959e73 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 28 Nov 2018 02:33:11 +0000 Subject: [PATCH 2/2] feat: improve error handling when running wkhtmltopdf --- php-classes/RequestHandler.class.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/php-classes/RequestHandler.class.php b/php-classes/RequestHandler.class.php index 413ab04ac..44b496bd0 100644 --- a/php-classes/RequestHandler.class.php +++ b/php-classes/RequestHandler.class.php @@ -166,22 +166,25 @@ public static function respondPrint($responseID, $responseData = array(), $forma $tmpPath = tempnam('/tmp', 'e_pdf_'); file_put_contents($tmpPath.'.html', $html); - - header('Content-Type: application/pdf'); - header('Content-Disposition: attachment; filename="'.str_replace('"', '', $responseID).'.pdf"'); - - exec(implode(' ', [ + + $command = implode(' ', [ static::$wkhtmltopdfPath, static::$wkhtmltopdfArguments, escapeshellarg($tmpPath.'.html'), escapeshellarg($tmpPath.'.pdf') - ])); - + ]); + + $output = exec($command); + if (!file_exists("$tmpPath.pdf")) { header('HTTP/1.0 501 Not Implemented'); - die('Unable to generate PDF, check that this system has wkhtmltopdf installed'); + header('Content-Type: text/plain'); + die("Unable to generate PDF, see command/output below and check that this system has wkhtmltopdf installed.\n\ncommand: {$command}\n\noutput: {$output}"); } - + + header('Content-Type: application/pdf'); + header('Content-Disposition: attachment; filename="'.str_replace('"', '', $responseID).'.pdf"'); + readfile($tmpPath.'.pdf'); exit(); } elseif ($format == 'html') {