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)));
|
||||||
@@ -867,10 +867,10 @@ class MP2Migrator {
|
|||||||
'type' => $type,
|
'type' => $type,
|
||||||
'name' => $field['name'],
|
'name' => $field['name'],
|
||||||
'id' => $field_id,
|
'id' => $field_id,
|
||||||
'unique' => !in_array($field['type'], array('html', 'divider', 'email', 'submit'))? "1" : "0",
|
'unique' => !in_array($field['type'], array('html', 'divider', 'email', 'submit')) ? "1" : "0",
|
||||||
'static' => in_array($field_id, array('email', 'submit'))? "1" : "0",
|
'static' => in_array($field_id, array('email', 'submit')) ? "1" : "0",
|
||||||
'params' => $params,
|
'params' => $params,
|
||||||
'position' => isset($field['position'])? $field['position'] : '',
|
'position' => isset($field['position']) ? $field['position'] : '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -988,10 +988,10 @@ class MP2Migrator {
|
|||||||
$subscribe = Setting::getValue('subscribe');
|
$subscribe = Setting::getValue('subscribe');
|
||||||
$subscribe['on_comment']['enabled'] = isset($options['commentform']) ? $options['commentform'] : '0';
|
$subscribe['on_comment']['enabled'] = isset($options['commentform']) ? $options['commentform'] : '0';
|
||||||
$subscribe['on_comment']['label'] = isset($options['commentform_linkname']) ? $options['commentform_linkname'] : '';
|
$subscribe['on_comment']['label'] = isset($options['commentform_linkname']) ? $options['commentform_linkname'] : '';
|
||||||
$subscribe['on_comment']['segments'] = isset($options['commentform_lists'])? $this->getMappedSegmentIds($options['commentform_lists']) : array();
|
$subscribe['on_comment']['segments'] = isset($options['commentform_lists']) ? $this->getMappedSegmentIds($options['commentform_lists']) : array();
|
||||||
$subscribe['on_register']['enabled'] = isset($options['registerform']) ? $options['registerform'] : '0';
|
$subscribe['on_register']['enabled'] = isset($options['registerform']) ? $options['registerform'] : '0';
|
||||||
$subscribe['on_register']['label'] = isset($options['registerform_linkname']) ? $options['registerform_linkname'] : '';
|
$subscribe['on_register']['label'] = isset($options['registerform_linkname']) ? $options['registerform_linkname'] : '';
|
||||||
$subscribe['on_register']['segments'] = isset($options['registerform_lists'])? $this->getMappedSegmentIds($options['registerform_lists']) : array();
|
$subscribe['on_register']['segments'] = isset($options['registerform_lists']) ? $this->getMappedSegmentIds($options['registerform_lists']) : array();
|
||||||
Setting::setValue('subscribe', $subscribe);
|
Setting::setValue('subscribe', $subscribe);
|
||||||
|
|
||||||
// Subscription
|
// Subscription
|
||||||
@@ -999,7 +999,7 @@ class MP2Migrator {
|
|||||||
$subscription['pages']['unsubscribe'] = isset($options['unsubscribe_page']) ? $options['unsubscribe_page'] : '';
|
$subscription['pages']['unsubscribe'] = isset($options['unsubscribe_page']) ? $options['unsubscribe_page'] : '';
|
||||||
$subscription['pages']['confirmation'] = isset($options['confirmation_page']) ? $options['confirmation_page'] : '';
|
$subscription['pages']['confirmation'] = isset($options['confirmation_page']) ? $options['confirmation_page'] : '';
|
||||||
$subscription['pages']['manage'] = isset($options['subscriptions_page']) ? $options['subscriptions_page'] : '';
|
$subscription['pages']['manage'] = isset($options['subscriptions_page']) ? $options['subscriptions_page'] : '';
|
||||||
$subscription['segments'] = isset($options['manage_subscriptions_lists'])? $this->getMappedSegmentIds($options['manage_subscriptions_lists']) : array();
|
$subscription['segments'] = isset($options['manage_subscriptions_lists']) ? $this->getMappedSegmentIds($options['manage_subscriptions_lists']) : array();
|
||||||
Setting::setValue('subscription', $subscription);
|
Setting::setValue('subscription', $subscription);
|
||||||
|
|
||||||
// Confirmation email
|
// Confirmation email
|
||||||
@@ -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'));
|
||||||
@@ -211,7 +214,7 @@ class Export {
|
|||||||
} else {
|
} else {
|
||||||
// if all subscribers belong to at least one segment, select the segment name
|
// if all subscribers belong to at least one segment, select the segment name
|
||||||
$subscribers = $subscribers
|
$subscribers = $subscribers
|
||||||
->selectExpr('MAX('.Segment::$_table . '.name) as segment_name')
|
->selectExpr('MAX(' . Segment::$_table . '.name) as segment_name')
|
||||||
->whereIn(SubscriberSegment::$_table . '.segment_id', $this->segments);
|
->whereIn(SubscriberSegment::$_table . '.segment_id', $this->segments);
|
||||||
}
|
}
|
||||||
if($this->group_by_segment_option) {
|
if($this->group_by_segment_option) {
|
||||||
|
Reference in New Issue
Block a user