diff --git a/RoboFile.php b/RoboFile.php index 00c4f2838d..962ae702db 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -370,7 +370,7 @@ class RoboFile extends \Robo\Tasks { 'php -d memory_limit=2G '. "$dir/phpstan.phar analyse ". "--configuration $dir/tasks/phpstan/phpstan.neon ". - '--level 0 '. + '--level 1 '. "$dir/lib" ) ->dir(__DIR__ . '/tasks/phpstan') diff --git a/lib/API/JSON/v1/Forms.php b/lib/API/JSON/v1/Forms.php index e420f19638..3c74d77a4b 100644 --- a/lib/API/JSON/v1/Forms.php +++ b/lib/API/JSON/v1/Forms.php @@ -172,6 +172,7 @@ class Forms extends APIEndpoint { // check if the user gets to pick his own lists // or if it's selected by the admin $has_segment_selection = false; + $list_selection = []; foreach($body as $i => $block) { if($block['type'] === 'segment') { $has_segment_selection = true; diff --git a/lib/API/JSON/v1/MP2Migrator.php b/lib/API/JSON/v1/MP2Migrator.php index aa3bd41d75..96967e6f33 100644 --- a/lib/API/JSON/v1/MP2Migrator.php +++ b/lib/API/JSON/v1/MP2Migrator.php @@ -11,6 +11,7 @@ class MP2Migrator extends APIEndpoint { public $permissions = array( 'global' => AccessControl::PERMISSION_MANAGE_SETTINGS ); + private $MP2Migrator; public function __construct() { $this->MP2Migrator = new \MailPoet\Config\MP2Migrator(); diff --git a/lib/Config/MP2Migrator.php b/lib/Config/MP2Migrator.php index 53db4b8fce..3bec6bf3ab 100644 --- a/lib/Config/MP2Migrator.php +++ b/lib/Config/MP2Migrator.php @@ -25,6 +25,14 @@ class MP2Migrator { private $segments_mapping = array(); // Mapping between old and new segment IDs private $wp_users_segment; private $double_optin_enabled = true; + private $mp2_campaign_table; + private $mp2_custom_field_table; + private $mp2_email_table; + private $mp2_form_table; + private $mp2_list_table; + private $mp2_user_table; + private $mp2_user_list_table; + public function __construct() { $this->defineMP2Tables(); @@ -37,27 +45,33 @@ class MP2Migrator { private function defineMP2Tables() { global $wpdb; - if(!defined('MP2_CAMPAIGN_TABLE')) { - define('MP2_CAMPAIGN_TABLE', $wpdb->prefix . 'wysija_campaign'); - } - if(!defined('MP2_CUSTOM_FIELD_TABLE')) { - define('MP2_CUSTOM_FIELD_TABLE', $wpdb->prefix . 'wysija_custom_field'); - } - if(!defined('MP2_EMAIL_TABLE')) { - define('MP2_EMAIL_TABLE', $wpdb->prefix . 'wysija_email'); - } - if(!defined('MP2_FORM_TABLE')) { - define('MP2_FORM_TABLE', $wpdb->prefix . 'wysija_form'); - } - if(!defined('MP2_LIST_TABLE')) { - define('MP2_LIST_TABLE', $wpdb->prefix . 'wysija_list'); - } - if(!defined('MP2_USER_TABLE')) { - define('MP2_USER_TABLE', $wpdb->prefix . 'wysija_user'); - } - if(!defined('MP2_USER_LIST_TABLE')) { - define('MP2_USER_LIST_TABLE', $wpdb->prefix . 'wysija_user_list'); - } + $this->mp2_campaign_table = defined('MP2_CAMPAIGN_TABLE') + ? MP2_CAMPAIGN_TABLE + : $wpdb->prefix . 'wysija_campaign'; + + $this->mp2_custom_field_table = defined('MP2_CUSTOM_FIELD_TABLE') + ? MP2_CUSTOM_FIELD_TABLE + : $wpdb->prefix . 'wysija_custom_field'; + + $this->mp2_email_table = defined('MP2_EMAIL_TABLE') + ? MP2_EMAIL_TABLE + : $wpdb->prefix . 'wysija_email'; + + $this->mp2_form_table = defined('MP2_FORM_TABLE') + ? MP2_FORM_TABLE + : $wpdb->prefix . 'wysija_form'; + + $this->mp2_list_table = defined('MP2_LIST_TABLE') + ? MP2_LIST_TABLE + : $wpdb->prefix . 'wysija_list'; + + $this->mp2_user_table = defined('MP2_USER_TABLE') + ? MP2_USER_TABLE + : $wpdb->prefix . 'wysija_user'; + + $this->mp2_user_list_table = defined('MP2_USER_LIST_TABLE') + ? MP2_USER_LIST_TABLE + : $wpdb->prefix . 'wysija_user_list'; } /** @@ -78,7 +92,7 @@ class MP2Migrator { if(Setting::getValue('mailpoet_migration_complete')) { return false; } else { - return $this->tableExists(MP2_CAMPAIGN_TABLE); // Check if the MailPoet 2 tables exist + return $this->tableExists($this->mp2_campaign_table); // Check if the MailPoet 2 tables exist } } @@ -272,17 +286,17 @@ class MP2Migrator { $result .= __('MailPoet 2 data found:', 'mailpoet') . "\n"; // User Lists - $users_lists_count = \ORM::for_table(MP2_LIST_TABLE)->count(); + $users_lists_count = \ORM::for_table($this->mp2_list_table)->count(); $total_count += $users_lists_count; $result .= sprintf(_n('%d subscribers list', '%d subscribers lists', $users_lists_count, 'mailpoet'), $users_lists_count) . "\n"; // Users - $users_count = \ORM::for_table(MP2_USER_TABLE)->count(); + $users_count = \ORM::for_table($this->mp2_user_table)->count(); $total_count += $users_count; $result .= sprintf(_n('%d subscriber', '%d subscribers', $users_count, 'mailpoet'), $users_count) . "\n"; // Forms - $forms_count = \ORM::for_table(MP2_FORM_TABLE)->count(); + $forms_count = \ORM::for_table($this->mp2_form_table)->count(); $total_count += $forms_count; $result .= sprintf(_n('%d form', '%d forms', $forms_count, 'mailpoet'), $forms_count) . "\n"; @@ -337,7 +351,7 @@ class MP2Migrator { $lists = array(); $last_id = Setting::getValue('last_imported_list_id', 0); - $table = MP2_LIST_TABLE; + $table = $this->mp2_list_table; $sql = " SELECT l.list_id, l.name, l.description, l.is_enabled, l.created_at FROM `$table` l @@ -414,7 +428,7 @@ class MP2Migrator { global $wpdb; $custom_fields = array(); - $table = MP2_CUSTOM_FIELD_TABLE; + $table = $this->mp2_custom_field_table; $sql = " SELECT cf.id, cf.name, cf.type, cf.required, cf.settings FROM `$table` cf @@ -576,7 +590,7 @@ class MP2Migrator { $users = array(); $last_id = Setting::getValue('last_imported_user_id', 0); - $table = MP2_USER_TABLE; + $table = $this->mp2_user_table; $sql = " SELECT u.* FROM `$table` u @@ -674,7 +688,7 @@ class MP2Migrator { global $wpdb; $user_lists = array(); - $table = MP2_USER_LIST_TABLE; + $table = $this->mp2_user_list_table; $sql = " SELECT ul.list_id, ul.sub_date, ul.unsub_date FROM `$table` ul @@ -721,9 +735,7 @@ class MP2Migrator { $imported_custom_fields = $this->getImportedCustomFields(); foreach($imported_custom_fields as $custom_field) { $custom_field_column = 'cf_' . $custom_field['id']; - if(isset($custom_field_column)) { - $this->importSubscriberCustomField($subscriber->id, $custom_field, $user[$custom_field_column]); - } + $this->importSubscriberCustomField($subscriber->id, $custom_field, $user[$custom_field_column]); } } @@ -828,7 +840,7 @@ class MP2Migrator { $forms = array(); $last_id = Setting::getValue('last_imported_form_id', 0); - $table = MP2_FORM_TABLE; + $table = $this->mp2_form_table; $sql = " SELECT f.* FROM `$table` f @@ -962,7 +974,7 @@ class MP2Migrator { $segment_id = $this->segments_mapping[$item_value]; $mp3_value['id'] = $segment_id; $segment = Segment::findOne($segment_id); - if(isset($segment)) { + if($segment) { $mp3_value['name'] = $segment->get('name'); } } else { @@ -1091,7 +1103,7 @@ class MP2Migrator { global $wpdb; $email = array(); - $table = MP2_EMAIL_TABLE; + $table = $this->mp2_email_table; $sql = " SELECT e.* FROM `$table` e diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index c670f294d3..9ee42dae2e 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -37,6 +37,8 @@ class Menu { const LAST_ANNOUNCEMENT_DATE = '2019-01-28 10:00:00'; public $renderer; + public $mp_api_key_valid; + public $premium_key_valid; private $access_control; private $subscribers_over_limit; private $wp; diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index 2f195f0ec8..fd02fcbbd8 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -10,6 +10,11 @@ if(!defined('ABSPATH')) exit; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); class Migrator { + + public $prefix; + private $charset_collate; + private $models; + function __construct() { $this->prefix = Env::$db_prefix; $this->charset_collate = Env::$db_charset_collate; diff --git a/lib/Config/PopulatorData/Templates/AppWelcome.php b/lib/Config/PopulatorData/Templates/AppWelcome.php index 80ffb382a3..589339c10e 100644 --- a/lib/Config/PopulatorData/Templates/AppWelcome.php +++ b/lib/Config/PopulatorData/Templates/AppWelcome.php @@ -1,7 +1,8 @@ template_image_url . '/app-welcome-email.jpg'; } -} \ No newline at end of file +} diff --git a/lib/Config/PopulatorData/Templates/Avocado.php b/lib/Config/PopulatorData/Templates/Avocado.php index f0f5a9aa02..0b56997c95 100644 --- a/lib/Config/PopulatorData/Templates/Avocado.php +++ b/lib/Config/PopulatorData/Templates/Avocado.php @@ -1,7 +1,8 @@ template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/faith'; - $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; + $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; } function get() { diff --git a/lib/Config/PopulatorData/Templates/FashionBlogA.php b/lib/Config/PopulatorData/Templates/FashionBlogA.php index e0c2017dc1..e6b2b196be 100644 --- a/lib/Config/PopulatorData/Templates/FashionBlogA.php +++ b/lib/Config/PopulatorData/Templates/FashionBlogA.php @@ -1,7 +1,8 @@ template_image_url . '/festival-event.jpg'; } -} \ No newline at end of file +} diff --git a/lib/Config/PopulatorData/Templates/Fitness.php b/lib/Config/PopulatorData/Templates/Fitness.php index 1014338539..fc0c1c4745 100644 --- a/lib/Config/PopulatorData/Templates/Fitness.php +++ b/lib/Config/PopulatorData/Templates/Fitness.php @@ -1,7 +1,8 @@ template_image_url . '/welcome-to-foodbox.jpg'; } -} \ No newline at end of file +} diff --git a/lib/Config/PopulatorData/Templates/GiftWelcome.php b/lib/Config/PopulatorData/Templates/GiftWelcome.php index b159385c6c..3a8c1a0163 100644 --- a/lib/Config/PopulatorData/Templates/GiftWelcome.php +++ b/lib/Config/PopulatorData/Templates/GiftWelcome.php @@ -1,7 +1,8 @@ template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/news_day'; - $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; + $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; } function get() { diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php index e749d4a0b5..f264a70132 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank121Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-1-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php index d80aa56e0d..65b9a58684 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank12Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php index 1420fb0998..62a91c4e59 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank13Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-3-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php index 64ae6a92a4..9ed9e20f8b 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-column'; diff --git a/lib/Config/PopulatorData/Templates/NewspaperTraditional.php b/lib/Config/PopulatorData/Templates/NewspaperTraditional.php index 131cb3b7e4..b2a4267741 100644 --- a/lib/Config/PopulatorData/Templates/NewspaperTraditional.php +++ b/lib/Config/PopulatorData/Templates/NewspaperTraditional.php @@ -1,7 +1,8 @@ template_image_url . '/piece-of-cake.jpg'; } -} \ No newline at end of file +} diff --git a/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php b/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php index a8852594bc..975dcb3ddd 100644 --- a/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class PostNotificationsBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/post-notifications-blank-1-column'; diff --git a/lib/Config/PopulatorData/Templates/Retro.php b/lib/Config/PopulatorData/Templates/Retro.php index 0b4b913652..5d6c777a24 100644 --- a/lib/Config/PopulatorData/Templates/Retro.php +++ b/lib/Config/PopulatorData/Templates/Retro.php @@ -1,7 +1,8 @@ template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/science_weekly'; - $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; + $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; } function get() { diff --git a/lib/Config/PopulatorData/Templates/Shoes.php b/lib/Config/PopulatorData/Templates/Shoes.php index 543e61a43d..5464023b61 100644 --- a/lib/Config/PopulatorData/Templates/Shoes.php +++ b/lib/Config/PopulatorData/Templates/Shoes.php @@ -9,7 +9,7 @@ class Shoes { function __construct($assets_url) { $this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/shoes'; - $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; + $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; } function get() { @@ -576,4 +576,4 @@ class Shoes { return $this->template_image_url . '/shoes.jpg'; } -} \ No newline at end of file +} diff --git a/lib/Config/PopulatorData/Templates/SimpleText.php b/lib/Config/PopulatorData/Templates/SimpleText.php index 3b24c70692..b6eaad5087 100644 --- a/lib/Config/PopulatorData/Templates/SimpleText.php +++ b/lib/Config/PopulatorData/Templates/SimpleText.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class SimpleText { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/simple-text'; diff --git a/lib/Config/PopulatorData/Templates/Sunglasses.php b/lib/Config/PopulatorData/Templates/Sunglasses.php index 4400c064de..7d8b653574 100644 --- a/lib/Config/PopulatorData/Templates/Sunglasses.php +++ b/lib/Config/PopulatorData/Templates/Sunglasses.php @@ -2,7 +2,6 @@ namespace MailPoet\Config\PopulatorData\Templates; - class Sunglasses { private $template_image_url; diff --git a/lib/Config/PopulatorData/Templates/TakeAHike.php b/lib/Config/PopulatorData/Templates/TakeAHike.php index fa9e1079bb..0c7f1f6056 100644 --- a/lib/Config/PopulatorData/Templates/TakeAHike.php +++ b/lib/Config/PopulatorData/Templates/TakeAHike.php @@ -9,7 +9,7 @@ class TakeAHike { function __construct($assets_url) { $this->template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/take_a_hike'; - $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; + $this->social_icon_url = $assets_url . '/img/newsletter_editor/social-icons'; } function get() { diff --git a/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php b/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php index 0eb444102b..e1bdce000f 100644 --- a/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php +++ b/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class WelcomeBlank12Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-2-column'; diff --git a/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php b/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php index 1ad3124f7f..e454c8dfe7 100644 --- a/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class WelcomeBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-column'; diff --git a/lib/Cron/Workers/SendingQueue/Migration.php b/lib/Cron/Workers/SendingQueue/Migration.php index 657debea80..38fda2a5dc 100644 --- a/lib/Cron/Workers/SendingQueue/Migration.php +++ b/lib/Cron/Workers/SendingQueue/Migration.php @@ -24,6 +24,9 @@ class Migration extends SimpleWorker { function prepareTask(ScheduledTask $task) { $unmigrated_columns = self::checkUnmigratedColumnsExist(); + $unmigrated_queues_count = 0; + $unmigrated_queue_subscribers = []; + if($unmigrated_columns) { $unmigrated_queues_count = $this->getUnmigratedQueues()->count(); $unmigrated_queue_subscribers = $this->getTaskIdsForUnmigratedSubscribers(); diff --git a/lib/Cron/Workers/SendingQueue/SendingQueue.php b/lib/Cron/Workers/SendingQueue/SendingQueue.php index f01bf4197a..dc49b1db0a 100644 --- a/lib/Cron/Workers/SendingQueue/SendingQueue.php +++ b/lib/Cron/Workers/SendingQueue/SendingQueue.php @@ -22,6 +22,7 @@ class SendingQueue { public $mailer_task; public $newsletter_task; public $timer; + public $batch_size; const BATCH_SIZE = 20; const TASK_BATCH_SIZE = 5; diff --git a/lib/DI/ContainerWrapper.php b/lib/DI/ContainerWrapper.php index a4af0e8d88..7be76c373b 100644 --- a/lib/DI/ContainerWrapper.php +++ b/lib/DI/ContainerWrapper.php @@ -61,7 +61,7 @@ class ContainerWrapper implements ContainerInterface { } private static function createPremiumContainer(ContainerInterface $free_container, $debug = false) { - $premium_container_factory = new ContainerFactory(new \MailPoet\Premium\DI\ContainerConfigurator($free_container), $debug); + $premium_container_factory = new ContainerFactory(new \MailPoet\Premium\DI\ContainerConfigurator(), $debug); $premium_container = $premium_container_factory->getContainer(); $premium_container->set(IContainerConfigurator::FREE_CONTAINER_SERVICE_SLUG, $free_container); $free_container->set(IContainerConfigurator::PREMIUM_CONTAINER_SERVICE_SLUG, $premium_container); diff --git a/lib/Form/Block/Html.php b/lib/Form/Block/Html.php index 3fc2b75eac..c13b892d6c 100644 --- a/lib/Form/Block/Html.php +++ b/lib/Form/Block/Html.php @@ -5,6 +5,7 @@ class Html { static function render($block) { $html = ''; + $text = ''; if(isset($block['params']['text']) && $block['params']['text']) { $text = html_entity_decode($block['params']['text'], ENT_QUOTES); diff --git a/lib/Form/Util/Styles.php b/lib/Form/Util/Styles.php index 372466303e..114039ae9b 100644 --- a/lib/Form/Util/Styles.php +++ b/lib/Form/Util/Styles.php @@ -78,6 +78,7 @@ class Styles { background-color: #5b5b5b; } EOL; + private $stylesheet; function __construct($stylesheet = null) { $this->stylesheet = $stylesheet; diff --git a/lib/Mailer/Methods/SMTP.php b/lib/Mailer/Methods/SMTP.php index fc5e2e5dae..f851c97824 100644 --- a/lib/Mailer/Methods/SMTP.php +++ b/lib/Mailer/Methods/SMTP.php @@ -18,6 +18,7 @@ class SMTP { public $reply_to; public $return_path; public $mailer; + private $mailer_logger; const SMTP_CONNECTION_TIMEOUT = 15; // seconds /** @var SMTPMapper */ diff --git a/lib/Models/CustomField.php b/lib/Models/CustomField.php index bcad797b4d..36d8445aca 100644 --- a/lib/Models/CustomField.php +++ b/lib/Models/CustomField.php @@ -5,6 +5,10 @@ use MailPoet\Form\Block\Date; if(!defined('ABSPATH')) exit; +/** + * @property string $type + * @property string|array $params + */ class CustomField extends Model { public static $_table = MP_CUSTOM_FIELDS_TABLE; const TYPE_DATE = 'date'; diff --git a/lib/Models/Form.php b/lib/Models/Form.php index 54dc8995e2..639865091e 100644 --- a/lib/Models/Form.php +++ b/lib/Models/Form.php @@ -3,6 +3,10 @@ namespace MailPoet\Models; if(!defined('ABSPATH')) exit; +/** + * @property string|array $settings + * @property string|array $body + */ class Form extends Model { public static $_table = MP_FORMS_TABLE; diff --git a/lib/Models/Model.php b/lib/Models/Model.php index c388889734..4de13f7211 100644 --- a/lib/Models/Model.php +++ b/lib/Models/Model.php @@ -19,26 +19,40 @@ if(!defined('ABSPATH')) exit; * @method array getConnectionNames() * @method $this useIdColumn($id_column) * @method \ORM|bool findOne($id=null) + * @method static \ORM|bool findOne($id=null) * @method array|\IdiormResultSet findMany() + * @method static array|\IdiormResultSet findMany() * @method \IdiormResultSet findResultSet() * @method array findArray() + * @method static array findArray() * @method $this forceAllDirty() * @method $this rawQuery($query, $parameters = array()) + * @method static $this rawQuery($query, $parameters = array()) * @method $this tableAlias($alias) + * @method static $this tableAlias($alias) * @method int countNullIdColumns() + * @method $this select($column, $alias=null) + * @method static $this select($column, $alias=null) * @method $this selectExpr($expr, $alias=null) - * @method \ORM selectMany($values) + * @method static $this selectExpr($expr, $alias=null) + * @method \ORM selectMany(...$values) + * @method static \ORM selectMany(...$values) * @method \ORM selectManyExpr($values) * @method $this rawJoin($table, $constraint, $table_alias, $parameters = array()) * @method $this innerJoin($table, $constraint, $table_alias=null) * @method $this leftOuterJoin($table, $constraint, $table_alias=null) * @method $this rightOuterJoin($table, $constraint, $table_alias=null) * @method $this fullOuterJoin($table, $constraint, $table_alias=null) + * @method $this where($column_name, $value=null) + * @method static $this where($column_name, $value=null) * @method $this whereEqual($column_name, $value=null) + * @method static $this whereEqual($column_name, $value=null) * @method $this whereNotEqual($column_name, $value=null) + * @method static $this whereNotEqual($column_name, $value=null) * @method $this whereIdIs($id) * @method $this whereAnyIs($values, $operator='=') * @method array|string whereIdIn($ids) + * @method static array|string whereIdIn($ids) * @method $this whereLike($column_name, $value=null) * @method $this whereNotLike($column_name, $value=null) * @method $this whereGt($column_name, $value=null) @@ -46,13 +60,19 @@ if(!defined('ABSPATH')) exit; * @method $this whereGte($column_name, $value=null) * @method $this whereLte($column_name, $value=null) * @method $this whereIn($column_name, $values) + * @method static $this whereIn($column_name, $values) * @method $this whereNotIn($column_name, $values) * @method $this whereNull($column_name) + * @method static $this whereNull($column_name) * @method $this whereNotNull($column_name) + * @method static $this whereNotNull($column_name) * @method $this whereRaw($clause, $parameters=array()) + * @method static $this whereRaw($clause, $parameters=array()) * @method $this deleteMany() * @method $this orderByDesc($column_name) + * @method static $this orderByDesc($column_name) * @method $this orderByAsc($column_name) + * @method static $this orderByAsc($column_name) * @method $this orderByExpr($clause) * @method $this groupBy($column_name) * @method $this groupByExpr($expr) @@ -73,10 +93,21 @@ if(!defined('ABSPATH')) exit; * @method static $this clearCache($table_name = null, $connection_name = self::DEFAULT_CONNECTION) * @method bool setExpr($key, $value = null) * @method bool isDirty($key) + * @method static ORMWrapper filter(...$args) + * @method \ORMWrapper hasMany($associated_class_name, $foreign_key_name=null, $foreign_key_name_in_current_models_table=null, $connection_name=null) + * @method \ORMWrapper hasManyThrough($associated_class_name, $join_class_name=null, $key_to_base_table=null, $key_to_associated_table=null, $key_in_base_table=null, $key_in_associated_table=null, $connection_name=null) + * @method \ORMWrapper hasOne($associated_class_name, $foreign_key_name=null, $foreign_key_name_in_current_models_table=null, $connection_name=null) + * @method \ORMWrapper|bool create($data=null) + * @method static \ORMWrapper|bool create($data=null) + * @method int count() + * @method static int count() + * + * @property string|null $created_at */ class Model extends \Sudzy\ValidModel { const DUPLICATE_RECORD = 23000; + public static $_table; protected $_errors; protected $_new_record; @@ -311,4 +342,4 @@ class Model extends \Sudzy\ValidModel { $this->setError($this->getValidationErrors()); return $success; } -} \ No newline at end of file +} diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php index ab771de381..191e444915 100644 --- a/lib/Models/Newsletter.php +++ b/lib/Models/Newsletter.php @@ -10,6 +10,22 @@ use function MailPoet\Util\array_column; if(!defined('ABSPATH')) exit; +/** + * @property int $id + * @property string $type + * @property object $queue + * @property string $hash + * @property string $status + * @property string|object $meta + * @property array $options + * @property int $children_count + * @property bool|array $statistics + * @property string $deleted_at + * @property int $children_count + * @property int $total_sent + * @property int $total_scheduled + * @property array $segments + */ class Newsletter extends Model { public static $_table = MP_NEWSLETTERS_TABLE; const TYPE_AUTOMATIC = 'automatic'; @@ -601,7 +617,7 @@ class Newsletter extends Model { } static function sentAfter($date) { - return static::table_alias('newsletters') + return static::tableAlias('newsletters') ->where('newsletters.type', self::TYPE_STANDARD) ->where('newsletters.status', self::STATUS_SENT) ->join( @@ -951,7 +967,7 @@ class Newsletter extends Model { } static function getWelcomeNotificationsForSegments($segments) { - return NewsletterOption::table_alias('options') + return NewsletterOption::tableAlias('options') ->select('options.newsletter_id') ->select('options.value', 'segment_id') ->join( @@ -972,7 +988,7 @@ class Newsletter extends Model { } static function getArchives($segment_ids = array()) { - $orm = self::table_alias('newsletters') + $orm = self::tableAlias('newsletters') ->distinct()->select('newsletters.*') ->select('newsletter_rendered_subject') ->whereIn('newsletters.type', array( diff --git a/lib/Models/ScheduledTask.php b/lib/Models/ScheduledTask.php index 5b6cffcea9..9cdb71e0c6 100644 --- a/lib/Models/ScheduledTask.php +++ b/lib/Models/ScheduledTask.php @@ -6,6 +6,11 @@ use MailPoet\WP\Functions as WPFunctions; if(!defined('ABSPATH')) exit; +/** + * @property int $id + * @property string $processed_at + * @property int $priority + */ class ScheduledTask extends Model { public static $_table = MP_SCHEDULED_TASKS_TABLE; const STATUS_COMPLETED = 'completed'; diff --git a/lib/Models/Segment.php b/lib/Models/Segment.php index bc8a7feb8c..d553e6621e 100644 --- a/lib/Models/Segment.php +++ b/lib/Models/Segment.php @@ -3,6 +3,10 @@ namespace MailPoet\Models; if(!defined('ABSPATH')) exit; +/** + * @property int $id + * @property array $subscribers_count + */ class Segment extends Model { static $_table = MP_SEGMENTS_TABLE; const TYPE_WP_USERS = 'wp_users'; @@ -71,7 +75,7 @@ class Segment extends Model { } function withSubscribersCount() { - $this->subscribers_count = SubscriberSegment::table_alias('relation') + $this->subscribers_count = SubscriberSegment::tableAlias('relation') ->where('relation.segment_id', $this->id) ->join( MP_SUBSCRIBERS_TABLE, @@ -208,7 +212,7 @@ class Segment extends Model { } static function getSegmentsForExport() { - return self::raw_query( + return self::rawQuery( '(SELECT segments.id, segments.name, COUNT(relation.subscriber_id) as subscribers ' . 'FROM ' . MP_SUBSCRIBER_SEGMENT_TABLE . ' relation ' . 'LEFT JOIN ' . self::$_table . ' segments ON segments.id = relation.segment_id ' . @@ -271,7 +275,7 @@ class Segment extends Model { } static function getAnalytics() { - $analytics = Segment::select_expr('type, count(*) as count') + $analytics = Segment::selectExpr('type, count(*) as count') ->whereNull('deleted_at') ->groupBy('type') ->findArray(); diff --git a/lib/Models/SendingQueue.php b/lib/Models/SendingQueue.php index f443aaeb73..8680202d1c 100644 --- a/lib/Models/SendingQueue.php +++ b/lib/Models/SendingQueue.php @@ -7,6 +7,14 @@ use MailPoet\Tasks\Subscribers as TaskSubscribers; if(!defined('ABSPATH')) exit; +/** + * @property int $count_processed + * @property int $count_total + * @property string $newsletter_rendered_body + * @property int $task_id + * @property string|object $meta + * @property string|array $subscribers + */ class SendingQueue extends Model { public static $_table = MP_SENDING_QUEUES_TABLE; const STATUS_COMPLETED = 'completed'; @@ -151,7 +159,7 @@ class SendingQueue extends Model { } static function getTasks() { - return ScheduledTask::table_alias('tasks') + return ScheduledTask::tableAlias('tasks') ->selectExpr('tasks.*') ->join( MP_SENDING_QUEUES_TABLE, @@ -161,7 +169,7 @@ class SendingQueue extends Model { } static function joinWithTasks() { - return static::table_alias('queues') + return static::tableAlias('queues') ->join( MP_SCHEDULED_TASKS_TABLE, 'tasks.id = queues.task_id', diff --git a/lib/Models/StatisticsClicks.php b/lib/Models/StatisticsClicks.php index 6beb47443b..8e874d7d23 100644 --- a/lib/Models/StatisticsClicks.php +++ b/lib/Models/StatisticsClicks.php @@ -26,7 +26,7 @@ class StatisticsClicks extends Model { } static function getAllForSubscriber(Subscriber $subscriber) { - return static::table_alias('clicks') + return static::tableAlias('clicks') ->select('clicks.id', 'id') ->select('newsletter_rendered_subject') ->select('clicks.created_at', 'created_at') diff --git a/lib/Models/StatisticsNewsletters.php b/lib/Models/StatisticsNewsletters.php index d332ea35e8..182f62766b 100644 --- a/lib/Models/StatisticsNewsletters.php +++ b/lib/Models/StatisticsNewsletters.php @@ -31,7 +31,7 @@ class StatisticsNewsletters extends Model { } static function getAllForSubscriber(Subscriber $subscriber) { - return static::table_alias('statistics') + return static::tableAlias('statistics') ->select('statistics.newsletter_id', 'newsletter_id') ->select('newsletter_rendered_subject') ->select('opens.created_at', 'opened_at') diff --git a/lib/Models/Subscriber.php b/lib/Models/Subscriber.php index 1126a26a62..54f6ae3841 100644 --- a/lib/Models/Subscriber.php +++ b/lib/Models/Subscriber.php @@ -10,6 +10,14 @@ use function MailPoet\Util\array_column; if(!defined('ABSPATH')) exit; +/** + * @property int $id + * @property string $email + * @property int $wp_user_id + * @property array $segments + * @property array $subscriptions + * @property string $unconfirmed_data + */ class Subscriber extends Model { public static $_table = MP_SUBSCRIBERS_TABLE; @@ -378,7 +386,7 @@ class Subscriber extends Model { } static function getSubscribedInSegments($segment_ids) { - $subscribers = SubscriberSegment::table_alias('relation') + $subscribers = SubscriberSegment::tableAlias('relation') ->whereIn('relation.segment_id', $segment_ids) ->where('relation.status', 'subscribed') ->join( @@ -518,7 +526,7 @@ class Subscriber extends Model { $custom_field_ids = array_keys($custom_fields_data); // get custom fields - $custom_fields = CustomField::findMany($custom_field_ids); + $custom_fields = CustomField::whereIdIn($custom_field_ids)->findMany(); foreach($custom_fields as $custom_field) { $value = (isset($custom_fields_data[$custom_field->id]) @@ -838,7 +846,7 @@ class Subscriber extends Model { } public function getAllSegmentNamesWithStatus() { - return Segment::table_alias('segment') + return Segment::tableAlias('segment') ->select('name') ->select('subscriber_segment.segment_id', 'segment_id') ->select('subscriber_segment.status', 'status') diff --git a/lib/Newsletter/Editor/PostListTransformer.php b/lib/Newsletter/Editor/PostListTransformer.php index 622905e00f..bad9f3696f 100644 --- a/lib/Newsletter/Editor/PostListTransformer.php +++ b/lib/Newsletter/Editor/PostListTransformer.php @@ -7,6 +7,9 @@ if(!defined('ABSPATH')) exit; class PostListTransformer { + private $args; + private $transformer; + function __construct($args) { $this->args = $args; $this->transformer = new PostTransformer($args); diff --git a/lib/Newsletter/Editor/TitleListTransformer.php b/lib/Newsletter/Editor/TitleListTransformer.php index fbec65b2c2..10d9a854f8 100644 --- a/lib/Newsletter/Editor/TitleListTransformer.php +++ b/lib/Newsletter/Editor/TitleListTransformer.php @@ -5,6 +5,8 @@ if(!defined('ABSPATH')) exit; class TitleListTransformer { + private $args; + function __construct($args) { $this->args = $args; } diff --git a/lib/Newsletter/Editor/Transformer.php b/lib/Newsletter/Editor/Transformer.php index b2df6cf989..8bb8c0e638 100644 --- a/lib/Newsletter/Editor/Transformer.php +++ b/lib/Newsletter/Editor/Transformer.php @@ -8,6 +8,8 @@ if(!defined('ABSPATH')) exit; class Transformer { + private $transformer; + function __construct($args) { $title_list_only = $args['displayType'] === 'titleOnly' && $args['titleFormat'] === 'ul'; diff --git a/lib/Newsletter/Renderer/Renderer.php b/lib/Newsletter/Renderer/Renderer.php index 3fc8f3118f..4e743cac8b 100644 --- a/lib/Newsletter/Renderer/Renderer.php +++ b/lib/Newsletter/Renderer/Renderer.php @@ -15,6 +15,9 @@ class Renderer { public $CSS_inliner; public $newsletter; public $preview; + public $premium_activated; + public $mss_activated; + private $template; const NEWSLETTER_TEMPLATE = 'Template.html'; const FILTER_POST_PROCESS = 'mailpoet_rendering_post_process'; diff --git a/lib/Newsletter/Scheduler/Scheduler.php b/lib/Newsletter/Scheduler/Scheduler.php index 81b72a5b93..5be6366c1d 100644 --- a/lib/Newsletter/Scheduler/Scheduler.php +++ b/lib/Newsletter/Scheduler/Scheduler.php @@ -147,7 +147,7 @@ class Scheduler { } static function createPostNotificationSendingTask($newsletter) { - $existing_notification_history = Newsletter::table_alias('newsletters') + $existing_notification_history = Newsletter::tableAlias('newsletters') ->where('newsletters.parent_id', $newsletter->id) ->where('newsletters.type', Newsletter::TYPE_NOTIFICATION_HISTORY) ->where('newsletters.status', Newsletter::STATUS_SENDING) @@ -194,9 +194,6 @@ class Scheduler { $newsletter->nthWeekDay : '#' . $newsletter->nthWeekDay; switch($interval_type) { - case self::INTERVAL_IMMEDIATELY: - $schedule = '* * * * *'; - break; case self::INTERVAL_IMMEDIATE: case self::INTERVAL_DAILY: $schedule = sprintf('0 %s * * *', $hour); @@ -210,6 +207,10 @@ class Scheduler { case self::INTERVAL_MONTHLY: $schedule = sprintf('0 %s %s * *', $hour, $month_day); break; + case self::INTERVAL_IMMEDIATELY: + default: + $schedule = '* * * * *'; + break; } $option_field = NewsletterOptionField::where('name', 'schedule')->findOne(); $relation = NewsletterOption::where('newsletter_id', $newsletter->id) diff --git a/lib/Router/Endpoints/ViewInBrowser.php b/lib/Router/Endpoints/ViewInBrowser.php index a6d42cd462..b15d297b06 100644 --- a/lib/Router/Endpoints/ViewInBrowser.php +++ b/lib/Router/Endpoints/ViewInBrowser.php @@ -18,6 +18,7 @@ class ViewInBrowser { public $permissions = array( 'global' => AccessControl::NO_ACCESS_RESTRICTION ); + private $access_control; function __construct(AccessControl $access_control) { $this->access_control = $access_control; diff --git a/lib/Router/Router.php b/lib/Router/Router.php index 7b5e041a17..99d123faea 100644 --- a/lib/Router/Router.php +++ b/lib/Router/Router.php @@ -13,6 +13,8 @@ class Router { public $endpoint; public $action; public $data; + public $endpoint_action; + public $access_control; /** @var ContainerInterface */ private $container; const NAME = 'mailpoet_router'; diff --git a/lib/Segments/SubscribersFinder.php b/lib/Segments/SubscribersFinder.php index 2ffce4bd0d..3c9f51250f 100644 --- a/lib/Segments/SubscribersFinder.php +++ b/lib/Segments/SubscribersFinder.php @@ -14,7 +14,7 @@ class SubscribersFinder { function findSubscribersInSegments($subscribers_to_process_ids, $newsletter_segments_ids) { $result = array(); foreach($newsletter_segments_ids as $segment_id) { - $segment = Segment::find_one($segment_id); + $segment = Segment::findOne($segment_id); $result = array_merge($result, $this->findSubscribersInSegment($segment, $subscribers_to_process_ids)); } return $this->unique($result); diff --git a/lib/Segments/WP.php b/lib/Segments/WP.php index 0ccb4bd4d8..872d6187c4 100644 --- a/lib/Segments/WP.php +++ b/lib/Segments/WP.php @@ -111,11 +111,11 @@ class WP { private static function updateSubscribersEmails() { global $wpdb; - Subscriber::raw_execute('SELECT NOW();'); - $start_time = Subscriber::get_last_statement()->fetch(\PDO::FETCH_COLUMN); + Subscriber::rawExecute('SELECT NOW();'); + $start_time = Subscriber::getLastStatement()->fetch(\PDO::FETCH_COLUMN); $subscribers_table = Subscriber::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' UPDATE IGNORE %1$s INNER JOIN %2$s as wu ON %1$s.wp_user_id = wu.id SET %1$s.email = wu.user_email; @@ -137,7 +137,7 @@ class WP { WHERE mps.wp_user_id IS NULL AND %2$s.user_email != "" ', $subscribers_table, $wpdb->users))->findArray(); - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' INSERT IGNORE INTO %1$s(wp_user_id, email, status, created_at, source) SELECT wu.id, wu.user_email, "subscribed", CURRENT_TIMESTAMP(), "%3$s" FROM %2$s wu LEFT JOIN %1$s mps ON wu.id = mps.wp_user_id @@ -151,7 +151,7 @@ class WP { private static function updateFirstNames() { global $wpdb; $subscribers_table = Subscriber::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' UPDATE %1$s JOIN %2$s as wpum ON %1$s.wp_user_id = wpum.user_id AND wpum.meta_key = "first_name" SET %1$s.first_name = wpum.meta_value @@ -164,7 +164,7 @@ class WP { private static function updateLastNames() { global $wpdb; $subscribers_table = Subscriber::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' UPDATE %1$s JOIN %2$s as wpum ON %1$s.wp_user_id = wpum.user_id AND wpum.meta_key = "last_name" SET %1$s.last_name = wpum.meta_value @@ -177,7 +177,7 @@ class WP { private static function updateFirstNameIfMissing() { global $wpdb; $subscribers_table = Subscriber::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' UPDATE %1$s JOIN %2$s wu ON %1$s.wp_user_id = wu.id SET %1$s.first_name = wu.display_name @@ -190,7 +190,7 @@ class WP { $wp_segment = Segment::getWPSegment(); $subscribers_table = Subscriber::$_table; $wp_mailpoet_subscriber_segment_table = SubscriberSegment::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' INSERT IGNORE INTO %s(subscriber_id, segment_id, created_at) SELECT mps.id, "%s", CURRENT_TIMESTAMP() FROM %s mps WHERE mps.wp_user_id > 0 @@ -199,7 +199,7 @@ class WP { private static function removeFromTrash() { $subscribers_table = Subscriber::$_table; - Subscriber::raw_execute(sprintf(' + Subscriber::rawExecute(sprintf(' UPDATE %1$s SET %1$s.deleted_at = NULL WHERE %1$s.wp_user_id IS NOT NULL diff --git a/lib/Subscribers/ImportExport/Import/Import.php b/lib/Subscribers/ImportExport/Import/Import.php index c531d894af..27ebbdeec0 100644 --- a/lib/Subscribers/ImportExport/Import/Import.php +++ b/lib/Subscribers/ImportExport/Import/Import.php @@ -194,6 +194,7 @@ class Import { } function transformSubscribersData($subscribers, $columns) { + $transformed_subscribers = []; foreach($columns as $column => $data) { $transformed_subscribers[$column] = array_column($subscribers, $data['index']); } @@ -227,6 +228,7 @@ class Import { $wp_users = array_filter(array_column($temp_existing_subscribers, 'wp_user_id')); // create a new two-dimensional associative array with existing subscribers ($existing_subscribers) // and reduce $subscribers_data to only new subscribers by removing existing subscribers + $existing_subscribers = []; $subscribers_emails = array_flip($subscribers_data['email']); foreach($temp_existing_subscribers as $temp_existing_subscriber) { $existing_subscriber_key = $subscribers_emails[$temp_existing_subscriber['email']]; diff --git a/lib/Subscribers/ImportExport/Import/MailChimp.php b/lib/Subscribers/ImportExport/Import/MailChimp.php index d214bbd4d9..b6a96ba9f9 100644 --- a/lib/Subscribers/ImportExport/Import/MailChimp.php +++ b/lib/Subscribers/ImportExport/Import/MailChimp.php @@ -7,7 +7,8 @@ class MailChimp { public $api_key; public $max_post_size; public $data_center; - public $export_url; + private $export_url; + private $lists_url; const API_KEY_REGEX = '/[a-zA-Z0-9]{32}-[a-zA-Z0-9]{2,4}$/'; function __construct($api_key) { @@ -44,6 +45,7 @@ class MailChimp { return $this->throwException('API'); } + $lists = []; foreach($response->data as $list) { $lists[] = array( 'id' => $list->id, @@ -64,6 +66,8 @@ class MailChimp { } $bytes_fetched = 0; + $subscribers = []; + $header = []; foreach($lists as $list) { $url = sprintf($this->export_url, $this->data_center, $this->api_key, $list); $connection = @fopen($url, 'r'); @@ -71,7 +75,6 @@ class MailChimp { return $this->throwException('connection'); } $i = 0; - $header = array(); while(!feof($connection)) { $buffer = fgets($connection, 4096); if(trim($buffer) !== '') { @@ -123,6 +126,7 @@ class MailChimp { } function throwException($error) { + $errorMessage = __('Unknown MailChimp error.', 'mailpoet'); switch($error) { case 'API': $errorMessage = __('Invalid API Key.', 'mailpoet'); @@ -145,4 +149,4 @@ class MailChimp { } throw new \Exception($errorMessage); } -} \ No newline at end of file +} diff --git a/lib/Tasks/Sending.php b/lib/Tasks/Sending.php index 4913c8f82a..b9a69cf50c 100644 --- a/lib/Tasks/Sending.php +++ b/lib/Tasks/Sending.php @@ -230,7 +230,7 @@ class Sending { static function getScheduledQueues($amount = self::RESULT_BATCH_SIZE) { $wp = new WPFunctions(); - $tasks = ScheduledTask::table_alias('tasks') + $tasks = ScheduledTask::tableAlias('tasks') ->select('tasks.*') ->join(SendingQueue::$_table, 'tasks.id = queues.task_id', 'queues') ->whereNull('tasks.deleted_at') diff --git a/lib/Util/Sudzy/ValidModel.php b/lib/Util/Sudzy/ValidModel.php index c8e69d365c..4d7533319a 100644 --- a/lib/Util/Sudzy/ValidModel.php +++ b/lib/Util/Sudzy/ValidModel.php @@ -3,6 +3,9 @@ namespace Sudzy; if(!defined('ABSPATH')) exit; +/** + * @method static ORMWrapper|bool create($data=null) + */ abstract class ValidModel extends \Model { protected $_validator = null; // Reference to Sudzy validator object protected $_validations = array(); // Array of validations diff --git a/lib/WP/Notice.php b/lib/WP/Notice.php index a53f699fcf..9a288df38c 100644 --- a/lib/WP/Notice.php +++ b/lib/WP/Notice.php @@ -10,6 +10,8 @@ class Notice { private $type; private $message; + private $classes; + private $data_notice_name; function __construct($type, $message, $classes = '', $data_notice_name = '') { $this->type = $type; diff --git a/tasks/phpstan/phpstan.neon b/tasks/phpstan/phpstan.neon index 545e0dd757..4369066f6b 100644 --- a/tasks/phpstan/phpstan.neon +++ b/tasks/phpstan/phpstan.neon @@ -2,8 +2,6 @@ parameters: tmpDir: ../../temp/phpstan bootstrap: bootstrap.php ignoreErrors: - - '#Access to an undefined property#' # current code suffers from this, it should be fixed & this line removed - - '#Static call to instance method MailPoet\\Models\\Model::#' - - '#Access to an undefined static property MailPoet\\Models\\Model::#' - '#Function members_register_.+ not found#' - '#MailPoet\\Premium\\DI\\ContainerConfigurator not found#' # this class is not available when premium is not active + reportUnmatchedIgnoredErrors: false diff --git a/tests/integration/Router/Endpoints/ViewInBrowserTest.php b/tests/integration/Router/Endpoints/ViewInBrowserTest.php index 9528598467..44977169ee 100644 --- a/tests/integration/Router/Endpoints/ViewInBrowserTest.php +++ b/tests/integration/Router/Endpoints/ViewInBrowserTest.php @@ -147,12 +147,12 @@ class ViewInBrowserTest extends \MailPoetTest { $wp_user = wp_set_current_user(0); // when WP user does not have 'manage options' permission, false should be returned $wp_user->remove_role('administrator'); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); expect($this->view_in_browser->_validateBrowserPreviewData($data))->false(); // when WP has 'manage options' permission, data should be returned $wp_user->add_role('administrator'); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); expect($view_in_browser->_validateBrowserPreviewData($data))->equals($data); } @@ -168,7 +168,7 @@ class ViewInBrowserTest extends \MailPoetTest { ); $data->preview = true; wp_set_current_user(1); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); $result = $view_in_browser->_validateBrowserPreviewData($data); expect($result->subscriber->id)->equals(1); }