Gravity PDF - Version 5.0.2

Version Description

  • Bug: Resolve fatal error on WP Engine due to security in place that prevented mPDF font cache from being saved.
Download this release

Release Info

Developer Blue Liquid Designs
Plugin Icon 128x128 Gravity PDF
Version 5.0.2
Comparing to
See all releases

Code changes from version 5.0.1 to 5.0.2

README.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://gravitypdf.com/donate-to-plugin/
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.8
7
  Tested up to: 4.9
8
- Stable tag: 5.0.1
9
  Requires PHP: 5.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl.txt
@@ -90,6 +90,9 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
90
 
91
  == Changelog ==
92
 
 
 
 
93
  = 5.0.1 =
94
  * Bug: Ensure the mPDF temporary directory is set to the PDF Working Directory `tmp` folder [GH#817]
95
  * Bug: Refine the Background Processing description and tooltip text [GH#818]
@@ -117,7 +120,7 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
117
  * Bug: Fix Chosen Drop Down display issue when WordPress using RTL display [GH#698]
118
  * Bug: Fix PHP Notice when Post Image field is blank [GH#805]
119
  * Bug: Correct A5 Label so it correctly references 148 x 210mm [GH#811]
120
- * Bug: Correct default en_US localization strings [GH#815] (credit Garrett Hyde)
121
 
122
  See [CHANGELOG.txt](https://github.com/GravityPDF/gravity-pdf/blob/master/CHANGELOG.txt) for v4 and v3 changelog history.
123
 
5
  Tags: gravity, forms, pdf, automation, attachment, email
6
  Requires at least: 4.8
7
  Tested up to: 4.9
8
+ Stable tag: 5.0.2
9
  Requires PHP: 5.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl.txt
90
 
91
  == Changelog ==
92
 
93
+ = 5.0.2 =
94
+ * Bug: Resolve fatal error on WP Engine due to security in place that prevented mPDF font cache from being saved.
95
+
96
  = 5.0.1 =
97
  * Bug: Ensure the mPDF temporary directory is set to the PDF Working Directory `tmp` folder [GH#817]
98
  * Bug: Refine the Background Processing description and tooltip text [GH#818]
120
  * Bug: Fix Chosen Drop Down display issue when WordPress using RTL display [GH#698]
121
  * Bug: Fix PHP Notice when Post Image field is blank [GH#805]
122
  * Bug: Correct A5 Label so it correctly references 148 x 210mm [GH#811]
123
+ * Bug: Correct default en_US localization strings [GH#815] (credit Garrett Hyder)
124
 
125
  See [CHANGELOG.txt](https://github.com/GravityPDF/gravity-pdf/blob/master/CHANGELOG.txt) for v4 and v3 changelog history.
126
 
api.php CHANGED
@@ -639,8 +639,8 @@ final class GPDFAPI {
639
  return new WP_Error( 'font_delete_failure', 'There was a problem deleting the font files.' );
640
  }
641
 
642
- /* Cleanup our fontdata directory to prevent caching issues with mPDF */
643
- $misc->cleanup_dir( $data->template_fontdata_location );
644
 
645
  /* Update the database */
646
  unset( $fonts[ $font_id ] );
639
  return new WP_Error( 'font_delete_failure', 'There was a problem deleting the font files.' );
640
  }
641
 
642
+ /* Cleanup our mPDF directory to prevent caching issues with mPDF */
643
+ $misc->cleanup_dir( $data->mpdf_tmp_location );
644
 
645
  /* Update the database */
646
  unset( $fonts[ $font_id ] );
pdf.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
- Version: 5.0.1
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
@@ -37,7 +37,7 @@ if ( ! defined( 'ABSPATH' ) ) {
37
  /*
38
  * Set base constants we'll use throughout the plugin
39
  */
40
- define( 'PDF_EXTENDED_VERSION', '5.0.1' ); /* the current plugin version */
41
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
42
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
43
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
1
  <?php
2
  /*
3
  Plugin Name: Gravity PDF
4
+ Version: 5.0.2
5
  Description: Automatically generate highly-customisable PDF documents using Gravity Forms.
6
  Author: Gravity PDF
7
  Author URI: https://gravitypdf.com
37
  /*
38
  * Set base constants we'll use throughout the plugin
39
  */
40
+ define( 'PDF_EXTENDED_VERSION', '5.0.2' ); /* the current plugin version */
41
  define( 'PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); /* plugin directory path */
42
  define( 'PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); /* plugin directory url */
43
  define( 'PDF_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); /* the plugin basename */
src/assets/languages/gravity-forms-pdf-extended.pot CHANGED
@@ -141,7 +141,7 @@ msgstr ""
141
  msgid "There was a problem uninstalling Gravity PDF. Please try again."
142
  msgstr ""
143
 
144
- #: src/controller/Controller_PDF.php:321, src/view/View_PDF.php:272
145
  msgid "There was a problem generating your PDF"
146
  msgstr ""
147
 
@@ -1013,19 +1013,19 @@ msgstr ""
1013
  msgid "PDF successfully duplicated."
1014
  msgstr ""
1015
 
1016
- #: src/model/Model_Install.php:313
1017
  msgid "There was a problem creating the %s directory. Ensure you have write permissions to your uploads folder."
1018
  msgstr ""
1019
 
1020
- #: src/model/Model_Install.php:322
1021
  msgid "Gravity PDF does not have write permission to the %s directory. Contact your web hosting provider to fix the issue."
1022
  msgstr ""
1023
 
1024
- #: src/model/Model_Install.php:481
1025
  msgid "There was a problem removing the Gravity Form \"%s\" PDF configuration. Try delete manually."
1026
  msgstr ""
1027
 
1028
- #: src/model/Model_Install.php:513
1029
  msgid "There was a problem removing the %s directory. Clean up manually via (S)FTP."
1030
  msgstr ""
1031
 
@@ -1049,7 +1049,7 @@ msgstr ""
1049
  msgid "The PDF could not be saved."
1050
  msgstr ""
1051
 
1052
- #: src/model/Model_PDF.php:1856
1053
  msgid "Could not find PDF configuration requested"
1054
  msgstr ""
1055
 
141
  msgid "There was a problem uninstalling Gravity PDF. Please try again."
142
  msgstr ""
143
 
144
+ #: src/controller/Controller_PDF.php:316, src/view/View_PDF.php:272
145
  msgid "There was a problem generating your PDF"
146
  msgstr ""
147
 
1013
  msgid "PDF successfully duplicated."
1014
  msgstr ""
1015
 
1016
+ #: src/model/Model_Install.php:314
1017
  msgid "There was a problem creating the %s directory. Ensure you have write permissions to your uploads folder."
1018
  msgstr ""
1019
 
1020
+ #: src/model/Model_Install.php:323
1021
  msgid "Gravity PDF does not have write permission to the %s directory. Contact your web hosting provider to fix the issue."
1022
  msgstr ""
1023
 
1024
+ #: src/model/Model_Install.php:482
1025
  msgid "There was a problem removing the Gravity Form \"%s\" PDF configuration. Try delete manually."
1026
  msgstr ""
1027
 
1028
+ #: src/model/Model_Install.php:514
1029
  msgid "There was a problem removing the %s directory. Clean up manually via (S)FTP."
1030
  msgstr ""
1031
 
1049
  msgid "The PDF could not be saved."
1050
  msgstr ""
1051
 
1052
+ #: src/model/Model_PDF.php:1821
1053
  msgid "Could not find PDF configuration requested"
1054
  msgstr ""
1055
 
src/controller/Controller_PDF.php CHANGED
@@ -184,11 +184,6 @@ class Controller_PDF extends Helper_Abstract_Controller implements Helper_Interf
184
  'notifications',
185
  ], 9999, 3 ); /* ensure Gravity PDF is one of the last filters to be applied */
186
 
187
- /* Modify mPDF's path locations */
188
- add_filter( 'mpdf_tmp_path', [ $this->model, 'mpdf_tmp_path' ] );
189
- add_filter( 'mpdf_font_path', [ $this->model, 'mpdf_font_path' ] );
190
- add_filter( 'mpdf_fontdata_path', [ $this->model, 'mpdf_tmp_font_path' ] );
191
-
192
  /* Change mPDF settings */
193
  add_filter( 'mpdf_font_data', [ $this->model, 'register_custom_font_data_with_mPDF' ] );
194
  add_filter( 'mpdf_font_data', [ $this->model, 'add_unregistered_fonts_to_mPDF' ], 20 );
184
  'notifications',
185
  ], 9999, 3 ); /* ensure Gravity PDF is one of the last filters to be applied */
186
 
 
 
 
 
 
187
  /* Change mPDF settings */
188
  add_filter( 'mpdf_font_data', [ $this->model, 'register_custom_font_data_with_mPDF' ] );
189
  add_filter( 'mpdf_font_data', [ $this->model, 'add_unregistered_fonts_to_mPDF' ], 20 );
src/deprecated.php CHANGED
@@ -753,7 +753,7 @@ if ( ! class_exists( 'mPDF' ) ) {
753
 
754
  'fontdata' => apply_filters( 'mpdf_font_data', $defaultFontConfig['fontdata'] ),
755
 
756
- 'tempDir' => $data->template_tmp_location . 'mpdf',
757
 
758
  'allow_output_buffering' => true,
759
  'autoLangToFont' => true,
753
 
754
  'fontdata' => apply_filters( 'mpdf_font_data', $defaultFontConfig['fontdata'] ),
755
 
756
+ 'tempDir' => $data->mpdf_tmp_location,
757
 
758
  'allow_output_buffering' => true,
759
  'autoLangToFont' => true,
src/helper/Helper_Data.php CHANGED
@@ -56,8 +56,8 @@ if ( ! defined( 'ABSPATH' ) ) {
56
  * @property string $template_location The current path to the PDF working directory
57
  * @property string $template_location_url The current URL to the PDF working directory
58
  * @property string $template_font_location The current path to the PDF font directory
59
- * @property string $template_fontdata_location The current path to the PDF tmp font directory
60
  * @property string $template_tmp_location The current path to the PDF tmp location
 
61
  * @property string $multisite_template_location The current path to the multisite PDF working directory
62
  * @property string $multisite_template_location_url The current URL to the multisite PDF working directory
63
  *
56
  * @property string $template_location The current path to the PDF working directory
57
  * @property string $template_location_url The current URL to the PDF working directory
58
  * @property string $template_font_location The current path to the PDF font directory
 
59
  * @property string $template_tmp_location The current path to the PDF tmp location
60
+ * @property string $mpdf_tmp_location The current path to the mPDF tmp directory (including fonts)
61
  * @property string $multisite_template_location The current path to the multisite PDF working directory
62
  * @property string $multisite_template_location_url The current URL to the multisite PDF working directory
63
  *
src/helper/Helper_PDF.php CHANGED
@@ -642,7 +642,7 @@ class Helper_PDF {
642
 
643
  'fontdata' => apply_filters( 'mpdf_font_data', $defaultFontConfig['fontdata'] ),
644
 
645
- 'tempDir' => $this->data->template_tmp_location . 'mpdf',
646
 
647
  'allow_output_buffering' => true,
648
  'autoLangToFont' => true,
642
 
643
  'fontdata' => apply_filters( 'mpdf_font_data', $defaultFontConfig['fontdata'] ),
644
 
645
+ 'tempDir' => $this->data->mpdf_tmp_location,
646
 
647
  'allow_output_buffering' => true,
648
  'autoLangToFont' => true,
src/model/Model_Install.php CHANGED
@@ -223,11 +223,12 @@ class Model_Install extends Helper_Abstract_Model {
223
  /* See https://gravitypdf.com/documentation/v5/gfpdf_font_location/ for more details about this filter */
224
  $this->data->template_font_location = apply_filters( 'gfpdf_font_location', $this->data->template_location . 'fonts/', $working_folder, $upload_dir ); /* can be in a directory not accessible via the web */
225
 
226
- /* @todo normally font and fontdata should be kept together but it may be worth adding a filter here */
227
- $this->data->template_fontdata_location = $this->data->template_font_location . 'fontdata/';
228
-
229
  /* See https://gravitypdf.com/documentation/v5/gfpdf_tmp_location/ for more details about this filter */
230
  $this->data->template_tmp_location = apply_filters( 'gfpdf_tmp_location', $this->data->template_location . 'tmp/', $working_folder, $upload_dir_url ); /* encouraged to move this to a directory not accessible via the web */
 
 
 
 
231
  }
232
 
233
  /**
@@ -291,8 +292,8 @@ class Model_Install extends Helper_Abstract_Model {
291
  $folders = [
292
  $this->data->template_location,
293
  $this->data->template_font_location,
294
- $this->data->template_fontdata_location,
295
  $this->data->template_tmp_location,
 
296
  ];
297
 
298
  if ( is_multisite() ) {
223
  /* See https://gravitypdf.com/documentation/v5/gfpdf_font_location/ for more details about this filter */
224
  $this->data->template_font_location = apply_filters( 'gfpdf_font_location', $this->data->template_location . 'fonts/', $working_folder, $upload_dir ); /* can be in a directory not accessible via the web */
225
 
 
 
 
226
  /* See https://gravitypdf.com/documentation/v5/gfpdf_tmp_location/ for more details about this filter */
227
  $this->data->template_tmp_location = apply_filters( 'gfpdf_tmp_location', $this->data->template_location . 'tmp/', $working_folder, $upload_dir_url ); /* encouraged to move this to a directory not accessible via the web */
228
+
229
+ /* See https://gravitypdf.com/documentation/v5/gfpdf_mpdf_tmp_location/ for more details about this filter */
230
+ $mpdf_tmp_path = get_temp_dir() . 'gravitypdf-' . md5( home_url() ) . '/mpdf';
231
+ $this->data->mpdf_tmp_location = untrailingslashit( apply_filters( 'gfpdf_mpdf_tmp_location', $mpdf_tmp_path ) );
232
  }
233
 
234
  /**
292
  $folders = [
293
  $this->data->template_location,
294
  $this->data->template_font_location,
 
295
  $this->data->template_tmp_location,
296
+ $this->data->mpdf_tmp_location,
297
  ];
298
 
299
  if ( is_multisite() ) {
src/model/Model_PDF.php CHANGED
@@ -1209,41 +1209,6 @@ class Model_PDF extends Helper_Abstract_Model {
1209
  return $form;
1210
  }
1211
 
1212
- /**
1213
- * Changes mPDF's tmp folder
1214
- *
1215
- * @param string $path The current path
1216
- *
1217
- * @return string The new path
1218
- */
1219
- public function mpdf_tmp_path( $path ) {
1220
- return $this->data->template_tmp_location;
1221
- }
1222
-
1223
- /**
1224
- * Changes mPDF's fontdata folders
1225
- *
1226
- * @param string $path The current path
1227
- *
1228
- * @return string The new path
1229
- */
1230
- public function mpdf_tmp_font_path( $path ) {
1231
- return $this->data->template_fontdata_location;
1232
- }
1233
-
1234
- /**
1235
- * Change mPDF's font folder
1236
- *
1237
- * @param $path
1238
- *
1239
- * @return string
1240
- *
1241
- * @since 5.0
1242
- */
1243
- public function mpdf_font_path( $path ) {
1244
- return $this->data->template_font_location;
1245
- }
1246
-
1247
  /**
1248
  * An mPDF filter which will register our custom font data with mPDF
1249
  *
1209
  return $form;
1210
  }
1211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1212
  /**
1213
  * An mPDF filter which will register our custom font data with mPDF
1214
  *
src/model/Model_Settings.php CHANGED
@@ -414,8 +414,8 @@ class Model_Settings extends Helper_Abstract_Model {
414
  /* Update our font database */
415
  $this->options->update_option( 'custom_fonts', $custom_fonts );
416
 
417
- /* Cleanup our fontdata directory to prevent caching issues with mPDF */
418
- $this->misc->cleanup_dir( $this->data->template_fontdata_location );
419
 
420
  }
421
 
@@ -488,8 +488,8 @@ class Model_Settings extends Helper_Abstract_Model {
488
  if ( $this->remove_font_file( $fonts[ $id ] ) ) {
489
  unset( $fonts[ $id ] );
490
 
491
- /* Cleanup our fontdata directory to prevent caching issues with mPDF */
492
- $this->misc->cleanup_dir( $this->data->template_fontdata_location );
493
 
494
  if ( $this->options->update_option( 'custom_fonts', $fonts ) ) {
495
  /* Success */
414
  /* Update our font database */
415
  $this->options->update_option( 'custom_fonts', $custom_fonts );
416
 
417
+ /* Cleanup the mPDF tmp directory to prevent font caching issues */
418
+ $this->misc->cleanup_dir( $this->data->mpdf_tmp_location );
419
 
420
  }
421
 
488
  if ( $this->remove_font_file( $fonts[ $id ] ) ) {
489
  unset( $fonts[ $id ] );
490
 
491
+ /* Cleanup the mPDF tmp directory to prevent font caching issues */
492
+ $this->misc->cleanup_dir( $this->data->mpdf_tmp_location );
493
 
494
  if ( $this->options->update_option( 'custom_fonts', $fonts ) ) {
495
  /* Success */