Conditionally uses set_time_limit() when function is not disabled

This commit is contained in:
Vlad
2017-08-11 12:15:12 -04:00
parent f35b66b3cf
commit 6fe5b7e0c5
2 changed files with 26 additions and 24 deletions

View File

@@ -2,21 +2,19 @@
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\SubscriberSegment;
use MailPoet\Models\SubscriberCustomField;
use MailPoet\Models\Form;
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;
class MP2Migrator {
const IMPORT_TIMEOUT_IN_SECONDS = 7200; // Timeout = 2 hours
const CHUNK_SIZE = 10; // To import the data by batch
@@ -145,7 +143,9 @@ class MP2Migrator {
* @return string Result
*/
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();
$datetime = new \MailPoet\WP\DateTime();
$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;
}
}

View File

@@ -1,4 +1,5 @@
<?php
namespace MailPoet\Subscribers\ImportExport\Export;
use MailPoet\Config\Env;
@@ -26,7 +27,9 @@ class Export {
public $subscriber_batch_size;
public function __construct($data) {
if(strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
set_time_limit(0);
}
$this->export_confirmed_option = $data['export_confirmed_option'];
$this->export_format_option = $data['export_format_option'];
$this->group_by_segment_option = $data['group_by_segment_option'];
@@ -47,7 +50,7 @@ class Export {
function process() {
try {
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')) {
throw new \Exception(__('Export requires a ZIP extension to be installed on the host.', 'mailpoet'));