Conditionally uses set_time_limit() when function is not disabled
This commit is contained in:
@@ -2,21 +2,19 @@
|
|||||||
|
|
||||||
namespace MailPoet\Config;
|
namespace MailPoet\Config;
|
||||||
|
|
||||||
use MailPoet\Util\ProgressBar;
|
|
||||||
use MailPoet\Models\Form;
|
|
||||||
use MailPoet\Models\Setting;
|
|
||||||
use MailPoet\Models\Segment;
|
|
||||||
use MailPoet\Models\Subscriber;
|
|
||||||
use MailPoet\Models\CustomField;
|
use MailPoet\Models\CustomField;
|
||||||
use MailPoet\Models\SubscriberSegment;
|
use MailPoet\Models\Form;
|
||||||
use MailPoet\Models\SubscriberCustomField;
|
|
||||||
use MailPoet\Models\MappingToExternalEntities;
|
use MailPoet\Models\MappingToExternalEntities;
|
||||||
use MailPoet\Config\Activator;
|
use MailPoet\Models\Segment;
|
||||||
|
use MailPoet\Models\Setting;
|
||||||
|
use MailPoet\Models\Subscriber;
|
||||||
|
use MailPoet\Models\SubscriberCustomField;
|
||||||
|
use MailPoet\Models\SubscriberSegment;
|
||||||
|
use MailPoet\Util\ProgressBar;
|
||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
class MP2Migrator {
|
class MP2Migrator {
|
||||||
|
|
||||||
const IMPORT_TIMEOUT_IN_SECONDS = 7200; // Timeout = 2 hours
|
const IMPORT_TIMEOUT_IN_SECONDS = 7200; // Timeout = 2 hours
|
||||||
const CHUNK_SIZE = 10; // To import the data by batch
|
const CHUNK_SIZE = 10; // To import the data by batch
|
||||||
|
|
||||||
@@ -145,7 +143,9 @@ class MP2Migrator {
|
|||||||
* @return string Result
|
* @return string Result
|
||||||
*/
|
*/
|
||||||
public function import() {
|
public function import() {
|
||||||
set_time_limit(self::IMPORT_TIMEOUT_IN_SECONDS);
|
if(strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
||||||
|
@set_time_limit(3600);
|
||||||
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
$datetime = new \MailPoet\WP\DateTime();
|
$datetime = new \MailPoet\WP\DateTime();
|
||||||
$this->log(sprintf('=== ' . __('START IMPORT', 'mailpoet') . ' %s ===', $datetime->formatTime(time(), \MailPoet\WP\DateTime::DEFAULT_DATE_TIME_FORMAT)));
|
$this->log(sprintf('=== ' . __('START IMPORT', 'mailpoet') . ' %s ===', $datetime->formatTime(time(), \MailPoet\WP\DateTime::DEFAULT_DATE_TIME_FORMAT)));
|
||||||
@@ -1139,5 +1139,4 @@ class MP2Migrator {
|
|||||||
}
|
}
|
||||||
return $emails_number;
|
return $emails_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace MailPoet\Subscribers\ImportExport\Export;
|
namespace MailPoet\Subscribers\ImportExport\Export;
|
||||||
|
|
||||||
use MailPoet\Config\Env;
|
use MailPoet\Config\Env;
|
||||||
@@ -26,7 +27,9 @@ class Export {
|
|||||||
public $subscriber_batch_size;
|
public $subscriber_batch_size;
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
|
if(strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
}
|
||||||
$this->export_confirmed_option = $data['export_confirmed_option'];
|
$this->export_confirmed_option = $data['export_confirmed_option'];
|
||||||
$this->export_format_option = $data['export_format_option'];
|
$this->export_format_option = $data['export_format_option'];
|
||||||
$this->group_by_segment_option = $data['group_by_segment_option'];
|
$this->group_by_segment_option = $data['group_by_segment_option'];
|
||||||
@@ -47,7 +50,7 @@ class Export {
|
|||||||
function process() {
|
function process() {
|
||||||
try {
|
try {
|
||||||
if(is_writable($this->export_path) === false) {
|
if(is_writable($this->export_path) === false) {
|
||||||
throw new \Exception(__("The export file could not be saved on the server.", 'mailpoet'));
|
throw new \Exception(__('The export file could not be saved on the server.', 'mailpoet'));
|
||||||
}
|
}
|
||||||
if(!extension_loaded('zip')) {
|
if(!extension_loaded('zip')) {
|
||||||
throw new \Exception(__('Export requires a ZIP extension to be installed on the host.', 'mailpoet'));
|
throw new \Exception(__('Export requires a ZIP extension to be installed on the host.', 'mailpoet'));
|
||||||
|
Reference in New Issue
Block a user