- Fixes code style
This commit is contained in:
@ -25,13 +25,10 @@ class TaskScheduler {
|
|||||||
switch($this->method) {
|
switch($this->method) {
|
||||||
case self::METHOD_MAILPOET:
|
case self::METHOD_MAILPOET:
|
||||||
return $this->configureMailpoetScheduler();
|
return $this->configureMailpoetScheduler();
|
||||||
break;
|
|
||||||
case self::METHOD_WORDPRESS:
|
case self::METHOD_WORDPRESS:
|
||||||
return $this->configureWordpressScheduler();
|
return $this->configureWordpressScheduler();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new \Exception(__("Task scheduler is not configured"));
|
throw new \Exception(__("Task scheduler is not configured"));
|
||||||
break;
|
|
||||||
};
|
};
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
// ignore exceptions as they should not prevent the rest of the site from loading
|
// ignore exceptions as they should not prevent the rest of the site from loading
|
||||||
@ -41,7 +38,6 @@ class TaskScheduler {
|
|||||||
function configureMailpoetScheduler() {
|
function configureMailpoetScheduler() {
|
||||||
$supervisor = new Supervisor();
|
$supervisor = new Supervisor();
|
||||||
$supervisor->checkDaemon();
|
$supervisor->checkDaemon();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureWordpressScheduler() {
|
function configureWordpressScheduler() {
|
||||||
@ -60,7 +56,6 @@ class TaskScheduler {
|
|||||||
if($cron_daemon) {
|
if($cron_daemon) {
|
||||||
CronHelper::deleteDaemon();
|
CronHelper::deleteDaemon();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAvailableMethods() {
|
static function getAvailableMethods() {
|
||||||
|
@ -66,44 +66,40 @@ class MailChimp {
|
|||||||
$connection = @fopen($url, 'r');
|
$connection = @fopen($url, 'r');
|
||||||
if(!$connection) {
|
if(!$connection) {
|
||||||
return $this->processError('connection');
|
return $this->processError('connection');
|
||||||
} else {
|
|
||||||
$i = 0;
|
|
||||||
$header = array();
|
|
||||||
while(!feof($connection)) {
|
|
||||||
$buffer = fgets($connection, 4096);
|
|
||||||
if(trim($buffer) !== '') {
|
|
||||||
$obj = json_decode($buffer);
|
|
||||||
if($i === 0) {
|
|
||||||
$header = $obj;
|
|
||||||
if(is_object($header) && isset($header->error)) {
|
|
||||||
return $this->processError('lists');
|
|
||||||
}
|
|
||||||
if(!isset($header_hash)) {
|
|
||||||
$header_hash = md5(implode(',', $header));
|
|
||||||
} else {
|
|
||||||
if(md5(implode(',', $header) !== $header_hash)) {
|
|
||||||
return $this->processError('headers');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$subscribers[] = $obj;
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bytes_fetched += strlen($buffer);
|
|
||||||
if($bytes_fetched > $this->max_post_size) {
|
|
||||||
return $this->processError('size');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose($connection);
|
|
||||||
}
|
}
|
||||||
|
$i = 0;
|
||||||
|
$header = array();
|
||||||
|
while(!feof($connection)) {
|
||||||
|
$buffer = fgets($connection, 4096);
|
||||||
|
if(trim($buffer) !== '') {
|
||||||
|
$obj = json_decode($buffer);
|
||||||
|
if($i === 0) {
|
||||||
|
$header = $obj;
|
||||||
|
if(is_object($header) && isset($header->error)) {
|
||||||
|
return $this->processError('lists');
|
||||||
|
}
|
||||||
|
if(!isset($header_hash)) {
|
||||||
|
$header_hash = md5(implode(',', $header));
|
||||||
|
} else {
|
||||||
|
if(md5(implode(',', $header) !== $header_hash)) {
|
||||||
|
return $this->processError('headers');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$subscribers[] = $obj;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$bytes_fetched += strlen($buffer);
|
||||||
|
if($bytes_fetched > $this->max_post_size) {
|
||||||
|
return $this->processError('size');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!count($subscribers)) {
|
if(!count($subscribers)) {
|
||||||
return $this->processError('subscribers');
|
return $this->processError('subscribers');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@ -130,7 +126,7 @@ class MailChimp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processError($error) {
|
function processError($error) {
|
||||||
switch ($error) {
|
switch($error) {
|
||||||
case 'API':
|
case 'API':
|
||||||
$errorMessage = __('Invalid API Key.');
|
$errorMessage = __('Invalid API Key.');
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user