Skip to content

Commit

Permalink
Remove all PDF queues on uninstallation
Browse files Browse the repository at this point in the history
Resolves #790
  • Loading branch information
jakejackson1 committed Jun 18, 2018
1 parent 3da834d commit b0c9786
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.txt
Expand Up @@ -39,7 +39,7 @@ The plugin ships with four highly-customisable PDF templates perfectly suited fo

= Requirements =

Gravity PDF can be run on most shared web hosting without any issues. It requires **PHP 5.4+** (PHP 7.0+ recommended) and at least 64MB of WP Memory (128MB+ recommended). You'll also need to be running WordPress 4.4+ and have [Gravity Forms 2.3+](https://rocketgenius.pxf.io/c/1211356/445235/7938) (affiliate link).
Gravity PDF can be run on most shared web hosting without any issues. It requires **PHP 5.4+** (PHP 7.0+ recommended) and at least 64MB of WP Memory (128MB+ recommended). You'll also need to be running WordPress 4.4+ and have [Gravity Forms 2.3.1+](https://rocketgenius.pxf.io/c/1211356/445235/7938) (affiliate link).

If you aren't sure Gravity PDF will meet your needs (and haven't got a Gravity Forms license yet) you can [try out the software via our demo site](https://demo.gravitypdf.com).

Expand Down Expand Up @@ -91,7 +91,7 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
== Changelog ==

= 5.0.0-beta1 =
* Breaking Change: Bump minimum version of Gravity Forms from 1.9 to 2.3+
* Breaking Change: Bump minimum version of Gravity Forms from 1.9 to 2.3.1+
* Breaking Change: Bump WordPress minimum version from 4.4 to 4.8+
* Breaking Change: Background process PDFs/emails on form submission and while resending notifications. Requires Background tasks is enabled.
* Breaking Change: Decouple the fonts from the plugin (see feature below)
Expand All @@ -116,7 +116,7 @@ See [CHANGELOG.txt](https://github.com/GravityPDF/gravity-pdf/blob/master/CHANGE
== Upgrade Notice ==

= 5.0.0 =
WARNING: Breaking changes! WordPress minimum version now 4.8+. Gravity Forms minimum version now 2.3+.
WARNING: Breaking changes! WordPress minimum version now 4.8+. Gravity Forms minimum version now 2.3.1+.

= 4.2.1 =
WARNING: The minimum WordPress version supported is now 4.4.
Expand Down
2 changes: 1 addition & 1 deletion pdf.php
Expand Up @@ -91,7 +91,7 @@ class GFPDF_Major_Compatibility_Checks {
*
* @since 4.0
*/
public $required_gf_version = '2.3';
public $required_gf_version = '2.3.1';

/**
* The plugin's required WordPress version
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap.php
Expand Up @@ -618,7 +618,7 @@ public function setup_settings_fields() {
* @return void
*/
public function installer() {
$model = new Model\Model_Install( $this->gform, $this->log, $this->data, $this->misc, $this->notices );
$model = new Model\Model_Install( $this->gform, $this->log, $this->data, $this->misc, $this->notices, new Helper\Helper_Pdf_Queue( $this->log ) );
$class = new Controller\Controller_Install( $model, $this->gform, $this->log, $this->notices, $this->data, $this->misc );
$class->init();

Expand Down
3 changes: 0 additions & 3 deletions src/controller/Controller_Install.php
Expand Up @@ -154,9 +154,6 @@ public function add_actions() {

/* rewrite endpoints */
add_action( 'init', [ $this->model, 'register_rewrite_rules' ] );

/* prepare for Mpdf font removal */
add_action( 'gfpdf_version_changed', [ $this->model, 'copy_fonts_to_working_directory' ] );
}

/**
Expand Down
28 changes: 16 additions & 12 deletions src/model/Model_Install.php
Expand Up @@ -7,6 +7,7 @@
use GFPDF\Helper\Helper_Misc;
use GFPDF\Helper\Helper_Notices;
use GFPDF\Helper\Helper_Abstract_Form;
use GFPDF\Helper\Helper_Pdf_Queue;

use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -103,6 +104,13 @@ class Model_Install extends Helper_Abstract_Model {
*/
protected $notices;

/**
* @var Helper_Pdf_Queue
*
* @since 5.0
*/
protected $queue;

/**
* Setup our class by injecting all our dependancies
*
Expand All @@ -111,17 +119,19 @@ class Model_Install extends Helper_Abstract_Model {
* @param \GFPDF\Helper\Helper_Data $data Our plugin data store
* @param \GFPDF\Helper\Helper_Misc $misc Our miscellaneous class
* @param \GFPDF\Helper\Helper_Notices $notices Our notice class used to queue admin messages and errors
* @param \GFPDF\Helper\Helper_Pdf_Queue $queue
*
* @since 4.0
*/
public function __construct( Helper_Abstract_Form $gform, LoggerInterface $log, Helper_Data $data, Helper_Misc $misc, Helper_Notices $notices ) {
public function __construct( Helper_Abstract_Form $gform, LoggerInterface $log, Helper_Data $data, Helper_Misc $misc, Helper_Notices $notices, Helper_Pdf_Queue $queue ) {

/* Assign our internal variables */
$this->gform = $gform;
$this->log = $log;
$this->data = $data;
$this->misc = $misc;
$this->notices = $notices;
$this->queue = $queue;
}

/**
Expand Down Expand Up @@ -424,6 +434,11 @@ public function uninstall_plugin() {
$this->remove_plugin_form_settings();
}

/* Removes background processes */
$this->queue->clear_scheduled_events();
$this->queue->clear_queue( true );
$this->queue->unlock_process();

/* Remove folder structure and deactivate */
$this->remove_folder_structure();
$this->deactivate_plugin();
Expand Down Expand Up @@ -528,15 +543,4 @@ public function redirect_to_plugins_page() {
}
exit;
}

/**
* In preparation for the removal of the Mpdf fonts we'll copy them all to our
* PDF Working Directory during an update
*
* @since 4.3
*/
public function copy_fonts_to_working_directory() {
$mpdf_dir = PDF_PLUGIN_DIR . 'vendor/blueliquiddesigns/mpdf/ttfonts/';
$this->misc->copyr( $mpdf_dir, $this->data->template_font_location );
}
}
3 changes: 2 additions & 1 deletion tests/phpunit/unit-tests/test-installer.php
Expand Up @@ -4,6 +4,7 @@

use GFPDF\Controller\Controller_Install;
use GFPDF\Model\Model_Install;
use GFPDF\Helper\Helper_Pdf_Queue;

use WP_UnitTestCase;

Expand Down Expand Up @@ -75,7 +76,7 @@ public function setUp() {
parent::setUp();

/* Setup our test classes */
$this->model = new Model_Install( $gfpdf->gform, $gfpdf->log, $gfpdf->data, $gfpdf->misc, $gfpdf->notices );
$this->model = new Model_Install( $gfpdf->gform, $gfpdf->log, $gfpdf->data, $gfpdf->misc, $gfpdf->notices, new Helper_Pdf_Queue( $gfpdf->log ) );

$this->controller = new Controller_Install( $this->model, $gfpdf->gform, $gfpdf->log, $gfpdf->notices, $gfpdf->data, $gfpdf->misc );
$this->controller->init();
Expand Down

0 comments on commit b0c9786

Please sign in to comment.