MailPoet Newsletters (New) - Version 3.40.1

Version Description

  • 2019-11-25 =
  • Improved: minor changes and fixes.
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (New)
Version 3.40.1
Comparing to
See all releases

Code changes from version 3.40.0 to 3.40.1

Files changed (96) hide show
  1. generated/FreeCachedContainer.php +233 -5
  2. lang/mailpoet-ar.mo +0 -0
  3. lang/mailpoet-bg_BG.mo +0 -0
  4. lang/mailpoet-ca.mo +0 -0
  5. lang/mailpoet-cs_CZ.mo +0 -0
  6. lang/mailpoet-da_DK.mo +0 -0
  7. lang/mailpoet-de_DE-formal.mo +0 -0
  8. lang/mailpoet-de_DE.mo +0 -0
  9. lang/mailpoet-el.mo +0 -0
  10. lang/mailpoet-en_GB.mo +0 -0
  11. lang/mailpoet-es_ES.mo +0 -0
  12. lang/mailpoet-es_MX.mo +0 -0
  13. lang/mailpoet-fa_IR.mo +0 -0
  14. lang/mailpoet-fr_CA.mo +0 -0
  15. lang/mailpoet-fr_FR.mo +0 -0
  16. lang/mailpoet-he_IL.mo +0 -0
  17. lang/mailpoet-hu_HU.mo +0 -0
  18. lang/mailpoet-it_IT.mo +0 -0
  19. lang/mailpoet-ja.mo +0 -0
  20. lang/mailpoet-nb_NO.mo +0 -0
  21. lang/mailpoet-nl_NL.mo +0 -0
  22. lang/mailpoet-pl_PL.mo +0 -0
  23. lang/mailpoet-pt_BR.mo +0 -0
  24. lang/mailpoet-pt_PT.mo +0 -0
  25. lang/mailpoet-ro_RO.mo +0 -0
  26. lang/mailpoet-ru_RU.mo +0 -0
  27. lang/mailpoet-sq.mo +0 -0
  28. lang/mailpoet-sr_RS.mo +0 -0
  29. lang/mailpoet-sv_SE.mo +0 -0
  30. lang/mailpoet-tr_TR.mo +0 -0
  31. lang/mailpoet-vi.mo +0 -0
  32. lang/mailpoet-zh_CN.mo +0 -0
  33. lang/mailpoet.pot +25 -21
  34. lib/API/JSON/v1/ImportExport.php +3 -3
  35. lib/API/JSON/v1/Newsletters.php +2 -1
  36. lib/API/JSON/v1/SendingTaskSubscribers.php +11 -1
  37. lib/API/JSON/v1/Settings.php +3 -3
  38. lib/AdminPages/Pages/Settings.php +1 -1
  39. lib/Analytics/Reporter.php +1 -1
  40. lib/Config/DeactivationSurvey.php +2 -2
  41. lib/Config/MP2Migrator.php +4 -4
  42. lib/Cron/CronTrigger.php +26 -13
  43. lib/Cron/CronWorkerScheduler.php +44 -0
  44. lib/Cron/Daemon.php +17 -17
  45. lib/Cron/DaemonHttpRunner.php +8 -5
  46. lib/Cron/Triggers/MailPoet.php +10 -5
  47. lib/Cron/Triggers/WordPress.php +69 -49
  48. lib/Cron/Workers/AuthorizedSendingEmailsCheck.php +3 -3
  49. lib/Cron/Workers/Beamer.php +4 -4
  50. lib/Cron/Workers/Bounce.php +9 -10
  51. lib/Cron/Workers/ExportFilesCleanup.php +4 -1
  52. lib/Cron/Workers/InactiveSubscribers.php +8 -9
  53. lib/Cron/Workers/KeyCheck/KeyCheckWorker.php +1 -1
  54. lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php +2 -2
  55. lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php +2 -2
  56. lib/Cron/Workers/Scheduler.php +9 -10
  57. lib/Cron/Workers/SendingQueue/Migration.php +20 -24
  58. lib/Cron/Workers/SendingQueue/SendingQueue.php +20 -16
  59. lib/Cron/Workers/SimpleWorker.php +49 -78
  60. lib/Cron/Workers/StatsNotifications/AutomatedEmails.php +4 -9
  61. lib/Cron/Workers/StatsNotifications/Worker.php +5 -9
  62. lib/Cron/Workers/SubscriberLinkTokens.php +3 -3
  63. lib/Cron/Workers/UnsubscribeTokens.php +4 -4
  64. lib/Cron/Workers/WooCommercePastOrders.php +6 -7
  65. lib/Cron/Workers/WooCommerceSync.php +3 -7
  66. lib/Cron/Workers/WorkersFactory.php +39 -179
  67. lib/DI/ContainerConfigurator.php +20 -0
  68. lib/Doctrine/EntityTraits/AutoincrementedIdTrait.php +1 -1
  69. lib/Models/Model.php +6 -2
  70. lib/Models/Newsletter.php +2 -2
  71. lib/Models/ScheduledTask.php +40 -0
  72. lib/Models/StatisticsClicks.php +1 -1
  73. lib/Models/StatisticsWooCommercePurchases.php +2 -2
  74. lib/Newsletter/Scheduler/PostNotificationScheduler.php +10 -5
  75. lib/Newsletter/Shortcodes/Categories/Subscriber.php +4 -2
  76. lib/Router/Endpoints/Track.php +1 -1
  77. lib/Router/Endpoints/ViewInBrowser.php +1 -1
  78. lib/Services/Bridge.php +28 -9
  79. lib/Settings/UserFlagsController.php +6 -2
  80. lib/Statistics/GATracking.php +1 -1
  81. lib/Statistics/Track/WooCommercePurchases.php +6 -2
  82. lib/Subscribers/ImportExport/Export/DynamicSubscribersGetter.php +5 -1
  83. lib/Subscribers/ImportExport/Import/Import.php +3 -0
  84. lib/Tasks/Sending.php +4 -3
  85. lib/Tasks/State.php +3 -2
  86. lib/Util/Helpers.php +3 -0
  87. lib/Util/Security.php +9 -1
  88. lib/Util/Sudzy/ValidModel.php +1 -1
  89. lib/Util/pQuery/pQuery.php +6 -0
  90. lib/WP/Functions.php +8 -4
  91. mailpoet.php +2 -2
  92. readme.txt +4 -1
  93. vendor-prefixed/autoload.php +1 -1
  94. vendor/autoload.php +1 -1
  95. vendor/composer/autoload_real.php +7 -7
  96. vendor/composer/autoload_static.php +5 -5
generated/FreeCachedContainer.php CHANGED
@@ -93,13 +93,32 @@ class FreeCachedContainer extends Container
93
  'mailpoet\\config\\shortcodes' => 'MailPoet\\Config\\Shortcodes',
94
  'mailpoet\\cron\\cronhelper' => 'MailPoet\\Cron\\CronHelper',
95
  'mailpoet\\cron\\crontrigger' => 'MailPoet\\Cron\\CronTrigger',
 
96
  'mailpoet\\cron\\daemon' => 'MailPoet\\Cron\\Daemon',
97
  'mailpoet\\cron\\daemonhttprunner' => 'MailPoet\\Cron\\DaemonHttpRunner',
98
  'mailpoet\\cron\\supervisor' => 'MailPoet\\Cron\\Supervisor',
 
 
 
 
 
 
 
 
 
 
 
99
  'mailpoet\\cron\\workers\\sendingqueue\\sendingerrorhandler' => 'MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler',
 
 
100
  'mailpoet\\cron\\workers\\statsnotifications\\newsletterlinkrepository' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository',
101
  'mailpoet\\cron\\workers\\statsnotifications\\scheduler' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler',
102
  'mailpoet\\cron\\workers\\statsnotifications\\statsnotificationsrepository' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository',
 
 
 
 
 
103
  'mailpoet\\cron\\workers\\workersfactory' => 'MailPoet\\Cron\\Workers\\WorkersFactory',
104
  'mailpoet\\customfields\\apidatasanitizer' => 'MailPoet\\CustomFields\\ApiDataSanitizer',
105
  'mailpoet\\di\\containerwrapper' => 'MailPoet\\DI\\ContainerWrapper',
@@ -252,13 +271,32 @@ class FreeCachedContainer extends Container
252
  'MailPoet\\Config\\Shortcodes' => 'getShortcodesService',
253
  'MailPoet\\Cron\\CronHelper' => 'getCronHelperService',
254
  'MailPoet\\Cron\\CronTrigger' => 'getCronTriggerService',
 
255
  'MailPoet\\Cron\\Daemon' => 'getDaemonService',
256
  'MailPoet\\Cron\\DaemonHttpRunner' => 'getDaemonHttpRunnerService',
257
  'MailPoet\\Cron\\Supervisor' => 'getSupervisorService',
 
 
 
 
 
 
 
 
 
 
 
258
  'MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler' => 'getSendingErrorHandlerService',
 
 
259
  'MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository' => 'getNewsletterLinkRepositoryService',
260
- 'MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler' => 'getSchedulerService',
261
  'MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository' => 'getStatsNotificationsRepositoryService',
 
 
 
 
 
262
  'MailPoet\\Cron\\Workers\\WorkersFactory' => 'getWorkersFactoryService',
263
  'MailPoet\\CustomFields\\ApiDataSanitizer' => 'getApiDataSanitizerService',
264
  'MailPoet\\DI\\ContainerWrapper' => 'getContainerWrapperService',
@@ -1057,7 +1095,17 @@ class FreeCachedContainer extends Container
1057
  */
1058
  protected function getCronTriggerService()
1059
  {
1060
- return $this->services['MailPoet\\Cron\\CronTrigger'] = new \MailPoet\Cron\CronTrigger(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
 
 
 
 
 
 
 
 
 
 
1061
  }
1062
 
1063
  /**
@@ -1077,7 +1125,7 @@ class FreeCachedContainer extends Container
1077
  */
1078
  protected function getDaemonHttpRunnerService()
1079
  {
1080
- return $this->services['MailPoet\\Cron\\DaemonHttpRunner'] = new \MailPoet\Cron\DaemonHttpRunner(${($_ = isset($this->services['MailPoet\\Cron\\Daemon']) ? $this->services['MailPoet\\Cron\\Daemon'] : $this->getDaemonService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1081
  }
1082
 
1083
  /**
@@ -1090,6 +1138,116 @@ class FreeCachedContainer extends Container
1090
  return $this->services['MailPoet\\Cron\\Supervisor'] = new \MailPoet\Cron\Supervisor(${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'});
1091
  }
1092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1093
  /**
1094
  * Gets the public 'MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler' shared autowired service.
1095
  *
@@ -1100,6 +1258,76 @@ class FreeCachedContainer extends Container
1100
  return $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] = new \MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler();
1101
  }
1102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1103
  /**
1104
  * Gets the public 'MailPoet\Cron\Workers\WorkersFactory' shared autowired service.
1105
  *
@@ -1107,7 +1335,7 @@ class FreeCachedContainer extends Container
1107
  */
1108
  protected function getWorkersFactoryService()
1109
  {
1110
- return $this->services['MailPoet\\Cron\\Workers\\WorkersFactory'] = new \MailPoet\Cron\Workers\WorkersFactory(${($_ = isset($this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler']) ? $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] : ($this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] = new \MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler'] : $this->getSchedulerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Mailer\\Mailer']) ? $this->services['MailPoet\\Mailer\\Mailer'] : $this->getMailer2Service()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Config\\Renderer']) ? $this->services['MailPoet\\Config\\Renderer'] : $this->getRendererService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Segments\\WooCommerce']) ? $this->services['MailPoet\\Segments\\WooCommerce'] : $this->getWooCommerceService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Subscribers\\InactiveSubscribersController']) ? $this->services['MailPoet\\Subscribers\\InactiveSubscribersController'] : $this->getInactiveSubscribersControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\WooCommerce\\Helper']) ? $this->services['MailPoet\\WooCommerce\\Helper'] : ($this->services['MailPoet\\WooCommerce\\Helper'] = new \MailPoet\WooCommerce\Helper())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Statistics\\Track\\WooCommercePurchases']) ? $this->services['MailPoet\\Statistics\\Track\\WooCommercePurchases'] : $this->getWooCommercePurchasesService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Services\\AuthorizedEmailsController']) ? $this->services['MailPoet\\Services\\AuthorizedEmailsController'] : $this->getAuthorizedEmailsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Segments\\SubscribersFinder']) ? $this->services['MailPoet\\Segments\\SubscribersFinder'] : $this->getSubscribersFinderService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Mailer\\MetaInfo']) ? $this->services['MailPoet\\Mailer\\MetaInfo'] : ($this->services['MailPoet\\Mailer\\MetaInfo'] = new \MailPoet\Mailer\MetaInfo())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Logging\\LoggerFactory']) ? $this->services['MailPoet\\Logging\\LoggerFactory'] : $this->getLoggerFactoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository'] : $this->getStatsNotificationsRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\NewslettersRepository']) ? $this->services['MailPoet\\Newsletter\\NewslettersRepository'] : $this->getNewslettersRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository'] : $this->getNewsletterLinkRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository']) ? $this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository'] : $this->getNewsletterStatisticsRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager']) ? $this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager'] : $this->getEntityManagerService()) && false ?: '_'});
1111
  }
1112
 
1113
  /**
@@ -1567,7 +1795,7 @@ class FreeCachedContainer extends Container
1567
  *
1568
  * @return \MailPoet\Cron\Workers\StatsNotifications\Scheduler
1569
  */
1570
- protected function getSchedulerService()
1571
  {
1572
  return $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler'] = new \MailPoet\Cron\Workers\StatsNotifications\Scheduler(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager']) ? $this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager'] : $this->getEntityManagerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository'] : $this->getStatsNotificationsRepositoryService()) && false ?: '_'});
1573
  }
93
  'mailpoet\\config\\shortcodes' => 'MailPoet\\Config\\Shortcodes',
94
  'mailpoet\\cron\\cronhelper' => 'MailPoet\\Cron\\CronHelper',
95
  'mailpoet\\cron\\crontrigger' => 'MailPoet\\Cron\\CronTrigger',
96
+ 'mailpoet\\cron\\cronworkerscheduler' => 'MailPoet\\Cron\\CronWorkerScheduler',
97
  'mailpoet\\cron\\daemon' => 'MailPoet\\Cron\\Daemon',
98
  'mailpoet\\cron\\daemonhttprunner' => 'MailPoet\\Cron\\DaemonHttpRunner',
99
  'mailpoet\\cron\\supervisor' => 'MailPoet\\Cron\\Supervisor',
100
+ 'mailpoet\\cron\\triggers\\mailpoet' => 'MailPoet\\Cron\\Triggers\\MailPoet',
101
+ 'mailpoet\\cron\\triggers\\wordpress' => 'MailPoet\\Cron\\Triggers\\WordPress',
102
+ 'mailpoet\\cron\\workers\\authorizedsendingemailscheck' => 'MailPoet\\Cron\\Workers\\AuthorizedSendingEmailsCheck',
103
+ 'mailpoet\\cron\\workers\\beamer' => 'MailPoet\\Cron\\Workers\\Beamer',
104
+ 'mailpoet\\cron\\workers\\bounce' => 'MailPoet\\Cron\\Workers\\Bounce',
105
+ 'mailpoet\\cron\\workers\\exportfilescleanup' => 'MailPoet\\Cron\\Workers\\ExportFilesCleanup',
106
+ 'mailpoet\\cron\\workers\\inactivesubscribers' => 'MailPoet\\Cron\\Workers\\InactiveSubscribers',
107
+ 'mailpoet\\cron\\workers\\keycheck\\premiumkeycheck' => 'MailPoet\\Cron\\Workers\\KeyCheck\\PremiumKeyCheck',
108
+ 'mailpoet\\cron\\workers\\keycheck\\sendingservicekeycheck' => 'MailPoet\\Cron\\Workers\\KeyCheck\\SendingServiceKeyCheck',
109
+ 'mailpoet\\cron\\workers\\scheduler' => 'MailPoet\\Cron\\Workers\\Scheduler',
110
+ 'mailpoet\\cron\\workers\\sendingqueue\\migration' => 'MailPoet\\Cron\\Workers\\SendingQueue\\Migration',
111
  'mailpoet\\cron\\workers\\sendingqueue\\sendingerrorhandler' => 'MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler',
112
+ 'mailpoet\\cron\\workers\\sendingqueue\\sendingqueue' => 'MailPoet\\Cron\\Workers\\SendingQueue\\SendingQueue',
113
+ 'mailpoet\\cron\\workers\\statsnotifications\\automatedemails' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\AutomatedEmails',
114
  'mailpoet\\cron\\workers\\statsnotifications\\newsletterlinkrepository' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository',
115
  'mailpoet\\cron\\workers\\statsnotifications\\scheduler' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler',
116
  'mailpoet\\cron\\workers\\statsnotifications\\statsnotificationsrepository' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository',
117
+ 'mailpoet\\cron\\workers\\statsnotifications\\worker' => 'MailPoet\\Cron\\Workers\\StatsNotifications\\Worker',
118
+ 'mailpoet\\cron\\workers\\subscriberlinktokens' => 'MailPoet\\Cron\\Workers\\SubscriberLinkTokens',
119
+ 'mailpoet\\cron\\workers\\unsubscribetokens' => 'MailPoet\\Cron\\Workers\\UnsubscribeTokens',
120
+ 'mailpoet\\cron\\workers\\woocommercepastorders' => 'MailPoet\\Cron\\Workers\\WooCommercePastOrders',
121
+ 'mailpoet\\cron\\workers\\woocommercesync' => 'MailPoet\\Cron\\Workers\\WooCommerceSync',
122
  'mailpoet\\cron\\workers\\workersfactory' => 'MailPoet\\Cron\\Workers\\WorkersFactory',
123
  'mailpoet\\customfields\\apidatasanitizer' => 'MailPoet\\CustomFields\\ApiDataSanitizer',
124
  'mailpoet\\di\\containerwrapper' => 'MailPoet\\DI\\ContainerWrapper',
271
  'MailPoet\\Config\\Shortcodes' => 'getShortcodesService',
272
  'MailPoet\\Cron\\CronHelper' => 'getCronHelperService',
273
  'MailPoet\\Cron\\CronTrigger' => 'getCronTriggerService',
274
+ 'MailPoet\\Cron\\CronWorkerScheduler' => 'getCronWorkerSchedulerService',
275
  'MailPoet\\Cron\\Daemon' => 'getDaemonService',
276
  'MailPoet\\Cron\\DaemonHttpRunner' => 'getDaemonHttpRunnerService',
277
  'MailPoet\\Cron\\Supervisor' => 'getSupervisorService',
278
+ 'MailPoet\\Cron\\Triggers\\MailPoet' => 'getMailPoetService',
279
+ 'MailPoet\\Cron\\Triggers\\WordPress' => 'getWordPressService',
280
+ 'MailPoet\\Cron\\Workers\\AuthorizedSendingEmailsCheck' => 'getAuthorizedSendingEmailsCheckService',
281
+ 'MailPoet\\Cron\\Workers\\Beamer' => 'getBeamerService',
282
+ 'MailPoet\\Cron\\Workers\\Bounce' => 'getBounceService',
283
+ 'MailPoet\\Cron\\Workers\\ExportFilesCleanup' => 'getExportFilesCleanupService',
284
+ 'MailPoet\\Cron\\Workers\\InactiveSubscribers' => 'getInactiveSubscribersService',
285
+ 'MailPoet\\Cron\\Workers\\KeyCheck\\PremiumKeyCheck' => 'getPremiumKeyCheckService',
286
+ 'MailPoet\\Cron\\Workers\\KeyCheck\\SendingServiceKeyCheck' => 'getSendingServiceKeyCheckService',
287
+ 'MailPoet\\Cron\\Workers\\Scheduler' => 'getSchedulerService',
288
+ 'MailPoet\\Cron\\Workers\\SendingQueue\\Migration' => 'getMigrationService',
289
  'MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler' => 'getSendingErrorHandlerService',
290
+ 'MailPoet\\Cron\\Workers\\SendingQueue\\SendingQueue' => 'getSendingQueue2Service',
291
+ 'MailPoet\\Cron\\Workers\\StatsNotifications\\AutomatedEmails' => 'getAutomatedEmailsService',
292
  'MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository' => 'getNewsletterLinkRepositoryService',
293
+ 'MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler' => 'getScheduler2Service',
294
  'MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository' => 'getStatsNotificationsRepositoryService',
295
+ 'MailPoet\\Cron\\Workers\\StatsNotifications\\Worker' => 'getWorkerService',
296
+ 'MailPoet\\Cron\\Workers\\SubscriberLinkTokens' => 'getSubscriberLinkTokensService',
297
+ 'MailPoet\\Cron\\Workers\\UnsubscribeTokens' => 'getUnsubscribeTokensService',
298
+ 'MailPoet\\Cron\\Workers\\WooCommercePastOrders' => 'getWooCommercePastOrdersService',
299
+ 'MailPoet\\Cron\\Workers\\WooCommerceSync' => 'getWooCommerceSyncService',
300
  'MailPoet\\Cron\\Workers\\WorkersFactory' => 'getWorkersFactoryService',
301
  'MailPoet\\CustomFields\\ApiDataSanitizer' => 'getApiDataSanitizerService',
302
  'MailPoet\\DI\\ContainerWrapper' => 'getContainerWrapperService',
1095
  */
1096
  protected function getCronTriggerService()
1097
  {
1098
+ return $this->services['MailPoet\\Cron\\CronTrigger'] = new \MailPoet\Cron\CronTrigger(${($_ = isset($this->services['MailPoet\\Cron\\Triggers\\MailPoet']) ? $this->services['MailPoet\\Cron\\Triggers\\MailPoet'] : $this->getMailPoetService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Triggers\\WordPress']) ? $this->services['MailPoet\\Cron\\Triggers\\WordPress'] : $this->getWordPressService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1099
+ }
1100
+
1101
+ /**
1102
+ * Gets the public 'MailPoet\Cron\CronWorkerScheduler' shared autowired service.
1103
+ *
1104
+ * @return \MailPoet\Cron\CronWorkerScheduler
1105
+ */
1106
+ protected function getCronWorkerSchedulerService()
1107
+ {
1108
+ return $this->services['MailPoet\\Cron\\CronWorkerScheduler'] = new \MailPoet\Cron\CronWorkerScheduler(${($_ = isset($this->services['MailPoet\\WP\\Functions']) ? $this->services['MailPoet\\WP\\Functions'] : ($this->services['MailPoet\\WP\\Functions'] = new \MailPoet\WP\Functions())) && false ?: '_'});
1109
  }
1110
 
1111
  /**
1125
  */
1126
  protected function getDaemonHttpRunnerService()
1127
  {
1128
+ return $this->services['MailPoet\\Cron\\DaemonHttpRunner'] = new \MailPoet\Cron\DaemonHttpRunner(${($_ = isset($this->services['MailPoet\\Cron\\Daemon']) ? $this->services['MailPoet\\Cron\\Daemon'] : $this->getDaemonService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Triggers\\WordPress']) ? $this->services['MailPoet\\Cron\\Triggers\\WordPress'] : $this->getWordPressService()) && false ?: '_'});
1129
  }
1130
 
1131
  /**
1138
  return $this->services['MailPoet\\Cron\\Supervisor'] = new \MailPoet\Cron\Supervisor(${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'});
1139
  }
1140
 
1141
+ /**
1142
+ * Gets the public 'MailPoet\Cron\Triggers\MailPoet' shared autowired service.
1143
+ *
1144
+ * @return \MailPoet\Cron\Triggers\MailPoet
1145
+ */
1146
+ protected function getMailPoetService()
1147
+ {
1148
+ return $this->services['MailPoet\\Cron\\Triggers\\MailPoet'] = new \MailPoet\Cron\Triggers\MailPoet(${($_ = isset($this->services['MailPoet\\Cron\\Supervisor']) ? $this->services['MailPoet\\Cron\\Supervisor'] : $this->getSupervisorService()) && false ?: '_'});
1149
+ }
1150
+
1151
+ /**
1152
+ * Gets the public 'MailPoet\Cron\Triggers\WordPress' shared autowired service.
1153
+ *
1154
+ * @return \MailPoet\Cron\Triggers\WordPress
1155
+ */
1156
+ protected function getWordPressService()
1157
+ {
1158
+ return $this->services['MailPoet\\Cron\\Triggers\\WordPress'] = new \MailPoet\Cron\Triggers\WordPress(${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Triggers\\MailPoet']) ? $this->services['MailPoet\\Cron\\Triggers\\MailPoet'] : $this->getMailPoetService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\WP\\Functions']) ? $this->services['MailPoet\\WP\\Functions'] : ($this->services['MailPoet\\WP\\Functions'] = new \MailPoet\WP\Functions())) && false ?: '_'});
1159
+ }
1160
+
1161
+ /**
1162
+ * Gets the public 'MailPoet\Cron\Workers\AuthorizedSendingEmailsCheck' shared autowired service.
1163
+ *
1164
+ * @return \MailPoet\Cron\Workers\AuthorizedSendingEmailsCheck
1165
+ */
1166
+ protected function getAuthorizedSendingEmailsCheckService()
1167
+ {
1168
+ return $this->services['MailPoet\\Cron\\Workers\\AuthorizedSendingEmailsCheck'] = new \MailPoet\Cron\Workers\AuthorizedSendingEmailsCheck(${($_ = isset($this->services['MailPoet\\Services\\AuthorizedEmailsController']) ? $this->services['MailPoet\\Services\\AuthorizedEmailsController'] : $this->getAuthorizedEmailsControllerService()) && false ?: '_'});
1169
+ }
1170
+
1171
+ /**
1172
+ * Gets the public 'MailPoet\Cron\Workers\Beamer' shared autowired service.
1173
+ *
1174
+ * @return \MailPoet\Cron\Workers\Beamer
1175
+ */
1176
+ protected function getBeamerService()
1177
+ {
1178
+ return $this->services['MailPoet\\Cron\\Workers\\Beamer'] = new \MailPoet\Cron\Workers\Beamer(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\WP\\Functions']) ? $this->services['MailPoet\\WP\\Functions'] : ($this->services['MailPoet\\WP\\Functions'] = new \MailPoet\WP\Functions())) && false ?: '_'});
1179
+ }
1180
+
1181
+ /**
1182
+ * Gets the public 'MailPoet\Cron\Workers\Bounce' shared autowired service.
1183
+ *
1184
+ * @return \MailPoet\Cron\Workers\Bounce
1185
+ */
1186
+ protected function getBounceService()
1187
+ {
1188
+ return $this->services['MailPoet\\Cron\\Workers\\Bounce'] = new \MailPoet\Cron\Workers\Bounce(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1189
+ }
1190
+
1191
+ /**
1192
+ * Gets the public 'MailPoet\Cron\Workers\ExportFilesCleanup' shared autowired service.
1193
+ *
1194
+ * @return \MailPoet\Cron\Workers\ExportFilesCleanup
1195
+ */
1196
+ protected function getExportFilesCleanupService()
1197
+ {
1198
+ return $this->services['MailPoet\\Cron\\Workers\\ExportFilesCleanup'] = new \MailPoet\Cron\Workers\ExportFilesCleanup();
1199
+ }
1200
+
1201
+ /**
1202
+ * Gets the public 'MailPoet\Cron\Workers\InactiveSubscribers' shared autowired service.
1203
+ *
1204
+ * @return \MailPoet\Cron\Workers\InactiveSubscribers
1205
+ */
1206
+ protected function getInactiveSubscribersService()
1207
+ {
1208
+ return $this->services['MailPoet\\Cron\\Workers\\InactiveSubscribers'] = new \MailPoet\Cron\Workers\InactiveSubscribers(${($_ = isset($this->services['MailPoet\\Subscribers\\InactiveSubscribersController']) ? $this->services['MailPoet\\Subscribers\\InactiveSubscribersController'] : $this->getInactiveSubscribersControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1209
+ }
1210
+
1211
+ /**
1212
+ * Gets the public 'MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck' shared autowired service.
1213
+ *
1214
+ * @return \MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck
1215
+ */
1216
+ protected function getPremiumKeyCheckService()
1217
+ {
1218
+ return $this->services['MailPoet\\Cron\\Workers\\KeyCheck\\PremiumKeyCheck'] = new \MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1219
+ }
1220
+
1221
+ /**
1222
+ * Gets the public 'MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck' shared autowired service.
1223
+ *
1224
+ * @return \MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck
1225
+ */
1226
+ protected function getSendingServiceKeyCheckService()
1227
+ {
1228
+ return $this->services['MailPoet\\Cron\\Workers\\KeyCheck\\SendingServiceKeyCheck'] = new \MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'});
1229
+ }
1230
+
1231
+ /**
1232
+ * Gets the public 'MailPoet\Cron\Workers\Scheduler' shared autowired service.
1233
+ *
1234
+ * @return \MailPoet\Cron\Workers\Scheduler
1235
+ */
1236
+ protected function getSchedulerService()
1237
+ {
1238
+ return $this->services['MailPoet\\Cron\\Workers\\Scheduler'] = new \MailPoet\Cron\Workers\Scheduler(${($_ = isset($this->services['MailPoet\\Segments\\SubscribersFinder']) ? $this->services['MailPoet\\Segments\\SubscribersFinder'] : $this->getSubscribersFinderService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Logging\\LoggerFactory']) ? $this->services['MailPoet\\Logging\\LoggerFactory'] : $this->getLoggerFactoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'});
1239
+ }
1240
+
1241
+ /**
1242
+ * Gets the public 'MailPoet\Cron\Workers\SendingQueue\Migration' shared autowired service.
1243
+ *
1244
+ * @return \MailPoet\Cron\Workers\SendingQueue\Migration
1245
+ */
1246
+ protected function getMigrationService()
1247
+ {
1248
+ return $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\Migration'] = new \MailPoet\Cron\Workers\SendingQueue\Migration();
1249
+ }
1250
+
1251
  /**
1252
  * Gets the public 'MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler' shared autowired service.
1253
  *
1258
  return $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] = new \MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler();
1259
  }
1260
 
1261
+ /**
1262
+ * Gets the public 'MailPoet\Cron\Workers\SendingQueue\SendingQueue' shared autowired service.
1263
+ *
1264
+ * @return \MailPoet\Cron\Workers\SendingQueue\SendingQueue
1265
+ */
1266
+ protected function getSendingQueue2Service()
1267
+ {
1268
+ return $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingQueue'] = new \MailPoet\Cron\Workers\SendingQueue\SendingQueue(${($_ = isset($this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler']) ? $this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] : ($this->services['MailPoet\\Cron\\Workers\\SendingQueue\\SendingErrorHandler'] = new \MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler'] : $this->getScheduler2Service()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Logging\\LoggerFactory']) ? $this->services['MailPoet\\Logging\\LoggerFactory'] : $this->getLoggerFactoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\NewslettersRepository']) ? $this->services['MailPoet\\Newsletter\\NewslettersRepository'] : $this->getNewslettersRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'});
1269
+ }
1270
+
1271
+ /**
1272
+ * Gets the public 'MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails' shared autowired service.
1273
+ *
1274
+ * @return \MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails
1275
+ */
1276
+ protected function getAutomatedEmailsService()
1277
+ {
1278
+ return $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\AutomatedEmails'] = new \MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails(${($_ = isset($this->services['MailPoet\\Mailer\\Mailer']) ? $this->services['MailPoet\\Mailer\\Mailer'] : $this->getMailer2Service()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Config\\Renderer']) ? $this->services['MailPoet\\Config\\Renderer'] : $this->getRendererService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\NewslettersRepository']) ? $this->services['MailPoet\\Newsletter\\NewslettersRepository'] : $this->getNewslettersRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository']) ? $this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository'] : $this->getNewsletterStatisticsRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Mailer\\MetaInfo']) ? $this->services['MailPoet\\Mailer\\MetaInfo'] : ($this->services['MailPoet\\Mailer\\MetaInfo'] = new \MailPoet\Mailer\MetaInfo())) && false ?: '_'});
1279
+ }
1280
+
1281
+ /**
1282
+ * Gets the public 'MailPoet\Cron\Workers\StatsNotifications\Worker' shared autowired service.
1283
+ *
1284
+ * @return \MailPoet\Cron\Workers\StatsNotifications\Worker
1285
+ */
1286
+ protected function getWorkerService()
1287
+ {
1288
+ return $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Worker'] = new \MailPoet\Cron\Workers\StatsNotifications\Worker(${($_ = isset($this->services['MailPoet\\Mailer\\Mailer']) ? $this->services['MailPoet\\Mailer\\Mailer'] : $this->getMailer2Service()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Config\\Renderer']) ? $this->services['MailPoet\\Config\\Renderer'] : $this->getRendererService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\CronHelper']) ? $this->services['MailPoet\\Cron\\CronHelper'] : $this->getCronHelperService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Mailer\\MetaInfo']) ? $this->services['MailPoet\\Mailer\\MetaInfo'] : ($this->services['MailPoet\\Mailer\\MetaInfo'] = new \MailPoet\Mailer\MetaInfo())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository'] : $this->getStatsNotificationsRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\NewsletterLinkRepository'] : $this->getNewsletterLinkRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository']) ? $this->services['MailPoet\\Newsletter\\Statistics\\NewsletterStatisticsRepository'] : $this->getNewsletterStatisticsRepositoryService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager']) ? $this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager'] : $this->getEntityManagerService()) && false ?: '_'});
1289
+ }
1290
+
1291
+ /**
1292
+ * Gets the public 'MailPoet\Cron\Workers\SubscriberLinkTokens' shared autowired service.
1293
+ *
1294
+ * @return \MailPoet\Cron\Workers\SubscriberLinkTokens
1295
+ */
1296
+ protected function getSubscriberLinkTokensService()
1297
+ {
1298
+ return $this->services['MailPoet\\Cron\\Workers\\SubscriberLinkTokens'] = new \MailPoet\Cron\Workers\SubscriberLinkTokens();
1299
+ }
1300
+
1301
+ /**
1302
+ * Gets the public 'MailPoet\Cron\Workers\UnsubscribeTokens' shared autowired service.
1303
+ *
1304
+ * @return \MailPoet\Cron\Workers\UnsubscribeTokens
1305
+ */
1306
+ protected function getUnsubscribeTokensService()
1307
+ {
1308
+ return $this->services['MailPoet\\Cron\\Workers\\UnsubscribeTokens'] = new \MailPoet\Cron\Workers\UnsubscribeTokens();
1309
+ }
1310
+
1311
+ /**
1312
+ * Gets the public 'MailPoet\Cron\Workers\WooCommercePastOrders' shared autowired service.
1313
+ *
1314
+ * @return \MailPoet\Cron\Workers\WooCommercePastOrders
1315
+ */
1316
+ protected function getWooCommercePastOrdersService()
1317
+ {
1318
+ return $this->services['MailPoet\\Cron\\Workers\\WooCommercePastOrders'] = new \MailPoet\Cron\Workers\WooCommercePastOrders(${($_ = isset($this->services['MailPoet\\WooCommerce\\Helper']) ? $this->services['MailPoet\\WooCommerce\\Helper'] : ($this->services['MailPoet\\WooCommerce\\Helper'] = new \MailPoet\WooCommerce\Helper())) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Statistics\\Track\\WooCommercePurchases']) ? $this->services['MailPoet\\Statistics\\Track\\WooCommercePurchases'] : $this->getWooCommercePurchasesService()) && false ?: '_'});
1319
+ }
1320
+
1321
+ /**
1322
+ * Gets the public 'MailPoet\Cron\Workers\WooCommerceSync' shared autowired service.
1323
+ *
1324
+ * @return \MailPoet\Cron\Workers\WooCommerceSync
1325
+ */
1326
+ protected function getWooCommerceSyncService()
1327
+ {
1328
+ return $this->services['MailPoet\\Cron\\Workers\\WooCommerceSync'] = new \MailPoet\Cron\Workers\WooCommerceSync(${($_ = isset($this->services['MailPoet\\Segments\\WooCommerce']) ? $this->services['MailPoet\\Segments\\WooCommerce'] : $this->getWooCommerceService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\WooCommerce\\Helper']) ? $this->services['MailPoet\\WooCommerce\\Helper'] : ($this->services['MailPoet\\WooCommerce\\Helper'] = new \MailPoet\WooCommerce\Helper())) && false ?: '_'});
1329
+ }
1330
+
1331
  /**
1332
  * Gets the public 'MailPoet\Cron\Workers\WorkersFactory' shared autowired service.
1333
  *
1335
  */
1336
  protected function getWorkersFactoryService()
1337
  {
1338
+ return $this->services['MailPoet\\Cron\\Workers\\WorkersFactory'] = new \MailPoet\Cron\Workers\WorkersFactory(${($_ = isset($this->services['MailPoet\\DI\\ContainerWrapper']) ? $this->services['MailPoet\\DI\\ContainerWrapper'] : $this->getContainerWrapperService()) && false ?: '_'});
1339
  }
1340
 
1341
  /**
1795
  *
1796
  * @return \MailPoet\Cron\Workers\StatsNotifications\Scheduler
1797
  */
1798
+ protected function getScheduler2Service()
1799
  {
1800
  return $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\Scheduler'] = new \MailPoet\Cron\Workers\StatsNotifications\Scheduler(${($_ = isset($this->services['MailPoet\\Settings\\SettingsController']) ? $this->services['MailPoet\\Settings\\SettingsController'] : $this->getSettingsControllerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager']) ? $this->services['MailPoetVendor\\Doctrine\\ORM\\EntityManager'] : $this->getEntityManagerService()) && false ?: '_'}, ${($_ = isset($this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository']) ? $this->services['MailPoet\\Cron\\Workers\\StatsNotifications\\StatsNotificationsRepository'] : $this->getStatsNotificationsRepositoryService()) && false ?: '_'});
1801
  }
lang/mailpoet-ar.mo CHANGED
Binary file
lang/mailpoet-bg_BG.mo CHANGED
Binary file
lang/mailpoet-ca.mo CHANGED
Binary file
lang/mailpoet-cs_CZ.mo CHANGED
Binary file
lang/mailpoet-da_DK.mo CHANGED
Binary file
lang/mailpoet-de_DE-formal.mo CHANGED
Binary file
lang/mailpoet-de_DE.mo CHANGED
Binary file
lang/mailpoet-el.mo CHANGED
Binary file
lang/mailpoet-en_GB.mo CHANGED
Binary file
lang/mailpoet-es_ES.mo CHANGED
Binary file
lang/mailpoet-es_MX.mo CHANGED
Binary file
lang/mailpoet-fa_IR.mo CHANGED
Binary file
lang/mailpoet-fr_CA.mo CHANGED
Binary file
lang/mailpoet-fr_FR.mo CHANGED
Binary file
lang/mailpoet-he_IL.mo CHANGED
Binary file
lang/mailpoet-hu_HU.mo CHANGED
Binary file
lang/mailpoet-it_IT.mo CHANGED
Binary file
lang/mailpoet-ja.mo CHANGED
Binary file
lang/mailpoet-nb_NO.mo CHANGED
Binary file
lang/mailpoet-nl_NL.mo CHANGED
Binary file
lang/mailpoet-pl_PL.mo CHANGED
Binary file
lang/mailpoet-pt_BR.mo CHANGED
Binary file
lang/mailpoet-pt_PT.mo CHANGED
Binary file
lang/mailpoet-ro_RO.mo CHANGED
Binary file
lang/mailpoet-ru_RU.mo CHANGED
Binary file
lang/mailpoet-sq.mo CHANGED
Binary file
lang/mailpoet-sr_RS.mo CHANGED
Binary file
lang/mailpoet-sv_SE.mo CHANGED
Binary file
lang/mailpoet-tr_TR.mo CHANGED
Binary file
lang/mailpoet-vi.mo CHANGED
Binary file
lang/mailpoet-zh_CN.mo CHANGED
Binary file
lang/mailpoet.pot CHANGED
@@ -4,7 +4,7 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
7
- "POT-Creation-Date: 2019-11-18 17:51:50+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -155,12 +155,12 @@ msgstr ""
155
  msgid "Subscribe!"
156
  msgstr ""
157
 
158
- #: lib/API/JSON/v1/Forms.php:281 lib/API/JSON/v1/Newsletters.php:386
159
  #: lib/API/JSON/v1/Segments.php:142
160
  msgid "Copy of %s"
161
  msgstr ""
162
 
163
- #: lib/API/JSON/v1/Mailer.php:61 lib/API/JSON/v1/Newsletters.php:492
164
  msgid "The email could not be sent: %s"
165
  msgstr ""
166
 
@@ -170,22 +170,22 @@ msgid "This template does not exist."
170
  msgstr ""
171
 
172
  #: lib/API/JSON/v1/Newsletters.php:128 lib/API/JSON/v1/Newsletters.php:155
173
- #: lib/API/JSON/v1/Newsletters.php:295 lib/API/JSON/v1/Newsletters.php:343
174
- #: lib/API/JSON/v1/Newsletters.php:362 lib/API/JSON/v1/Newsletters.php:375
175
- #: lib/API/JSON/v1/Newsletters.php:404 lib/API/JSON/v1/Newsletters.php:440
176
- #: lib/API/JSON/v1/Newsletters.php:511
177
  msgid "This email does not exist."
178
  msgstr ""
179
 
180
- #: lib/API/JSON/v1/Newsletters.php:286
181
  msgid "You need to specify a status."
182
  msgstr ""
183
 
184
- #: lib/API/JSON/v1/Newsletters.php:412
185
  msgid "Newsletter data is missing."
186
  msgstr ""
187
 
188
- #: lib/API/JSON/v1/Newsletters.php:448
189
  msgid "Please specify receiver information."
190
  msgstr ""
191
 
@@ -217,10 +217,14 @@ msgstr ""
217
  msgid "This email has not been sent yet."
218
  msgstr ""
219
 
220
- #: lib/API/JSON/v1/SendingTaskSubscribers.php:85
221
  msgid "Failed sending task not found!"
222
  msgstr ""
223
 
 
 
 
 
224
  #: lib/API/JSON/v1/Services.php:52
225
  msgid "SPF check has failed."
226
  msgstr ""
@@ -1534,15 +1538,15 @@ msgstr ""
1534
  msgid "Maximum execution time has been reached."
1535
  msgstr ""
1536
 
1537
- #: lib/Cron/DaemonHttpRunner.php:53
1538
  msgid "Invalid or missing request data."
1539
  msgstr ""
1540
 
1541
- #: lib/Cron/DaemonHttpRunner.php:56
1542
  msgid "Daemon does not exist."
1543
  msgstr ""
1544
 
1545
- #: lib/Cron/Workers/SendingQueue/Migration.php:59
1546
  msgid ""
1547
  "Your sending queue data is being migrated to allow better performance, "
1548
  "sending is paused while the migration is in progress and will resume "
@@ -1559,21 +1563,21 @@ msgid ""
1559
  "please contact us and report this issue."
1560
  msgstr ""
1561
 
1562
- #: lib/Cron/Workers/StatsNotifications/AutomatedEmails.php:108
1563
  #: views/emails/statsNotificationAutomatedEmails.html:27
1564
  msgid "Your monthly stats are in!"
1565
  msgstr ""
1566
 
1567
- #: lib/Cron/Workers/StatsNotifications/Worker.php:152
1568
  #: lib/Newsletter/Shortcodes/ShortcodesHelper.php:83
1569
  msgid "Unsubscribe link"
1570
  msgstr ""
1571
 
1572
- #: lib/Cron/Workers/StatsNotifications/Worker.php:153
1573
  msgid "Manage subscription link"
1574
  msgstr ""
1575
 
1576
- #: lib/Cron/Workers/StatsNotifications/Worker.php:154
1577
  #: lib/Newsletter/Shortcodes/ShortcodesHelper.php:99
1578
  msgid "View in browser link"
1579
  msgstr ""
@@ -1921,7 +1925,7 @@ msgstr ""
1921
  msgid "You’ve been successfully subscribed to our newsletter!"
1922
  msgstr ""
1923
 
1924
- #: lib/Models/Model.php:230
1925
  #: views/subscribers/importExport/import/step_data_manipulation.html:14
1926
  msgid "Another record already exists. Please specify a different \"%1$s\"."
1927
  msgstr ""
@@ -7251,14 +7255,14 @@ msgctxt "Form label"
7251
  msgid "Subscribe!"
7252
  msgstr ""
7253
 
7254
- #: lib/Cron/Workers/StatsNotifications/Worker.php:107
7255
  msgctxt ""
7256
  "title of an automatic email containing statistics (newsletter open rate, "
7257
  "click rate, etc)"
7258
  msgid "Stats for email %s"
7259
  msgstr ""
7260
 
7261
- #: lib/Cron/Workers/StatsNotifications/Worker.php:123
7262
  msgctxt "newsletter open rate, click rate and unsubscribe rate"
7263
  msgid "%1$s%% opens, %2$s%% clicks, %3$s%% unsubscribes in a nutshell."
7264
  msgstr ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
7
+ "POT-Creation-Date: 2019-11-25 16:48:37+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
155
  msgid "Subscribe!"
156
  msgstr ""
157
 
158
+ #: lib/API/JSON/v1/Forms.php:281 lib/API/JSON/v1/Newsletters.php:387
159
  #: lib/API/JSON/v1/Segments.php:142
160
  msgid "Copy of %s"
161
  msgstr ""
162
 
163
+ #: lib/API/JSON/v1/Mailer.php:61 lib/API/JSON/v1/Newsletters.php:493
164
  msgid "The email could not be sent: %s"
165
  msgstr ""
166
 
170
  msgstr ""
171
 
172
  #: lib/API/JSON/v1/Newsletters.php:128 lib/API/JSON/v1/Newsletters.php:155
173
+ #: lib/API/JSON/v1/Newsletters.php:296 lib/API/JSON/v1/Newsletters.php:344
174
+ #: lib/API/JSON/v1/Newsletters.php:363 lib/API/JSON/v1/Newsletters.php:376
175
+ #: lib/API/JSON/v1/Newsletters.php:405 lib/API/JSON/v1/Newsletters.php:441
176
+ #: lib/API/JSON/v1/Newsletters.php:512
177
  msgid "This email does not exist."
178
  msgstr ""
179
 
180
+ #: lib/API/JSON/v1/Newsletters.php:287
181
  msgid "You need to specify a status."
182
  msgstr ""
183
 
184
+ #: lib/API/JSON/v1/Newsletters.php:413
185
  msgid "Newsletter data is missing."
186
  msgstr ""
187
 
188
+ #: lib/API/JSON/v1/Newsletters.php:449
189
  msgid "Please specify receiver information."
190
  msgstr ""
191
 
217
  msgid "This email has not been sent yet."
218
  msgstr ""
219
 
220
+ #: lib/API/JSON/v1/SendingTaskSubscribers.php:90
221
  msgid "Failed sending task not found!"
222
  msgstr ""
223
 
224
+ #: lib/API/JSON/v1/SendingTaskSubscribers.php:96
225
+ msgid "Newsletter not found!"
226
+ msgstr ""
227
+
228
  #: lib/API/JSON/v1/Services.php:52
229
  msgid "SPF check has failed."
230
  msgstr ""
1538
  msgid "Maximum execution time has been reached."
1539
  msgstr ""
1540
 
1541
+ #: lib/Cron/DaemonHttpRunner.php:57
1542
  msgid "Invalid or missing request data."
1543
  msgstr ""
1544
 
1545
+ #: lib/Cron/DaemonHttpRunner.php:60
1546
  msgid "Daemon does not exist."
1547
  msgstr ""
1548
 
1549
+ #: lib/Cron/Workers/SendingQueue/Migration.php:58
1550
  msgid ""
1551
  "Your sending queue data is being migrated to allow better performance, "
1552
  "sending is paused while the migration is in progress and will resume "
1563
  "please contact us and report this issue."
1564
  msgstr ""
1565
 
1566
+ #: lib/Cron/Workers/StatsNotifications/AutomatedEmails.php:103
1567
  #: views/emails/statsNotificationAutomatedEmails.html:27
1568
  msgid "Your monthly stats are in!"
1569
  msgstr ""
1570
 
1571
+ #: lib/Cron/Workers/StatsNotifications/Worker.php:148
1572
  #: lib/Newsletter/Shortcodes/ShortcodesHelper.php:83
1573
  msgid "Unsubscribe link"
1574
  msgstr ""
1575
 
1576
+ #: lib/Cron/Workers/StatsNotifications/Worker.php:149
1577
  msgid "Manage subscription link"
1578
  msgstr ""
1579
 
1580
+ #: lib/Cron/Workers/StatsNotifications/Worker.php:150
1581
  #: lib/Newsletter/Shortcodes/ShortcodesHelper.php:99
1582
  msgid "View in browser link"
1583
  msgstr ""
1925
  msgid "You’ve been successfully subscribed to our newsletter!"
1926
  msgstr ""
1927
 
1928
+ #: lib/Models/Model.php:234
1929
  #: views/subscribers/importExport/import/step_data_manipulation.html:14
1930
  msgid "Another record already exists. Please specify a different \"%1$s\"."
1931
  msgstr ""
7255
  msgid "Subscribe!"
7256
  msgstr ""
7257
 
7258
+ #: lib/Cron/Workers/StatsNotifications/Worker.php:103
7259
  msgctxt ""
7260
  "title of an automatic email containing statistics (newsletter open rate, "
7261
  "click rate, etc)"
7262
  msgid "Stats for email %s"
7263
  msgstr ""
7264
 
7265
+ #: lib/Cron/Workers/StatsNotifications/Worker.php:119
7266
  msgctxt "newsletter open rate, click rate and unsubscribe rate"
7267
  msgid "%1$s%% opens, %2$s%% clicks, %3$s%% unsubscribes in a nutshell."
7268
  msgstr ""
lib/API/JSON/v1/ImportExport.php CHANGED
@@ -88,15 +88,15 @@ class ImportExport extends APIEndpoint {
88
  $task = ScheduledTask::where('type', WooCommerceSync::TASK_TYPE)
89
  ->whereRaw('status = ? OR status IS NULL', [ScheduledTask::STATUS_SCHEDULED])
90
  ->findOne();
91
- if ($task && $task->status === null) {
92
  return $this->successResponse();
93
  }
94
- if (!$task) {
95
  $task = ScheduledTask::create();
96
  $task->type = WooCommerceSync::TASK_TYPE;
97
  $task->status = ScheduledTask::STATUS_SCHEDULED;
98
  }
99
- $task->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
100
  $task->save();
101
  return $this->successResponse();
102
  } catch (\Exception $e) {
88
  $task = ScheduledTask::where('type', WooCommerceSync::TASK_TYPE)
89
  ->whereRaw('status = ? OR status IS NULL', [ScheduledTask::STATUS_SCHEDULED])
90
  ->findOne();
91
+ if (($task instanceof ScheduledTask) && $task->status === null) {
92
  return $this->successResponse();
93
  }
94
+ if (!($task instanceof ScheduledTask)) {
95
  $task = ScheduledTask::create();
96
  $task->type = WooCommerceSync::TASK_TYPE;
97
  $task->status = ScheduledTask::STATUS_SCHEDULED;
98
  }
99
+ $task->scheduled_at = Carbon::createFromTimestamp((int)current_time('timestamp'));
100
  $task->save();
101
  return $this->successResponse();
102
  } catch (\Exception $e) {
lib/API/JSON/v1/Newsletters.php CHANGED
@@ -185,7 +185,8 @@ class Newsletters extends APIEndpoint {
185
 
186
  $old_newsletter = null;
187
  if (isset($data['id'])) {
188
- $old_newsletter = Newsletter::findOne(intval($data['id'])) ?: null;
 
189
  }
190
 
191
  if (!empty($data['body'])) {
185
 
186
  $old_newsletter = null;
187
  if (isset($data['id'])) {
188
+ $fetched = Newsletter::findOne(intval($data['id']));
189
+ $old_newsletter = $fetched instanceof Newsletter ? $fetched : null;
190
  }
191
 
192
  if (!empty($data['body'])) {
lib/API/JSON/v1/SendingTaskSubscribers.php CHANGED
@@ -83,12 +83,22 @@ class SendingTaskSubscribers extends APIEndpoint {
83
  ->findOne();
84
  $task = ScheduledTask::findOne($task_id);
85
  $sending_queue = SendingQueueModel::where('task_id', $task_id)->findOne();
86
- if (!$task || !$task_subscriber || !$sending_queue || $task_subscriber->failed != 1) {
 
 
 
 
 
87
  return $this->errorResponse([
88
  APIError::NOT_FOUND => __('Failed sending task not found!', 'mailpoet'),
89
  ]);
90
  }
91
  $newsletter = Newsletter::findOne($sending_queue->newsletter_id);
 
 
 
 
 
92
 
93
  $task_subscriber->error = '';
94
  $task_subscriber->failed = 0;
83
  ->findOne();
84
  $task = ScheduledTask::findOne($task_id);
85
  $sending_queue = SendingQueueModel::where('task_id', $task_id)->findOne();
86
+ if (
87
+ !($task instanceof ScheduledTask)
88
+ || !($task_subscriber instanceof ScheduledTaskSubscriber)
89
+ || !($sending_queue instanceof SendingQueueModel)
90
+ || $task_subscriber->failed != 1
91
+ ) {
92
  return $this->errorResponse([
93
  APIError::NOT_FOUND => __('Failed sending task not found!', 'mailpoet'),
94
  ]);
95
  }
96
  $newsletter = Newsletter::findOne($sending_queue->newsletter_id);
97
+ if (!($newsletter instanceof Newsletter)) {
98
+ return $this->errorResponse([
99
+ APIError::NOT_FOUND => __('Newsletter not found!', 'mailpoet'),
100
+ ]);
101
+ }
102
 
103
  $task_subscriber->error = '';
104
  $task_subscriber->failed = 0;
lib/API/JSON/v1/Settings.php CHANGED
@@ -107,7 +107,7 @@ class Settings extends APIEndpoint {
107
  $task = ScheduledTask::where('type', WooCommerceSync::TASK_TYPE)
108
  ->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
109
  ->findOne();
110
- if (!$task) {
111
  $task = ScheduledTask::create();
112
  $task->type = WooCommerceSync::TASK_TYPE;
113
  $task->status = ScheduledTask::STATUS_SCHEDULED;
@@ -121,12 +121,12 @@ class Settings extends APIEndpoint {
121
  $task = ScheduledTask::where('type', InactiveSubscribers::TASK_TYPE)
122
  ->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
123
  ->findOne();
124
- if (!$task) {
125
  $task = ScheduledTask::create();
126
  $task->type = InactiveSubscribers::TASK_TYPE;
127
  $task->status = ScheduledTask::STATUS_SCHEDULED;
128
  }
129
- $datetime = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
130
  $task->scheduled_at = $datetime->subMinute();
131
  $task->save();
132
  }
107
  $task = ScheduledTask::where('type', WooCommerceSync::TASK_TYPE)
108
  ->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
109
  ->findOne();
110
+ if (!($task instanceof ScheduledTask)) {
111
  $task = ScheduledTask::create();
112
  $task->type = WooCommerceSync::TASK_TYPE;
113
  $task->status = ScheduledTask::STATUS_SCHEDULED;
121
  $task = ScheduledTask::where('type', InactiveSubscribers::TASK_TYPE)
122
  ->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
123
  ->findOne();
124
+ if (!($task instanceof ScheduledTask)) {
125
  $task = ScheduledTask::create();
126
  $task->type = InactiveSubscribers::TASK_TYPE;
127
  $task->status = ScheduledTask::STATUS_SCHEDULED;
128
  }
129
+ $datetime = Carbon::createFromTimestamp((int)WPFunctions::get()->currentTime('timestamp'));
130
  $task->scheduled_at = $datetime->subMinute();
131
  $task->save();
132
  }
lib/AdminPages/Pages/Settings.php CHANGED
@@ -79,7 +79,7 @@ class Settings {
79
  $data = [
80
  'settings' => $settings,
81
  'segments' => Segment::getSegmentsWithSubscriberCount(),
82
- 'cron_trigger' => CronTrigger::getAvailableMethods(),
83
  'total_subscribers' => Subscriber::getTotalSubscribers(),
84
  'premium_plugin_active' => License::getLicense(),
85
  'premium_key_valid' => !empty($premium_key_valid),
79
  $data = [
80
  'settings' => $settings,
81
  'segments' => Segment::getSegmentsWithSubscriberCount(),
82
+ 'cron_trigger' => CronTrigger::METHODS,
83
  'total_subscribers' => Subscriber::getTotalSubscribers(),
84
  'premium_plugin_active' => License::getLicense(),
85
  'premium_key_valid' => !empty($premium_key_valid),
lib/Analytics/Reporter.php CHANGED
@@ -33,7 +33,7 @@ class Reporter {
33
  global $wpdb, $wp_version, $woocommerce;
34
  $mta = $this->settings->get('mta', []);
35
  $newsletters = Newsletter::getAnalytics();
36
- $isCronTriggerMethodWP = $this->settings->get('cron_trigger.method') === CronTrigger::$available_methods['wordpress'];
37
  $checker = new ServicesChecker();
38
  $bounceAddress = $this->settings->get('bounce.address');
39
  $segments = Segment::getAnalytics();
33
  global $wpdb, $wp_version, $woocommerce;
34
  $mta = $this->settings->get('mta', []);
35
  $newsletters = Newsletter::getAnalytics();
36
+ $isCronTriggerMethodWP = $this->settings->get('cron_trigger.method') === CronTrigger::METHOD_WORDPRESS;
37
  $checker = new ServicesChecker();
38
  $bounceAddress = $this->settings->get('bounce.address');
39
  $segments = Segment::getAnalytics();
lib/Config/DeactivationSurvey.php CHANGED
@@ -27,10 +27,10 @@ class DeactivationSurvey {
27
  return false;
28
  }
29
  $screen = WPFunctions::get()->getCurrentScreen();
30
- if (!is_object($screen)) {
31
  return false;
32
  }
33
- return (in_array(get_current_screen()->id, ['plugins', 'plugins-network'], true));
34
  }
35
 
36
  public function js() {
27
  return false;
28
  }
29
  $screen = WPFunctions::get()->getCurrentScreen();
30
+ if (is_null($screen)) {
31
  return false;
32
  }
33
+ return (in_array($screen->id, ['plugins', 'plugins-network'], true));
34
  }
35
 
36
  public function js() {
lib/Config/MP2Migrator.php CHANGED
@@ -715,7 +715,7 @@ class MP2Migrator {
715
  *
716
  * @param int $subscriber_id
717
  * @param array $user_list
718
- * @return SubscriberSegment
719
  */
720
  private function importSubscriberSegment($subscriber_id, $user_list) {
721
  $subscriber_segment = null;
@@ -946,7 +946,7 @@ class MP2Migrator {
946
  * Replace the MP2 shortcodes used in the textarea fields
947
  *
948
  * @param string $text Text
949
- * @return string Text
950
  */
951
  private function replaceMP2Shortcodes($text) {
952
  $text = str_replace('[total_subscribers]', '[mailpoet_subscribers_count]', $text);
@@ -990,7 +990,7 @@ class MP2Migrator {
990
  $segment_id = $this->segments_mapping[$item_value];
991
  $mp3_value['id'] = $segment_id;
992
  $segment = Segment::findOne($segment_id);
993
- if ($segment) {
994
  $mp3_value['name'] = $segment->get('name');
995
  }
996
  } else {
@@ -1180,7 +1180,7 @@ class MP2Migrator {
1180
  $emails_number /= 8;
1181
  break;
1182
  }
1183
- $emails_number = round($emails_number);
1184
  }
1185
  return $emails_number;
1186
  }
715
  *
716
  * @param int $subscriber_id
717
  * @param array $user_list
718
+ * @return SubscriberSegment|null
719
  */
720
  private function importSubscriberSegment($subscriber_id, $user_list) {
721
  $subscriber_segment = null;
946
  * Replace the MP2 shortcodes used in the textarea fields
947
  *
948
  * @param string $text Text
949
+ * @return string|null Text
950
  */
951
  private function replaceMP2Shortcodes($text) {
952
  $text = str_replace('[total_subscribers]', '[mailpoet_subscribers_count]', $text);
990
  $segment_id = $this->segments_mapping[$item_value];
991
  $mp3_value['id'] = $segment_id;
992
  $segment = Segment::findOne($segment_id);
993
+ if ($segment instanceof Segment) {
994
  $mp3_value['name'] = $segment->get('name');
995
  }
996
  } else {
1180
  $emails_number /= 8;
1181
  break;
1182
  }
1183
+ $emails_number = (int)round($emails_number);
1184
  }
1185
  return $emails_number;
1186
  }
lib/Cron/CronTrigger.php CHANGED
@@ -5,42 +5,55 @@ namespace MailPoet\Cron;
5
  if (!defined('ABSPATH')) exit;
6
 
7
 
 
 
8
  use MailPoet\Settings\SettingsController;
9
 
10
  class CronTrigger {
11
- /** @var SettingsController */
12
- private $settings;
13
-
14
  const METHOD_LINUX_CRON = 'Linux Cron';
15
  const METHOD_MAILPOET = 'MailPoet';
16
  const METHOD_WORDPRESS = 'WordPress';
17
 
18
- public static $available_methods = [
19
  'mailpoet' => self::METHOD_MAILPOET,
20
  'wordpress' => self::METHOD_WORDPRESS,
21
  'linux_cron' => self::METHOD_LINUX_CRON,
22
  'none' => 'Disabled',
23
  ];
 
24
  const DEFAULT_METHOD = 'WordPress';
25
  const SETTING_NAME = 'cron_trigger';
26
 
27
- function __construct(SettingsController $settings) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  $this->settings = $settings;
29
  }
30
 
31
  function init() {
32
  $current_method = $this->settings->get(self::SETTING_NAME . '.method');
33
  try {
34
- $trigger_class = __NAMESPACE__ . '\Triggers\\' . $current_method;
35
- return (class_exists($trigger_class)) ?
36
- $trigger_class::run() :
37
- false;
 
 
38
  } catch (\Exception $e) {
39
  // cron exceptions should not prevent the rest of the site from loading
40
  }
41
  }
42
-
43
- static function getAvailableMethods() {
44
- return self::$available_methods;
45
- }
46
  }
5
  if (!defined('ABSPATH')) exit;
6
 
7
 
8
+ use MailPoet\Cron\Triggers\MailPoet;
9
+ use MailPoet\Cron\Triggers\WordPress;
10
  use MailPoet\Settings\SettingsController;
11
 
12
  class CronTrigger {
 
 
 
13
  const METHOD_LINUX_CRON = 'Linux Cron';
14
  const METHOD_MAILPOET = 'MailPoet';
15
  const METHOD_WORDPRESS = 'WordPress';
16
 
17
+ const METHODS = [
18
  'mailpoet' => self::METHOD_MAILPOET,
19
  'wordpress' => self::METHOD_WORDPRESS,
20
  'linux_cron' => self::METHOD_LINUX_CRON,
21
  'none' => 'Disabled',
22
  ];
23
+
24
  const DEFAULT_METHOD = 'WordPress';
25
  const SETTING_NAME = 'cron_trigger';
26
 
27
+ /** @var MailPoet */
28
+ private $mailpoet_trigger;
29
+
30
+ /** @var WordPress */
31
+ private $wordpress_trigger;
32
+
33
+ /** @var SettingsController */
34
+ private $settings;
35
+
36
+ function __construct(
37
+ MailPoet $mailpoet_trigger,
38
+ WordPress $wordpress_trigger,
39
+ SettingsController $settings
40
+ ) {
41
+ $this->mailpoet_trigger = $mailpoet_trigger;
42
+ $this->wordpress_trigger = $wordpress_trigger;
43
  $this->settings = $settings;
44
  }
45
 
46
  function init() {
47
  $current_method = $this->settings->get(self::SETTING_NAME . '.method');
48
  try {
49
+ if ($current_method === self::METHOD_MAILPOET) {
50
+ return $this->mailpoet_trigger->run();
51
+ } elseif ($current_method === self::METHOD_WORDPRESS) {
52
+ return $this->wordpress_trigger->run();
53
+ }
54
+ return false;
55
  } catch (\Exception $e) {
56
  // cron exceptions should not prevent the rest of the site from loading
57
  }
58
  }
 
 
 
 
59
  }
lib/Cron/CronWorkerScheduler.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace MailPoet\Cron;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+
8
+ use Carbon\Carbon;
9
+ use MailPoet\Models\ScheduledTask;
10
+ use MailPoet\WP\Functions as WPFunctions;
11
+
12
+ class CronWorkerScheduler {
13
+ /** @var WPFunctions */
14
+ private $wp;
15
+
16
+ function __construct(WPFunctions $wp) {
17
+ $this->wp = $wp;
18
+ }
19
+
20
+ function schedule($task_type, $next_run_date) {
21
+ $already_scheduled = ScheduledTask::where('type', $task_type)
22
+ ->whereNull('deleted_at')
23
+ ->where('status', ScheduledTask::STATUS_SCHEDULED)
24
+ ->findMany();
25
+ if ($already_scheduled) {
26
+ return false;
27
+ }
28
+ $task = ScheduledTask::create();
29
+ $task->type = $task_type;
30
+ $task->status = ScheduledTask::STATUS_SCHEDULED;
31
+ $task->priority = ScheduledTask::PRIORITY_LOW;
32
+ $task->scheduled_at = $next_run_date;
33
+ $task->save();
34
+ return $task;
35
+ }
36
+
37
+ function reschedule(ScheduledTask $task, $timeout) {
38
+ $scheduled_at = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
39
+ $task->scheduled_at = $scheduled_at->addMinutes($timeout);
40
+ $task->setExpr('updated_at', 'NOW()');
41
+ $task->status = ScheduledTask::STATUS_SCHEDULED;
42
+ $task->save();
43
+ }
44
+ }
lib/Cron/Daemon.php CHANGED
@@ -29,7 +29,7 @@ class Daemon {
29
  $errors = [];
30
  foreach ($this->getWorkers() as $worker) {
31
  try {
32
- $worker->process();
33
  } catch (\Exception $e) {
34
  $worker_class_name_parts = explode('\\', get_class($worker));
35
  $errors[] = [
@@ -48,21 +48,21 @@ class Daemon {
48
  }
49
 
50
  private function getWorkers() {
51
- yield $this->workers_factory->createMigrationWorker($this->timer);
52
- yield $this->workers_factory->createStatsNotificationsWorker($this->timer);
53
- yield $this->workers_factory->createScheduleWorker($this->timer);
54
- yield $this->workers_factory->createQueueWorker($this->timer);
55
- yield $this->workers_factory->createSendingServiceKeyCheckWorker($this->timer);
56
- yield $this->workers_factory->createPremiumKeyCheckWorker($this->timer);
57
- yield $this->workers_factory->createBounceWorker($this->timer);
58
- yield $this->workers_factory->createExportFilesCleanupWorker($this->timer);
59
- yield $this->workers_factory->createBeamerkWorker($this->timer);
60
- yield $this->workers_factory->createInactiveSubscribersWorker($this->timer);
61
- yield $this->workers_factory->createUnsubscribeTokensWorker($this->timer);
62
- yield $this->workers_factory->createWooCommerceSyncWorker($this->timer);
63
- yield $this->workers_factory->createAuthorizedSendingEmailsCheckWorker($this->timer);
64
- yield $this->workers_factory->createWooCommercePastOrdersWorker($this->timer);
65
- yield $this->workers_factory->createStatsNotificationsWorkerForAutomatedEmails($this->timer);
66
- yield $this->workers_factory->createSubscriberLinkTokensWorker($this->timer);
67
  }
68
  }
29
  $errors = [];
30
  foreach ($this->getWorkers() as $worker) {
31
  try {
32
+ $worker->process($this->timer);
33
  } catch (\Exception $e) {
34
  $worker_class_name_parts = explode('\\', get_class($worker));
35
  $errors[] = [
48
  }
49
 
50
  private function getWorkers() {
51
+ yield $this->workers_factory->createMigrationWorker();
52
+ yield $this->workers_factory->createStatsNotificationsWorker();
53
+ yield $this->workers_factory->createScheduleWorker();
54
+ yield $this->workers_factory->createQueueWorker();
55
+ yield $this->workers_factory->createSendingServiceKeyCheckWorker();
56
+ yield $this->workers_factory->createPremiumKeyCheckWorker();
57
+ yield $this->workers_factory->createBounceWorker();
58
+ yield $this->workers_factory->createExportFilesCleanupWorker();
59
+ yield $this->workers_factory->createBeamerkWorker();
60
+ yield $this->workers_factory->createInactiveSubscribersWorker();
61
+ yield $this->workers_factory->createUnsubscribeTokensWorker();
62
+ yield $this->workers_factory->createWooCommerceSyncWorker();
63
+ yield $this->workers_factory->createAuthorizedSendingEmailsCheckWorker();
64
+ yield $this->workers_factory->createWooCommercePastOrdersWorker();
65
+ yield $this->workers_factory->createStatsNotificationsWorkerForAutomatedEmails();
66
+ yield $this->workers_factory->createSubscriberLinkTokensWorker();
67
  }
68
  }
lib/Cron/DaemonHttpRunner.php CHANGED
@@ -26,13 +26,17 @@ class DaemonHttpRunner {
26
 
27
  const PING_SUCCESS_RESPONSE = 'pong';
28
 
29
- function __construct(Daemon $daemon = null, CronHelper $cron_helper, SettingsController $settings) {
 
 
 
30
  $this->cron_helper = $cron_helper;
31
  $this->settings_daemon_data = $this->cron_helper->getDaemon();
32
  $this->token = $this->cron_helper->createToken();
33
  $this->timer = microtime(true);
34
  $this->daemon = $daemon;
35
  $this->settings = $settings;
 
36
  }
37
 
38
  function ping() {
@@ -112,16 +116,15 @@ class DaemonHttpRunner {
112
  }
113
 
114
  function isCronTriggerMethodWordPress() {
115
- $available_methods = CronTrigger::getAvailableMethods();
116
- return $this->settings->get(CronTrigger::SETTING_NAME . '.method') === $available_methods['wordpress'];
117
  }
118
 
119
  function checkWPTriggerExecutionRequirements() {
120
- return WordPress::checkExecutionRequirements();
121
  }
122
 
123
  function stopCron() {
124
- return WordPress::stop();
125
  }
126
 
127
  /**
26
 
27
  const PING_SUCCESS_RESPONSE = 'pong';
28
 
29
+ /** @var WordPress */
30
+ private $wordpress_trigger;
31
+
32
+ function __construct(Daemon $daemon = null, CronHelper $cron_helper, SettingsController $settings, WordPress $wordpress_trigger) {
33
  $this->cron_helper = $cron_helper;
34
  $this->settings_daemon_data = $this->cron_helper->getDaemon();
35
  $this->token = $this->cron_helper->createToken();
36
  $this->timer = microtime(true);
37
  $this->daemon = $daemon;
38
  $this->settings = $settings;
39
+ $this->wordpress_trigger = $wordpress_trigger;
40
  }
41
 
42
  function ping() {
116
  }
117
 
118
  function isCronTriggerMethodWordPress() {
119
+ return $this->settings->get(CronTrigger::SETTING_NAME . '.method') === CronTrigger::METHOD_WORDPRESS;
 
120
  }
121
 
122
  function checkWPTriggerExecutionRequirements() {
123
+ return $this->wordpress_trigger->checkExecutionRequirements();
124
  }
125
 
126
  function stopCron() {
127
+ return $this->wordpress_trigger->stop();
128
  }
129
 
130
  /**
lib/Cron/Triggers/MailPoet.php CHANGED
@@ -6,12 +6,17 @@ if (!defined('ABSPATH')) exit;
6
 
7
 
8
  use MailPoet\Cron\Supervisor;
9
- use MailPoet\DI\ContainerWrapper;
10
 
11
  class MailPoet {
12
- static function run() {
13
- $supervisor = ContainerWrapper::getInstance()->get(Supervisor::class);
14
- $supervisor->init();
15
- return $supervisor->checkDaemon();
 
 
 
 
 
 
16
  }
17
  }
6
 
7
 
8
  use MailPoet\Cron\Supervisor;
 
9
 
10
  class MailPoet {
11
+ /** @var Supervisor */
12
+ private $supervisor;
13
+
14
+ function __construct(Supervisor $supervisor) {
15
+ $this->supervisor = $supervisor;
16
+ }
17
+
18
+ function run() {
19
+ $this->supervisor->init();
20
+ return $this->supervisor->checkDaemon();
21
  }
22
  }
lib/Cron/Triggers/WordPress.php CHANGED
@@ -21,7 +21,6 @@ use MailPoet\Cron\Workers\SubscriberLinkTokens;
21
  use MailPoet\Cron\Workers\UnsubscribeTokens;
22
  use MailPoet\Cron\Workers\WooCommercePastOrders;
23
  use MailPoet\Cron\Workers\WooCommerceSync as WooCommerceSyncWorker;
24
- use MailPoet\DI\ContainerWrapper;
25
  use MailPoet\Mailer\MailerLog;
26
  use MailPoet\Models\ScheduledTask;
27
  use MailPoet\Services\Bridge;
@@ -35,24 +34,47 @@ class WordPress {
35
  const RUN_INTERVAL = -1; // seconds
36
  const LAST_RUN_AT_SETTING = 'cron_trigger_wordpress.last_run_at';
37
 
38
- static private $tasks_counts;
39
 
40
- static function run() {
41
- if (!self::checkRunInterval()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  return false;
43
  }
44
- return (self::checkExecutionRequirements()) ?
45
- MailPoet::run() :
46
  self::stop();
47
  }
48
 
49
- private static function checkRunInterval() {
50
- $settings = SettingsController::getInstance();
51
- $last_run_at = (int)$settings->get(self::LAST_RUN_AT_SETTING, 0);
52
- $run_interval = WPFunctions::get()->applyFilters('mailpoet_cron_trigger_wordpress_run_interval', self::RUN_INTERVAL);
53
  $run_interval_elapsed = (time() - $last_run_at) >= $run_interval;
54
  if ($run_interval_elapsed) {
55
- $settings->set(self::LAST_RUN_AT_SETTING, time());
56
  return true;
57
  }
58
  return false;
@@ -63,23 +85,22 @@ class WordPress {
63
  $settings->set(self::LAST_RUN_AT_SETTING, 0);
64
  }
65
 
66
- static function checkExecutionRequirements(WPFunctions $wp = null) {
67
- self::loadTasksCounts($wp ?: new WPFunctions);
68
 
69
  // migration
70
- $settings = SettingsController::getInstance();
71
- $migration_disabled = $settings->get('cron_trigger.method') === 'none';
72
- $migration_due_tasks = self::getTasksCount([
73
  'type' => MigrationWorker::TASK_TYPE,
74
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
75
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
76
  ]);
77
- $migration_completed_tasks = self::getTasksCount([
78
  'type' => MigrationWorker::TASK_TYPE,
79
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST, self::SCHEDULED_IN_THE_FUTURE],
80
  'status' => [ScheduledTask::STATUS_COMPLETED],
81
  ]);
82
- $migration_future_tasks = self::getTasksCount([
83
  'type' => MigrationWorker::TASK_TYPE,
84
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
85
  'status' => [ScheduledTask::STATUS_SCHEDULED],
@@ -92,96 +113,96 @@ class WordPress {
92
  // sending service
93
  $mp_sending_enabled = Bridge::isMPSendingServiceEnabled();
94
  // bounce sync
95
- $bounce_due_tasks = self::getTasksCount([
96
  'type' => BounceWorker::TASK_TYPE,
97
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
98
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
99
  ]);
100
- $bounce_future_tasks = self::getTasksCount([
101
  'type' => BounceWorker::TASK_TYPE,
102
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
103
  'status' => [ScheduledTask::STATUS_SCHEDULED],
104
  ]);
105
  // sending service key check
106
- $msskeycheck_due_tasks = self::getTasksCount([
107
  'type' => SendingServiceKeyCheckWorker::TASK_TYPE,
108
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
109
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
110
  ]);
111
- $msskeycheck_future_tasks = self::getTasksCount([
112
  'type' => SendingServiceKeyCheckWorker::TASK_TYPE,
113
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
114
  'status' => [ScheduledTask::STATUS_SCHEDULED],
115
  ]);
116
  // premium key check
117
  $premium_key_specified = Bridge::isPremiumKeySpecified();
118
- $premium_keycheck_due_tasks = self::getTasksCount([
119
  'type' => PremiumKeyCheckWorker::TASK_TYPE,
120
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
121
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
122
  ]);
123
- $premium_keycheck_future_tasks = self::getTasksCount([
124
  'type' => PremiumKeyCheckWorker::TASK_TYPE,
125
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
126
  'status' => [ScheduledTask::STATUS_SCHEDULED],
127
  ]);
128
  // stats notifications
129
- $stats_notifications_tasks = self::getTasksCount([
130
  'type' => StatsNotificationsWorker::TASK_TYPE,
131
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
132
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
133
  ]);
134
  // stats notifications for auto emails
135
- $auto_stats_notifications_tasks = self::getTasksCount([
136
  'type' => AutomatedEmails::TASK_TYPE,
137
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
138
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
139
  ]);
140
  // inactive subscribers check
141
- $inactive_subscribers_tasks = self::getTasksCount([
142
  'type' => InactiveSubscribers::TASK_TYPE,
143
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
144
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
145
  ]);
146
  // unsubscribe tokens check
147
- $unsubscribe_tokens_tasks = self::getTasksCount([
148
  'type' => UnsubscribeTokens::TASK_TYPE,
149
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
150
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
151
  ]);
152
  // subscriber link tokens check
153
- $subscriber_link_tokens_tasks = self::getTasksCount([
154
  'type' => SubscriberLinkTokens::TASK_TYPE,
155
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
156
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
157
  ]);
158
  // WooCommerce sync
159
- $woo_commerce_sync_tasks = self::getTasksCount([
160
  'type' => WooCommerceSyncWorker::TASK_TYPE,
161
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
162
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
163
  ]);
164
  // Beamer
165
- $beamer_due_checks = self::getTasksCount([
166
  'type' => BeamerWorker::TASK_TYPE,
167
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
168
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
169
  ]);
170
- $beamer_future_checks = self::getTasksCount([
171
  'type' => BeamerWorker::TASK_TYPE,
172
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
173
  'status' => [ScheduledTask::STATUS_SCHEDULED],
174
  ]);
175
 
176
  // Authorized email addresses check
177
- $authorized_email_addresses_tasks = self::getTasksCount([
178
  'type' => AuthorizedSendingEmailsCheck::TASK_TYPE,
179
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
180
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
181
  ]);
182
 
183
  // WooCommerce past orders revenues sync
184
- $woo_commerce_past_orders_tasks = self::getTasksCount([
185
  'type' => WooCommercePastOrders::TASK_TYPE,
186
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
187
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
@@ -213,15 +234,14 @@ class WordPress {
213
  );
214
  }
215
 
216
- static function stop() {
217
- $cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
218
- $cron_daemon = $cron_helper->getDaemon();
219
  if ($cron_daemon) {
220
- $cron_helper->deactivateDaemon($cron_daemon);
221
  }
222
  }
223
 
224
- static private function loadTasksCounts(WPFunctions $wp) {
225
  $query = sprintf(
226
  "select
227
  type,
@@ -232,31 +252,31 @@ class WordPress {
232
  where deleted_at is null
233
  group by type, status, scheduled_in
234
  ",
235
- date('Y-m-d H:i:s', $wp->currentTime('timestamp')),
236
  self::SCHEDULED_IN_THE_PAST,
237
  self::SCHEDULED_IN_THE_FUTURE,
238
  ScheduledTask::$_table
239
  );
240
  $rows = ScheduledTask::rawQuery($query)->findMany();
241
- self::$tasks_counts = [];
242
  foreach ($rows as $r) {
243
- if (empty(self::$tasks_counts[$r->type])) {
244
- self::$tasks_counts[$r->type] = [];
245
  }
246
- if (empty(self::$tasks_counts[$r->type][$r->scheduled_in])) {
247
- self::$tasks_counts[$r->type][$r->scheduled_in] = [];
248
  }
249
- self::$tasks_counts[$r->type][$r->scheduled_in][$r->status ?: 'null'] = $r->count;
250
  }
251
  }
252
 
253
- static private function getTasksCount(array $options) {
254
  $count = 0;
255
  $type = $options['type'];
256
  foreach ($options['scheduled_in'] as $scheduled_in) {
257
  foreach ($options['status'] as $status) {
258
- if (! empty(self::$tasks_counts[$type][$scheduled_in][$status])) {
259
- $count += self::$tasks_counts[$type][$scheduled_in][$status];
260
  }
261
  }
262
  }
21
  use MailPoet\Cron\Workers\UnsubscribeTokens;
22
  use MailPoet\Cron\Workers\WooCommercePastOrders;
23
  use MailPoet\Cron\Workers\WooCommerceSync as WooCommerceSyncWorker;
 
24
  use MailPoet\Mailer\MailerLog;
25
  use MailPoet\Models\ScheduledTask;
26
  use MailPoet\Services\Bridge;
34
  const RUN_INTERVAL = -1; // seconds
35
  const LAST_RUN_AT_SETTING = 'cron_trigger_wordpress.last_run_at';
36
 
37
+ private $tasks_counts;
38
 
39
+ /** @var CronHelper */
40
+ private $cron_helper;
41
+
42
+ /** @var MailPoet */
43
+ private $mailpoet_trigger;
44
+
45
+ /** @var SettingsController */
46
+ private $settings;
47
+
48
+ /** @var WPFunctions */
49
+ private $wp;
50
+
51
+ function __construct(
52
+ CronHelper $cron_helper,
53
+ MailPoet $mailpoet_trigger,
54
+ SettingsController $settings,
55
+ WPFunctions $wp
56
+ ) {
57
+ $this->mailpoet_trigger = $mailpoet_trigger;
58
+ $this->settings = $settings;
59
+ $this->wp = $wp;
60
+ $this->cron_helper = $cron_helper;
61
+ }
62
+
63
+ function run() {
64
+ if (!$this->checkRunInterval()) {
65
  return false;
66
  }
67
+ return ($this->checkExecutionRequirements()) ?
68
+ $this->mailpoet_trigger->run() :
69
  self::stop();
70
  }
71
 
72
+ private function checkRunInterval() {
73
+ $last_run_at = (int)$this->settings->get(self::LAST_RUN_AT_SETTING, 0);
74
+ $run_interval = $this->wp->applyFilters('mailpoet_cron_trigger_wordpress_run_interval', self::RUN_INTERVAL);
 
75
  $run_interval_elapsed = (time() - $last_run_at) >= $run_interval;
76
  if ($run_interval_elapsed) {
77
+ $this->settings->set(self::LAST_RUN_AT_SETTING, time());
78
  return true;
79
  }
80
  return false;
85
  $settings->set(self::LAST_RUN_AT_SETTING, 0);
86
  }
87
 
88
+ function checkExecutionRequirements() {
89
+ $this->loadTasksCounts();
90
 
91
  // migration
92
+ $migration_disabled = $this->settings->get('cron_trigger.method') === 'none';
93
+ $migration_due_tasks = $this->getTasksCount([
 
94
  'type' => MigrationWorker::TASK_TYPE,
95
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
96
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
97
  ]);
98
+ $migration_completed_tasks = $this->getTasksCount([
99
  'type' => MigrationWorker::TASK_TYPE,
100
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST, self::SCHEDULED_IN_THE_FUTURE],
101
  'status' => [ScheduledTask::STATUS_COMPLETED],
102
  ]);
103
+ $migration_future_tasks = $this->getTasksCount([
104
  'type' => MigrationWorker::TASK_TYPE,
105
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
106
  'status' => [ScheduledTask::STATUS_SCHEDULED],
113
  // sending service
114
  $mp_sending_enabled = Bridge::isMPSendingServiceEnabled();
115
  // bounce sync
116
+ $bounce_due_tasks = $this->getTasksCount([
117
  'type' => BounceWorker::TASK_TYPE,
118
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
119
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
120
  ]);
121
+ $bounce_future_tasks = $this->getTasksCount([
122
  'type' => BounceWorker::TASK_TYPE,
123
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
124
  'status' => [ScheduledTask::STATUS_SCHEDULED],
125
  ]);
126
  // sending service key check
127
+ $msskeycheck_due_tasks = $this->getTasksCount([
128
  'type' => SendingServiceKeyCheckWorker::TASK_TYPE,
129
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
130
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
131
  ]);
132
+ $msskeycheck_future_tasks = $this->getTasksCount([
133
  'type' => SendingServiceKeyCheckWorker::TASK_TYPE,
134
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
135
  'status' => [ScheduledTask::STATUS_SCHEDULED],
136
  ]);
137
  // premium key check
138
  $premium_key_specified = Bridge::isPremiumKeySpecified();
139
+ $premium_keycheck_due_tasks = $this->getTasksCount([
140
  'type' => PremiumKeyCheckWorker::TASK_TYPE,
141
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
142
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
143
  ]);
144
+ $premium_keycheck_future_tasks = $this->getTasksCount([
145
  'type' => PremiumKeyCheckWorker::TASK_TYPE,
146
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
147
  'status' => [ScheduledTask::STATUS_SCHEDULED],
148
  ]);
149
  // stats notifications
150
+ $stats_notifications_tasks = $this->getTasksCount([
151
  'type' => StatsNotificationsWorker::TASK_TYPE,
152
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
153
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
154
  ]);
155
  // stats notifications for auto emails
156
+ $auto_stats_notifications_tasks = $this->getTasksCount([
157
  'type' => AutomatedEmails::TASK_TYPE,
158
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
159
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
160
  ]);
161
  // inactive subscribers check
162
+ $inactive_subscribers_tasks = $this->getTasksCount([
163
  'type' => InactiveSubscribers::TASK_TYPE,
164
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
165
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
166
  ]);
167
  // unsubscribe tokens check
168
+ $unsubscribe_tokens_tasks = $this->getTasksCount([
169
  'type' => UnsubscribeTokens::TASK_TYPE,
170
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
171
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
172
  ]);
173
  // subscriber link tokens check
174
+ $subscriber_link_tokens_tasks = $this->getTasksCount([
175
  'type' => SubscriberLinkTokens::TASK_TYPE,
176
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
177
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
178
  ]);
179
  // WooCommerce sync
180
+ $woo_commerce_sync_tasks = $this->getTasksCount([
181
  'type' => WooCommerceSyncWorker::TASK_TYPE,
182
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
183
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
184
  ]);
185
  // Beamer
186
+ $beamer_due_checks = $this->getTasksCount([
187
  'type' => BeamerWorker::TASK_TYPE,
188
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
189
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
190
  ]);
191
+ $beamer_future_checks = $this->getTasksCount([
192
  'type' => BeamerWorker::TASK_TYPE,
193
  'scheduled_in' => [self::SCHEDULED_IN_THE_FUTURE],
194
  'status' => [ScheduledTask::STATUS_SCHEDULED],
195
  ]);
196
 
197
  // Authorized email addresses check
198
+ $authorized_email_addresses_tasks = $this->getTasksCount([
199
  'type' => AuthorizedSendingEmailsCheck::TASK_TYPE,
200
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
201
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
202
  ]);
203
 
204
  // WooCommerce past orders revenues sync
205
+ $woo_commerce_past_orders_tasks = $this->getTasksCount([
206
  'type' => WooCommercePastOrders::TASK_TYPE,
207
  'scheduled_in' => [self::SCHEDULED_IN_THE_PAST],
208
  'status' => ['null', ScheduledTask::STATUS_SCHEDULED],
234
  );
235
  }
236
 
237
+ function stop() {
238
+ $cron_daemon = $this->cron_helper->getDaemon();
 
239
  if ($cron_daemon) {
240
+ $this->cron_helper->deactivateDaemon($cron_daemon);
241
  }
242
  }
243
 
244
+ private function loadTasksCounts() {
245
  $query = sprintf(
246
  "select
247
  type,
252
  where deleted_at is null
253
  group by type, status, scheduled_in
254
  ",
255
+ date('Y-m-d H:i:s', $this->wp->currentTime('timestamp')),
256
  self::SCHEDULED_IN_THE_PAST,
257
  self::SCHEDULED_IN_THE_FUTURE,
258
  ScheduledTask::$_table
259
  );
260
  $rows = ScheduledTask::rawQuery($query)->findMany();
261
+ $this->tasks_counts = [];
262
  foreach ($rows as $r) {
263
+ if (empty($this->tasks_counts[$r->type])) {
264
+ $this->tasks_counts[$r->type] = [];
265
  }
266
+ if (empty($this->tasks_counts[$r->type][$r->scheduled_in])) {
267
+ $this->tasks_counts[$r->type][$r->scheduled_in] = [];
268
  }
269
+ $this->tasks_counts[$r->type][$r->scheduled_in][$r->status ?: 'null'] = $r->count;
270
  }
271
  }
272
 
273
+ private function getTasksCount(array $options) {
274
  $count = 0;
275
  $type = $options['type'];
276
  foreach ($options['scheduled_in'] as $scheduled_in) {
277
  foreach ($options['status'] as $status) {
278
+ if (! empty($this->tasks_counts[$type][$scheduled_in][$status])) {
279
+ $count += $this->tasks_counts[$type][$scheduled_in][$status];
280
  }
281
  }
282
  }
lib/Cron/Workers/AuthorizedSendingEmailsCheck.php CHANGED
@@ -16,16 +16,16 @@ class AuthorizedSendingEmailsCheck extends SimpleWorker {
16
  /** @var AuthorizedEmailsController */
17
  private $authorized_emails_controller;
18
 
19
- function __construct(AuthorizedEmailsController $authorized_emails_controller, $timer = false) {
20
  $this->authorized_emails_controller = $authorized_emails_controller;
21
- parent::__construct($timer);
22
  }
23
 
24
  function checkProcessingRequirements() {
25
  return Bridge::isMPSendingServiceEnabled();
26
  }
27
 
28
- function processTaskStrategy(ScheduledTask $task) {
29
  $this->authorized_emails_controller->checkAuthorizedEmailAddresses();
30
  return true;
31
  }
16
  /** @var AuthorizedEmailsController */
17
  private $authorized_emails_controller;
18
 
19
+ function __construct(AuthorizedEmailsController $authorized_emails_controller) {
20
  $this->authorized_emails_controller = $authorized_emails_controller;
21
+ parent::__construct();
22
  }
23
 
24
  function checkProcessingRequirements() {
25
  return Bridge::isMPSendingServiceEnabled();
26
  }
27
 
28
+ function processTaskStrategy(ScheduledTask $task, $timer) {
29
  $this->authorized_emails_controller->checkAuthorizedEmailAddresses();
30
  return true;
31
  }
lib/Cron/Workers/Beamer.php CHANGED
@@ -21,13 +21,13 @@ class Beamer extends SimpleWorker {
21
  /** @var WPFunctions */
22
  private $wp;
23
 
24
- function __construct(SettingsController $settings, WPFunctions $wp, $timer = false) {
25
- parent::__construct($timer);
26
  $this->settings = $settings;
27
  $this->wp = $wp;
28
  }
29
 
30
- function processTaskStrategy(ScheduledTask $task) {
31
  return $this->setLastAnnouncementDate();
32
  }
33
 
@@ -45,7 +45,7 @@ class Beamer extends SimpleWorker {
45
  return true;
46
  }
47
 
48
- static function getNextRunDate() {
49
  $wp = new WPFunctions;
50
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
51
  return $date->hour(11)->minute(00)->second(00)->addDay();
21
  /** @var WPFunctions */
22
  private $wp;
23
 
24
+ function __construct(SettingsController $settings, WPFunctions $wp) {
25
+ parent::__construct();
26
  $this->settings = $settings;
27
  $this->wp = $wp;
28
  }
29
 
30
+ function processTaskStrategy(ScheduledTask $task, $timer) {
31
  return $this->setLastAnnouncementDate();
32
  }
33
 
45
  return true;
46
  }
47
 
48
+ function getNextRunDate() {
49
  $wp = new WPFunctions;
50
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
51
  return $date->hour(11)->minute(00)->second(00)->addDay();
lib/Cron/Workers/Bounce.php CHANGED
@@ -32,9 +32,9 @@ class Bounce extends SimpleWorker {
32
  /** @var SettingsController */
33
  private $settings;
34
 
35
- function __construct(SettingsController $settings, $timer = false) {
36
  $this->settings = $settings;
37
- parent::__construct($timer);
38
  }
39
 
40
  function init() {
@@ -47,30 +47,29 @@ class Bounce extends SimpleWorker {
47
  return Bridge::isMPSendingServiceEnabled();
48
  }
49
 
50
- function prepareTask(ScheduledTask $task) {
51
  BounceTask::prepareSubscribers($task);
52
 
53
  if (!ScheduledTaskSubscriber::getUnprocessedCount($task->id)) {
54
- $task->delete();
55
  return false;
56
  }
57
-
58
- return parent::prepareTask($task);
59
  }
60
 
61
- function processTask(ScheduledTask $task) {
62
  $subscriber_batches = new BatchIterator($task->id, self::BATCH_SIZE);
63
 
64
  if (count($subscriber_batches) === 0) {
65
- $task->delete();
66
- return false;
67
  }
68
 
69
  $task_subscribers = new TaskSubscribers($task);
70
 
71
  foreach ($subscriber_batches as $subscribers_to_process_ids) {
72
  // abort if execution limit is reached
73
- $this->cron_helper->enforceExecutionLimit($this->timer);
74
 
75
  $subscriber_emails = Subscriber::select('email')
76
  ->whereIn('id', $subscribers_to_process_ids)
32
  /** @var SettingsController */
33
  private $settings;
34
 
35
+ function __construct(SettingsController $settings) {
36
  $this->settings = $settings;
37
+ parent::__construct();
38
  }
39
 
40
  function init() {
47
  return Bridge::isMPSendingServiceEnabled();
48
  }
49
 
50
+ function prepareTaskStrategy(ScheduledTask $task, $timer) {
51
  BounceTask::prepareSubscribers($task);
52
 
53
  if (!ScheduledTaskSubscriber::getUnprocessedCount($task->id)) {
54
+ ScheduledTaskSubscriber::where('task_id', $task->id)->deleteMany();
55
  return false;
56
  }
57
+ return true;
 
58
  }
59
 
60
+ function processTaskStrategy(ScheduledTask $task, $timer) {
61
  $subscriber_batches = new BatchIterator($task->id, self::BATCH_SIZE);
62
 
63
  if (count($subscriber_batches) === 0) {
64
+ ScheduledTaskSubscriber::where('task_id', $task->id)->deleteMany();
65
+ return true; // mark completed
66
  }
67
 
68
  $task_subscribers = new TaskSubscribers($task);
69
 
70
  foreach ($subscriber_batches as $subscribers_to_process_ids) {
71
  // abort if execution limit is reached
72
+ $this->cron_helper->enforceExecutionLimit($timer);
73
 
74
  $subscriber_emails = Subscriber::select('email')
75
  ->whereIn('id', $subscribers_to_process_ids)
lib/Cron/Workers/ExportFilesCleanup.php CHANGED
@@ -13,9 +13,12 @@ class ExportFilesCleanup extends SimpleWorker {
13
  const TASK_TYPE = 'export_files_cleanup';
14
  const DELETE_FILES_AFTER_X_DAYS = 1;
15
 
16
- function processTaskStrategy(ScheduledTask $task) {
17
  $iterator = new \GlobIterator(Export::getExportPath() . '/' . Export::getFilePrefix() . '*.*');
18
  foreach ($iterator as $file) {
 
 
 
19
  $name = $file->getPathname();
20
  $created = $file->getMTime();
21
  $now = new Carbon();
13
  const TASK_TYPE = 'export_files_cleanup';
14
  const DELETE_FILES_AFTER_X_DAYS = 1;
15
 
16
+ function processTaskStrategy(ScheduledTask $task, $timer) {
17
  $iterator = new \GlobIterator(Export::getExportPath() . '/' . Export::getFilePrefix() . '*.*');
18
  foreach ($iterator as $file) {
19
+ if (is_string($file)) {
20
+ continue;
21
+ }
22
  $name = $file->getPathname();
23
  $created = $file->getMTime();
24
  $now = new Carbon();
lib/Cron/Workers/InactiveSubscribers.php CHANGED
@@ -24,26 +24,25 @@ class InactiveSubscribers extends SimpleWorker {
24
 
25
  function __construct(
26
  InactiveSubscribersController $inactive_subscribers_controller,
27
- SettingsController $settings,
28
- $timer = false
29
  ) {
30
  $this->inactive_subscribers_controller = $inactive_subscribers_controller;
31
  $this->settings = $settings;
32
- parent::__construct($timer);
33
  }
34
 
35
 
36
- function processTaskStrategy(ScheduledTask $task) {
37
  $tracking_enabled = (bool)$this->settings->get('tracking.enabled');
38
  if (!$tracking_enabled) {
39
- self::schedule();
40
  return true;
41
  }
42
  $days_to_inactive = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
43
  // Activate all inactive subscribers in case the feature is turned off
44
  if ($days_to_inactive === 0) {
45
  $this->inactive_subscribers_controller->reactivateInactiveSubscribers();
46
- self::schedule();
47
  return true;
48
  }
49
  // Handle activation/deactivation within interval
@@ -58,12 +57,12 @@ class InactiveSubscribers extends SimpleWorker {
58
  $last_subscriber_id += self::BATCH_SIZE;
59
  $task->meta = ['last_subscriber_id' => $last_subscriber_id];
60
  $task->save();
61
- $this->cron_helper->enforceExecutionLimit($this->timer);
62
  };
63
  while ($this->inactive_subscribers_controller->markActiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
64
- $this->cron_helper->enforceExecutionLimit($this->timer);
65
  };
66
- self::schedule();
67
  return true;
68
  }
69
  }
24
 
25
  function __construct(
26
  InactiveSubscribersController $inactive_subscribers_controller,
27
+ SettingsController $settings
 
28
  ) {
29
  $this->inactive_subscribers_controller = $inactive_subscribers_controller;
30
  $this->settings = $settings;
31
+ parent::__construct();
32
  }
33
 
34
 
35
+ function processTaskStrategy(ScheduledTask $task, $timer) {
36
  $tracking_enabled = (bool)$this->settings->get('tracking.enabled');
37
  if (!$tracking_enabled) {
38
+ $this->schedule();
39
  return true;
40
  }
41
  $days_to_inactive = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
42
  // Activate all inactive subscribers in case the feature is turned off
43
  if ($days_to_inactive === 0) {
44
  $this->inactive_subscribers_controller->reactivateInactiveSubscribers();
45
+ $this->schedule();
46
  return true;
47
  }
48
  // Handle activation/deactivation within interval
57
  $last_subscriber_id += self::BATCH_SIZE;
58
  $task->meta = ['last_subscriber_id' => $last_subscriber_id];
59
  $task->save();
60
+ $this->cron_helper->enforceExecutionLimit($timer);
61
  };
62
  while ($this->inactive_subscribers_controller->markActiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
63
+ $this->cron_helper->enforceExecutionLimit($timer);
64
  };
65
+ $this->schedule();
66
  return true;
67
  }
68
  }
lib/Cron/Workers/KeyCheck/KeyCheckWorker.php CHANGED
@@ -18,7 +18,7 @@ abstract class KeyCheckWorker extends SimpleWorker {
18
  }
19
  }
20
 
21
- function processTaskStrategy(ScheduledTask $task) {
22
  try {
23
  $result = $this->checkKey();
24
  } catch (\Exception $e) {
18
  }
19
  }
20
 
21
+ function processTaskStrategy(ScheduledTask $task, $timer) {
22
  try {
23
  $result = $this->checkKey();
24
  } catch (\Exception $e) {
lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php CHANGED
@@ -14,9 +14,9 @@ class PremiumKeyCheck extends KeyCheckWorker {
14
  /** @var SettingsController */
15
  private $settings;
16
 
17
- function __construct(SettingsController $settings, $timer = false) {
18
  $this->settings = $settings;
19
- parent::__construct($timer);
20
  }
21
 
22
 
14
  /** @var SettingsController */
15
  private $settings;
16
 
17
+ function __construct(SettingsController $settings) {
18
  $this->settings = $settings;
19
+ parent::__construct();
20
  }
21
 
22
 
lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php CHANGED
@@ -15,9 +15,9 @@ class SendingServiceKeyCheck extends KeyCheckWorker {
15
  /** @var SettingsController */
16
  private $settings;
17
 
18
- function __construct(SettingsController $settings, $timer = false) {
19
  $this->settings = $settings;
20
- parent::__construct($timer);
21
  }
22
 
23
  function checkProcessingRequirements() {
15
  /** @var SettingsController */
16
  private $settings;
17
 
18
+ function __construct(SettingsController $settings) {
19
  $this->settings = $settings;
20
+ parent::__construct();
21
  }
22
 
23
  function checkProcessingRequirements() {
lib/Cron/Workers/Scheduler.php CHANGED
@@ -23,8 +23,6 @@ use MailPoetVendor\Monolog\Logger;
23
  class Scheduler {
24
  const TASK_BATCH_SIZE = 5;
25
 
26
- public $timer;
27
-
28
  /** @var SubscribersFinder */
29
  private $subscribers_finder;
30
 
@@ -37,18 +35,19 @@ class Scheduler {
37
  function __construct(
38
  SubscribersFinder $subscribers_finder,
39
  LoggerFactory $logger_factory,
40
- CronHelper $cron_helper,
41
- $timer = false
42
  ) {
43
- $this->timer = ($timer) ? $timer : microtime(true);
44
- // abort if execution limit is reached
45
  $this->cron_helper = $cron_helper;
46
- $this->cron_helper->enforceExecutionLimit($this->timer);
47
  $this->subscribers_finder = $subscribers_finder;
48
  $this->logger_factory = $logger_factory;
49
  }
50
 
51
- function process() {
 
 
 
 
 
52
  $scheduled_queues = self::getScheduledQueues();
53
  if (!count($scheduled_queues)) return false;
54
  $this->updateTasks($scheduled_queues);
@@ -67,7 +66,7 @@ class Scheduler {
67
  } elseif ($newsletter->type === Newsletter::TYPE_AUTOMATIC) {
68
  $this->processScheduledAutomaticEmail($newsletter, $queue);
69
  }
70
- $this->cron_helper->enforceExecutionLimit($this->timer);
71
  }
72
  }
73
 
@@ -251,7 +250,7 @@ class Scheduler {
251
  }
252
 
253
  private function reScheduleBounceTask() {
254
- $bounce_tasks = Bounce::getScheduledTasks($future = true);
255
  if (count($bounce_tasks)) {
256
  $bounce_task = reset($bounce_tasks);
257
  if (Carbon::createFromTimestamp(current_time('timestamp'))->addHour(42)->lessThan($bounce_task->scheduled_at)) {
23
  class Scheduler {
24
  const TASK_BATCH_SIZE = 5;
25
 
 
 
26
  /** @var SubscribersFinder */
27
  private $subscribers_finder;
28
 
35
  function __construct(
36
  SubscribersFinder $subscribers_finder,
37
  LoggerFactory $logger_factory,
38
+ CronHelper $cron_helper
 
39
  ) {
 
 
40
  $this->cron_helper = $cron_helper;
 
41
  $this->subscribers_finder = $subscribers_finder;
42
  $this->logger_factory = $logger_factory;
43
  }
44
 
45
+ function process($timer = false) {
46
+ $timer = $timer ?: microtime(true);
47
+
48
+ // abort if execution limit is reached
49
+ $this->cron_helper->enforceExecutionLimit($timer);
50
+
51
  $scheduled_queues = self::getScheduledQueues();
52
  if (!count($scheduled_queues)) return false;
53
  $this->updateTasks($scheduled_queues);
66
  } elseif ($newsletter->type === Newsletter::TYPE_AUTOMATIC) {
67
  $this->processScheduledAutomaticEmail($newsletter, $queue);
68
  }
69
+ $this->cron_helper->enforceExecutionLimit($timer);
70
  }
71
  }
72
 
250
  }
251
 
252
  private function reScheduleBounceTask() {
253
+ $bounce_tasks = ScheduledTask::findFutureScheduledByType(Bounce::TASK_TYPE);
254
  if (count($bounce_tasks)) {
255
  $bounce_task = reset($bounce_tasks);
256
  if (Carbon::createFromTimestamp(current_time('timestamp'))->addHour(42)->lessThan($bounce_task->scheduled_at)) {
lib/Cron/Workers/SendingQueue/Migration.php CHANGED
@@ -11,7 +11,7 @@ use MailPoet\Cron\Workers\SimpleWorker;
11
  use MailPoet\Mailer\MailerLog;
12
  use MailPoet\Models\ScheduledTask;
13
  use MailPoet\Models\ScheduledTaskSubscriber;
14
- use MailPoet\Models\SendingQueue;
15
  use MailPoet\WP\Functions as WPFunctions;
16
 
17
  class Migration extends SimpleWorker {
@@ -20,12 +20,12 @@ class Migration extends SimpleWorker {
20
 
21
  function checkProcessingRequirements() {
22
  // if migration was completed, don't run it again
23
- $completed_tasks = self::getCompletedTasks();
24
  return empty($completed_tasks);
25
  }
26
 
27
- function prepareTask(ScheduledTask $task) {
28
- $unmigrated_columns = self::checkUnmigratedColumnsExist();
29
  $unmigrated_queues_count = 0;
30
  $unmigrated_queue_subscribers = [];
31
 
@@ -46,8 +46,7 @@ class Migration extends SimpleWorker {
46
 
47
  // pause sending while the migration is in process
48
  $this->pauseSending();
49
-
50
- return parent::prepareTask($task);
51
  }
52
 
53
  function pauseSending() {
@@ -77,24 +76,21 @@ class Migration extends SimpleWorker {
77
  }
78
  }
79
 
80
- function processTask(ScheduledTask $task) {
81
- $this->migrateSendingQueues();
82
- $this->migrateSubscribers();
83
-
84
- $this->complete($task);
85
  $this->resumeSending();
86
-
87
  return true;
88
  }
89
 
90
- static function checkUnmigratedColumnsExist() {
91
  global $wpdb;
92
- $existing_columns = $wpdb->get_col('DESC ' . SendingQueue::$_table);
93
  return in_array('type', $existing_columns);
94
  }
95
 
96
  function getUnmigratedQueues() {
97
- return SendingQueue::where('task_id', 0)
98
  ->whereNull('type');
99
  }
100
 
@@ -115,7 +111,7 @@ class Migration extends SimpleWorker {
115
  /*
116
  * Migrate all sending queues without converting subscriber data
117
  */
118
- function migrateSendingQueues() {
119
  global $wpdb;
120
 
121
  $queues = $this->getUnmigratedQueues()
@@ -135,7 +131,7 @@ class Migration extends SimpleWorker {
135
  if (!empty($queues)) {
136
  foreach (array_chunk($queues, self::BATCH_SIZE) as $queue_batch) {
137
  // abort if execution limit is reached
138
- $this->cron_helper->enforceExecutionLimit($this->timer);
139
 
140
  foreach ($queue_batch as $queue) {
141
  // create a new scheduled task of type "sending"
@@ -165,7 +161,7 @@ class Migration extends SimpleWorker {
165
  /*
166
  * Migrate subscribers for in-progress sending tasks from the `subscribers` field to a separate table
167
  */
168
- function migrateSubscribers() {
169
  global $wpdb;
170
 
171
  // find in-progress queues that have serialized subscribers
@@ -184,16 +180,16 @@ class Migration extends SimpleWorker {
184
  if (!empty($task_ids)) {
185
  foreach ($task_ids as $task_id) {
186
  // abort if execution limit is reached
187
- $this->cron_helper->enforceExecutionLimit($this->timer);
188
 
189
- $this->migrateTaskSubscribers($task_id);
190
  }
191
  }
192
 
193
  return true;
194
  }
195
 
196
- function migrateTaskSubscribers($task_id) {
197
  global $wpdb;
198
 
199
  $migrated_unprocessed_count = ScheduledTaskSubscriber::getUnprocessedCount($task_id);
@@ -219,7 +215,7 @@ class Migration extends SimpleWorker {
219
  $subscribers_to_migrate = array_slice($subscribers['to_process'], $migrated_unprocessed_count);
220
  foreach ($subscribers_to_migrate as $sub_id) {
221
  // abort if execution limit is reached
222
- $this->cron_helper->enforceExecutionLimit($this->timer);
223
 
224
  ScheduledTaskSubscriber::createOrUpdate([
225
  'task_id' => $task_id,
@@ -233,7 +229,7 @@ class Migration extends SimpleWorker {
233
  $subscribers_to_migrate = array_slice($subscribers['processed'], $migrated_processed_count);
234
  foreach ($subscribers_to_migrate as $sub_id) {
235
  // abort if execution limit is reached
236
- $this->cron_helper->enforceExecutionLimit($this->timer);
237
 
238
  ScheduledTaskSubscriber::createOrUpdate([
239
  'task_id' => $task_id,
@@ -246,7 +242,7 @@ class Migration extends SimpleWorker {
246
  return true;
247
  }
248
 
249
- static function getNextRunDate($wp = null) {
250
  if (is_null($wp)) {
251
  $wp = new WPFunctions();
252
  }
11
  use MailPoet\Mailer\MailerLog;
12
  use MailPoet\Models\ScheduledTask;
13
  use MailPoet\Models\ScheduledTaskSubscriber;
14
+ use MailPoet\Models\SendingQueue as SendingQueueModel;
15
  use MailPoet\WP\Functions as WPFunctions;
16
 
17
  class Migration extends SimpleWorker {
20
 
21
  function checkProcessingRequirements() {
22
  // if migration was completed, don't run it again
23
+ $completed_tasks = $this->getCompletedTasks();
24
  return empty($completed_tasks);
25
  }
26
 
27
+ function prepareTaskStrategy(ScheduledTask $task, $timer) {
28
+ $unmigrated_columns = $this->checkUnmigratedColumnsExist();
29
  $unmigrated_queues_count = 0;
30
  $unmigrated_queue_subscribers = [];
31
 
46
 
47
  // pause sending while the migration is in process
48
  $this->pauseSending();
49
+ return true;
 
50
  }
51
 
52
  function pauseSending() {
76
  }
77
  }
78
 
79
+ function processTaskStrategy(ScheduledTask $task, $timer) {
80
+ $this->migrateSendingQueues($timer);
81
+ $this->migrateSubscribers($timer);
 
 
82
  $this->resumeSending();
 
83
  return true;
84
  }
85
 
86
+ private function checkUnmigratedColumnsExist() {
87
  global $wpdb;
88
+ $existing_columns = $wpdb->get_col('DESC ' . SendingQueueModel::$_table);
89
  return in_array('type', $existing_columns);
90
  }
91
 
92
  function getUnmigratedQueues() {
93
+ return SendingQueueModel::where('task_id', 0)
94
  ->whereNull('type');
95
  }
96
 
111
  /*
112
  * Migrate all sending queues without converting subscriber data
113
  */
114
+ function migrateSendingQueues($timer) {
115
  global $wpdb;
116
 
117
  $queues = $this->getUnmigratedQueues()
131
  if (!empty($queues)) {
132
  foreach (array_chunk($queues, self::BATCH_SIZE) as $queue_batch) {
133
  // abort if execution limit is reached
134
+ $this->cron_helper->enforceExecutionLimit($timer);
135
 
136
  foreach ($queue_batch as $queue) {
137
  // create a new scheduled task of type "sending"
161
  /*
162
  * Migrate subscribers for in-progress sending tasks from the `subscribers` field to a separate table
163
  */
164
+ function migrateSubscribers($timer) {
165
  global $wpdb;
166
 
167
  // find in-progress queues that have serialized subscribers
180
  if (!empty($task_ids)) {
181
  foreach ($task_ids as $task_id) {
182
  // abort if execution limit is reached
183
+ $this->cron_helper->enforceExecutionLimit($timer);
184
 
185
+ $this->migrateTaskSubscribers($task_id, $timer);
186
  }
187
  }
188
 
189
  return true;
190
  }
191
 
192
+ function migrateTaskSubscribers($task_id, $timer) {
193
  global $wpdb;
194
 
195
  $migrated_unprocessed_count = ScheduledTaskSubscriber::getUnprocessedCount($task_id);
215
  $subscribers_to_migrate = array_slice($subscribers['to_process'], $migrated_unprocessed_count);
216
  foreach ($subscribers_to_migrate as $sub_id) {
217
  // abort if execution limit is reached
218
+ $this->cron_helper->enforceExecutionLimit($timer);
219
 
220
  ScheduledTaskSubscriber::createOrUpdate([
221
  'task_id' => $task_id,
229
  $subscribers_to_migrate = array_slice($subscribers['processed'], $migrated_processed_count);
230
  foreach ($subscribers_to_migrate as $sub_id) {
231
  // abort if execution limit is reached
232
+ $this->cron_helper->enforceExecutionLimit($timer);
233
 
234
  ScheduledTaskSubscriber::createOrUpdate([
235
  'task_id' => $task_id,
242
  return true;
243
  }
244
 
245
+ function getNextRunDate($wp = null) {
246
  if (is_null($wp)) {
247
  $wp = new WPFunctions();
248
  }
lib/Cron/Workers/SendingQueue/SendingQueue.php CHANGED
@@ -28,7 +28,6 @@ use function MailPoet\Util\array_column;
28
  class SendingQueue {
29
  public $mailer_task;
30
  public $newsletter_task;
31
- public $timer;
32
  public $batch_size;
33
  const BATCH_SIZE = 20;
34
  const TASK_BATCH_SIZE = 5;
@@ -57,7 +56,6 @@ class SendingQueue {
57
  LoggerFactory $logger_factory,
58
  NewslettersRepository $newsletters_repository,
59
  CronHelper $cron_helper,
60
- $timer = false,
61
  $mailer_task = false,
62
  $newsletter_task = false
63
  ) {
@@ -65,7 +63,6 @@ class SendingQueue {
65
  $this->stats_notifications_scheduler = $stats_notifications_scheduler;
66
  $this->mailer_task = ($mailer_task) ? $mailer_task : new MailerTask();
67
  $this->newsletter_task = ($newsletter_task) ? $newsletter_task : new NewsletterTask();
68
- $this->timer = ($timer) ? $timer : microtime(true);
69
  $this->mailerMetaInfo = new MetaInfo;
70
  $wp = new WPFunctions;
71
  $this->batch_size = $wp->applyFilters('mailpoet_cron_worker_sending_queue_batch_size', self::BATCH_SIZE);
@@ -74,8 +71,9 @@ class SendingQueue {
74
  $this->cron_helper = $cron_helper;
75
  }
76
 
77
- function process() {
78
- $this->enforceSendingAndExecutionLimits();
 
79
  foreach (self::getRunningQueues() as $queue) {
80
  if (!$queue instanceof SendingTask) continue;
81
  ScheduledTaskModel::touchAllByIds([$queue->task_id]);
@@ -150,7 +148,8 @@ class SendingQueue {
150
  $queue = $this->processQueue(
151
  $queue,
152
  $_newsletter,
153
- $found_subscribers
 
154
  );
155
  $this->logger_factory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->addInfo(
156
  'after queue chunk processing',
@@ -164,12 +163,12 @@ class SendingQueue {
164
  $this->newsletter_task->markNewsletterAsSent($newsletter, $queue);
165
  $this->stats_notifications_scheduler->schedule($this->newsletters_repository->findOneById($newsletter->id));
166
  }
167
- $this->enforceSendingAndExecutionLimits();
168
  }
169
  }
170
  }
171
 
172
- function processQueue($queue, $newsletter, $subscribers) {
173
  // determine if processing is done in bulk or individually
174
  $processing_method = $this->mailer_task->getProcessingMethod();
175
  $prepared_newsletters = [];
@@ -207,6 +206,7 @@ class SendingQueue {
207
  $prepared_newsletters[0],
208
  $prepared_subscribers[0],
209
  $statistics[0],
 
210
  ['unsubscribe_url' => $unsubscribe_urls[0], 'meta' => $metas[0]]
211
  );
212
  $prepared_newsletters = [];
@@ -223,6 +223,7 @@ class SendingQueue {
223
  $prepared_newsletters,
224
  $prepared_subscribers,
225
  $statistics,
 
226
  ['unsubscribe_url' => $unsubscribe_urls, 'meta' => $metas]
227
  );
228
  }
@@ -231,7 +232,7 @@ class SendingQueue {
231
 
232
  function sendNewsletter(
233
  SendingTask $sending_task, $prepared_subscriber_id, $prepared_newsletter,
234
- $prepared_subscriber, $statistics, $extra_params = []
235
  ) {
236
  // send newsletter
237
  $send_result = $this->mailer_task->send(
@@ -244,13 +245,14 @@ class SendingQueue {
244
  $send_result,
245
  [$prepared_subscriber],
246
  [$prepared_subscriber_id],
247
- [$statistics]
 
248
  );
249
  }
250
 
251
  function sendNewsletters(
252
  SendingTask $sending_task, $prepared_subscribers_ids, $prepared_newsletters,
253
- $prepared_subscribers, $statistics, $extra_params = []
254
  ) {
255
  // send newsletters
256
  $send_result = $this->mailer_task->sendBulk(
@@ -263,7 +265,8 @@ class SendingQueue {
263
  $send_result,
264
  $prepared_subscribers,
265
  $prepared_subscribers_ids,
266
- $statistics
 
267
  );
268
  }
269
 
@@ -272,7 +275,8 @@ class SendingQueue {
272
  $send_result,
273
  array $prepared_subscribers,
274
  array $prepared_subscribers_ids,
275
- array $statistics
 
276
  ) {
277
  // log error message and schedule retry/pause sending
278
  if ($send_result['response'] === false) {
@@ -295,14 +299,14 @@ class SendingQueue {
295
  $this->mailer_task->updateSentCount();
296
  // enforce execution limits if queue is still being processed
297
  if ($sending_task->status !== ScheduledTaskModel::STATUS_COMPLETED) {
298
- $this->enforceSendingAndExecutionLimits();
299
  }
300
  return $sending_task;
301
  }
302
 
303
- function enforceSendingAndExecutionLimits() {
304
  // abort if execution limit is reached
305
- $this->cron_helper->enforceExecutionLimit($this->timer);
306
  // abort if sending limit has been reached
307
  MailerLog::enforceExecutionRequirements();
308
  }
28
  class SendingQueue {
29
  public $mailer_task;
30
  public $newsletter_task;
 
31
  public $batch_size;
32
  const BATCH_SIZE = 20;
33
  const TASK_BATCH_SIZE = 5;
56
  LoggerFactory $logger_factory,
57
  NewslettersRepository $newsletters_repository,
58
  CronHelper $cron_helper,
 
59
  $mailer_task = false,
60
  $newsletter_task = false
61
  ) {
63
  $this->stats_notifications_scheduler = $stats_notifications_scheduler;
64
  $this->mailer_task = ($mailer_task) ? $mailer_task : new MailerTask();
65
  $this->newsletter_task = ($newsletter_task) ? $newsletter_task : new NewsletterTask();
 
66
  $this->mailerMetaInfo = new MetaInfo;
67
  $wp = new WPFunctions;
68
  $this->batch_size = $wp->applyFilters('mailpoet_cron_worker_sending_queue_batch_size', self::BATCH_SIZE);
71
  $this->cron_helper = $cron_helper;
72
  }
73
 
74
+ function process($timer = false) {
75
+ $timer = $timer ?: microtime(true);
76
+ $this->enforceSendingAndExecutionLimits($timer);
77
  foreach (self::getRunningQueues() as $queue) {
78
  if (!$queue instanceof SendingTask) continue;
79
  ScheduledTaskModel::touchAllByIds([$queue->task_id]);
148
  $queue = $this->processQueue(
149
  $queue,
150
  $_newsletter,
151
+ $found_subscribers,
152
+ $timer
153
  );
154
  $this->logger_factory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->addInfo(
155
  'after queue chunk processing',
163
  $this->newsletter_task->markNewsletterAsSent($newsletter, $queue);
164
  $this->stats_notifications_scheduler->schedule($this->newsletters_repository->findOneById($newsletter->id));
165
  }
166
+ $this->enforceSendingAndExecutionLimits($timer);
167
  }
168
  }
169
  }
170
 
171
+ function processQueue($queue, $newsletter, $subscribers, $timer) {
172
  // determine if processing is done in bulk or individually
173
  $processing_method = $this->mailer_task->getProcessingMethod();
174
  $prepared_newsletters = [];
206
  $prepared_newsletters[0],
207
  $prepared_subscribers[0],
208
  $statistics[0],
209
+ $timer,
210
  ['unsubscribe_url' => $unsubscribe_urls[0], 'meta' => $metas[0]]
211
  );
212
  $prepared_newsletters = [];
223
  $prepared_newsletters,
224
  $prepared_subscribers,
225
  $statistics,
226
+ $timer,
227
  ['unsubscribe_url' => $unsubscribe_urls, 'meta' => $metas]
228
  );
229
  }
232
 
233
  function sendNewsletter(
234
  SendingTask $sending_task, $prepared_subscriber_id, $prepared_newsletter,
235
+ $prepared_subscriber, $statistics, $timer, $extra_params = []
236
  ) {
237
  // send newsletter
238
  $send_result = $this->mailer_task->send(
245
  $send_result,
246
  [$prepared_subscriber],
247
  [$prepared_subscriber_id],
248
+ [$statistics],
249
+ $timer
250
  );
251
  }
252
 
253
  function sendNewsletters(
254
  SendingTask $sending_task, $prepared_subscribers_ids, $prepared_newsletters,
255
+ $prepared_subscribers, $statistics, $timer, $extra_params = []
256
  ) {
257
  // send newsletters
258
  $send_result = $this->mailer_task->sendBulk(
265
  $send_result,
266
  $prepared_subscribers,
267
  $prepared_subscribers_ids,
268
+ $statistics,
269
+ $timer
270
  );
271
  }
272
 
275
  $send_result,
276
  array $prepared_subscribers,
277
  array $prepared_subscribers_ids,
278
+ array $statistics,
279
+ $timer
280
  ) {
281
  // log error message and schedule retry/pause sending
282
  if ($send_result['response'] === false) {
299
  $this->mailer_task->updateSentCount();
300
  // enforce execution limits if queue is still being processed
301
  if ($sending_task->status !== ScheduledTaskModel::STATUS_COMPLETED) {
302
+ $this->enforceSendingAndExecutionLimits($timer);
303
  }
304
  return $sending_task;
305
  }
306
 
307
+ function enforceSendingAndExecutionLimits($timer) {
308
  // abort if execution limit is reached
309
+ $this->cron_helper->enforceExecutionLimit($timer);
310
  // abort if sending limit has been reached
311
  MailerLog::enforceExecutionRequirements();
312
  }
lib/Cron/Workers/SimpleWorker.php CHANGED
@@ -7,12 +7,12 @@ if (!defined('ABSPATH')) exit;
7
 
8
  use Carbon\Carbon;
9
  use MailPoet\Cron\CronHelper;
 
10
  use MailPoet\DI\ContainerWrapper;
11
  use MailPoet\Models\ScheduledTask;
12
  use MailPoet\WP\Functions as WPFunctions;
13
 
14
  abstract class SimpleWorker {
15
- public $timer;
16
  private $wp;
17
  const TASK_TYPE = null;
18
  const TASK_BATCH_SIZE = 5;
@@ -25,15 +25,17 @@ abstract class SimpleWorker {
25
  /** @var CronHelper */
26
  protected $cron_helper;
27
 
28
- function __construct($timer = false) {
 
 
 
29
  if (static::TASK_TYPE === null) {
30
  throw new \Exception('Constant TASK_TYPE is not defined on subclass ' . get_class($this));
31
  }
32
- $this->timer = ($timer) ? $timer : microtime(true);
33
- // abort if execution limit is reached
34
- $this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
35
- $this->cron_helper->enforceExecutionLimit($this->timer);
36
  $this->wp = new WPFunctions();
 
 
37
  }
38
 
39
  function checkProcessingRequirements() {
@@ -43,19 +45,27 @@ abstract class SimpleWorker {
43
  function init() {
44
  }
45
 
46
- function process() {
 
 
 
 
 
 
 
47
  if (!$this->checkProcessingRequirements()) {
 
 
 
48
  return false;
49
  }
50
 
51
  $this->init();
52
 
53
- $scheduled_tasks = self::getScheduledTasks();
54
- $running_tasks = self::getRunningTasks();
55
 
56
  if (!$scheduled_tasks && !$running_tasks) {
57
  if (static::AUTOMATIC_SCHEDULING) {
58
- self::schedule();
59
  }
60
  return false;
61
  }
@@ -63,10 +73,10 @@ abstract class SimpleWorker {
63
  $task = null;
64
  try {
65
  foreach ($scheduled_tasks as $i => $task) {
66
- $this->prepareTask($task);
67
  }
68
  foreach ($running_tasks as $i => $task) {
69
- $this->processTask($task);
70
  }
71
  } catch (\Exception $e) {
72
  if ($task && $e->getCode() !== CronHelper::DAEMON_EXECUTION_LIMIT_REACHED) {
@@ -78,36 +88,24 @@ abstract class SimpleWorker {
78
  return true;
79
  }
80
 
81
- static function schedule() {
82
- $already_scheduled = ScheduledTask::where('type', static::TASK_TYPE)
83
- ->whereNull('deleted_at')
84
- ->where('status', ScheduledTask::STATUS_SCHEDULED)
85
- ->findMany();
86
- if ($already_scheduled) {
87
- return false;
88
- }
89
- $task = ScheduledTask::create();
90
- $task->type = static::TASK_TYPE;
91
- $task->status = ScheduledTask::STATUS_SCHEDULED;
92
- $task->priority = ScheduledTask::PRIORITY_LOW;
93
- $task->scheduled_at = static::getNextRunDate();
94
- $task->save();
95
- return $task;
96
  }
97
 
98
- function prepareTask(ScheduledTask $task) {
99
- $task->status = null;
100
- $task->save();
101
-
102
  // abort if execution limit is reached
103
- $this->cron_helper->enforceExecutionLimit($this->timer);
104
 
105
- return true;
 
 
 
 
106
  }
107
 
108
- function processTask(ScheduledTask $task) {
109
  // abort if execution limit is reached
110
- $this->cron_helper->enforceExecutionLimit($this->timer);
111
 
112
  if (!static::SUPPORT_MULTIPLE_INSTANCES) {
113
  if ($this->rescheduleOutdated($task)) {
@@ -121,7 +119,7 @@ abstract class SimpleWorker {
121
  $this->startProgress($task);
122
 
123
  try {
124
- $completed = $this->processTaskStrategy($task);
125
  } catch (\Exception $e) {
126
  $this->stopProgress($task);
127
  throw $e;
@@ -136,7 +134,11 @@ abstract class SimpleWorker {
136
  return (bool)$completed;
137
  }
138
 
139
- function processTaskStrategy(ScheduledTask $task) {
 
 
 
 
140
  return true;
141
  }
142
 
@@ -147,11 +149,7 @@ abstract class SimpleWorker {
147
  }
148
 
149
  function reschedule(ScheduledTask $task, $timeout) {
150
- $scheduled_at = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
151
- $task->scheduled_at = $scheduled_at->addMinutes($timeout);
152
- $task->setExpr('updated_at', 'NOW()');
153
- $task->status = ScheduledTask::STATUS_SCHEDULED;
154
- $task->save();
155
  }
156
 
157
  private function isInProgress(ScheduledTask $task) {
@@ -186,7 +184,7 @@ abstract class SimpleWorker {
186
  return false;
187
  }
188
 
189
- static function getNextRunDate() {
190
  $wp = new WPFunctions();
191
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
192
  // Random day of the next week
@@ -195,42 +193,15 @@ abstract class SimpleWorker {
195
  return $date;
196
  }
197
 
198
- /**
199
- * @param bool $future
200
- * @return ScheduledTask[]
201
- */
202
- static function getScheduledTasks($future = false) {
203
- $dateWhere = ($future) ? 'whereGt' : 'whereLte';
204
- $wp = new WPFunctions();
205
- return ScheduledTask::where('type', static::TASK_TYPE)
206
- ->$dateWhere('scheduled_at', Carbon::createFromTimestamp($wp->currentTime('timestamp')))
207
- ->whereNull('deleted_at')
208
- ->where('status', ScheduledTask::STATUS_SCHEDULED)
209
- ->limit(self::TASK_BATCH_SIZE)
210
- ->findMany();
211
  }
212
 
213
- static function getRunningTasks() {
214
- $wp = new WPFunctions();
215
- return ScheduledTask::where('type', static::TASK_TYPE)
216
- ->whereLte('scheduled_at', Carbon::createFromTimestamp($wp->currentTime('timestamp')))
217
- ->whereNull('deleted_at')
218
- ->whereNull('status')
219
- ->limit(self::TASK_BATCH_SIZE)
220
- ->findMany();
221
- }
222
-
223
- static function getDueTasks() {
224
- $scheduled_tasks = self::getScheduledTasks();
225
- $running_tasks = self::getRunningTasks();
226
- return array_merge((array)$scheduled_tasks, (array)$running_tasks);
227
- }
228
-
229
- static function getCompletedTasks() {
230
- return ScheduledTask::where('type', static::TASK_TYPE)
231
- ->whereNull('deleted_at')
232
- ->where('status', ScheduledTask::STATUS_COMPLETED)
233
- ->limit(self::TASK_BATCH_SIZE)
234
- ->findMany();
235
  }
236
  }
7
 
8
  use Carbon\Carbon;
9
  use MailPoet\Cron\CronHelper;
10
+ use MailPoet\Cron\CronWorkerScheduler;
11
  use MailPoet\DI\ContainerWrapper;
12
  use MailPoet\Models\ScheduledTask;
13
  use MailPoet\WP\Functions as WPFunctions;
14
 
15
  abstract class SimpleWorker {
 
16
  private $wp;
17
  const TASK_TYPE = null;
18
  const TASK_BATCH_SIZE = 5;
25
  /** @var CronHelper */
26
  protected $cron_helper;
27
 
28
+ /** @var CronWorkerScheduler */
29
+ protected $cron_worker_scheduler;
30
+
31
+ function __construct() {
32
  if (static::TASK_TYPE === null) {
33
  throw new \Exception('Constant TASK_TYPE is not defined on subclass ' . get_class($this));
34
  }
35
+
 
 
 
36
  $this->wp = new WPFunctions();
37
+ $this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
38
+ $this->cron_worker_scheduler = ContainerWrapper::getInstance()->get(CronWorkerScheduler::class);
39
  }
40
 
41
  function checkProcessingRequirements() {
45
  function init() {
46
  }
47
 
48
+ function process($timer = false) {
49
+ $timer = $timer ?: microtime(true);
50
+
51
+ // abort if execution limit is reached
52
+ $this->cron_helper->enforceExecutionLimit($timer);
53
+ $scheduled_tasks = $this->getDueTasks();
54
+ $running_tasks = $this->getRunningTasks();
55
+
56
  if (!$this->checkProcessingRequirements()) {
57
+ foreach (array_merge($scheduled_tasks, $running_tasks) as $task) {
58
+ $task->delete();
59
+ }
60
  return false;
61
  }
62
 
63
  $this->init();
64
 
 
 
65
 
66
  if (!$scheduled_tasks && !$running_tasks) {
67
  if (static::AUTOMATIC_SCHEDULING) {
68
+ $this->schedule();
69
  }
70
  return false;
71
  }
73
  $task = null;
74
  try {
75
  foreach ($scheduled_tasks as $i => $task) {
76
+ $this->prepareTask($task, $timer);
77
  }
78
  foreach ($running_tasks as $i => $task) {
79
+ $this->processTask($task, $timer);
80
  }
81
  } catch (\Exception $e) {
82
  if ($task && $e->getCode() !== CronHelper::DAEMON_EXECUTION_LIMIT_REACHED) {
88
  return true;
89
  }
90
 
91
+ function schedule() {
92
+ $this->cron_worker_scheduler->schedule(static::TASK_TYPE, static::getNextRunDate());
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
+ function prepareTask(ScheduledTask $task, $timer) {
 
 
 
96
  // abort if execution limit is reached
97
+ $this->cron_helper->enforceExecutionLimit($timer);
98
 
99
+ $prepare_completed = $this->prepareTaskStrategy($task, $timer);
100
+ if ($prepare_completed) {
101
+ $task->status = null;
102
+ $task->save();
103
+ }
104
  }
105
 
106
+ function processTask(ScheduledTask $task, $timer) {
107
  // abort if execution limit is reached
108
+ $this->cron_helper->enforceExecutionLimit($timer);
109
 
110
  if (!static::SUPPORT_MULTIPLE_INSTANCES) {
111
  if ($this->rescheduleOutdated($task)) {
119
  $this->startProgress($task);
120
 
121
  try {
122
+ $completed = $this->processTaskStrategy($task, $timer);
123
  } catch (\Exception $e) {
124
  $this->stopProgress($task);
125
  throw $e;
134
  return (bool)$completed;
135
  }
136
 
137
+ function prepareTaskStrategy(ScheduledTask $task, $timer) {
138
+ return true;
139
+ }
140
+
141
+ function processTaskStrategy(ScheduledTask $task, $timer) {
142
  return true;
143
  }
144
 
149
  }
150
 
151
  function reschedule(ScheduledTask $task, $timeout) {
152
+ $this->cron_worker_scheduler->reschedule($task, $timeout);
 
 
 
 
153
  }
154
 
155
  private function isInProgress(ScheduledTask $task) {
184
  return false;
185
  }
186
 
187
+ function getNextRunDate() {
188
  $wp = new WPFunctions();
189
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
190
  // Random day of the next week
193
  return $date;
194
  }
195
 
196
+ function getDueTasks() {
197
+ return ScheduledTask::findDueByType(static::TASK_TYPE, self::TASK_BATCH_SIZE);
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
+ function getRunningTasks() {
201
+ return ScheduledTask::findRunningByType(static::TASK_TYPE, self::TASK_BATCH_SIZE);
202
+ }
203
+
204
+ function getCompletedTasks() {
205
+ return ScheduledTask::findCompletedByType(static::TASK_TYPE, self::TASK_BATCH_SIZE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
  }
lib/Cron/Workers/StatsNotifications/AutomatedEmails.php CHANGED
@@ -34,9 +34,6 @@ class AutomatedEmails extends SimpleWorker {
34
  /** @var MetaInfo */
35
  private $mailerMetaInfo;
36
 
37
- /** @var float */
38
- public $timer;
39
-
40
  /** @var NewslettersRepository */
41
  private $repository;
42
 
@@ -49,15 +46,13 @@ class AutomatedEmails extends SimpleWorker {
49
  SettingsController $settings,
50
  NewslettersRepository $repository,
51
  NewsletterStatisticsRepository $newsletter_statistics_repository,
52
- MetaInfo $mailerMetaInfo,
53
- $timer = false
54
  ) {
55
- parent::__construct($timer);
56
  $this->mailer = $mailer;
57
  $this->settings = $settings;
58
  $this->renderer = $renderer;
59
  $this->mailerMetaInfo = $mailerMetaInfo;
60
- $this->timer = $timer ?: microtime(true);
61
  $this->repository = $repository;
62
  $this->newsletter_statistics_repository = $newsletter_statistics_repository;
63
  }
@@ -82,7 +77,7 @@ class AutomatedEmails extends SimpleWorker {
82
  return (bool)$settings['automated'];
83
  }
84
 
85
- function processTaskStrategy(ScheduledTask $task) {
86
  try {
87
  $settings = $this->settings->get(Worker::SETTINGS_KEY);
88
  $newsletters = $this->getNewsletters();
@@ -155,7 +150,7 @@ class AutomatedEmails extends SimpleWorker {
155
  return $context;
156
  }
157
 
158
- static function getNextRunDate() {
159
  $wp = new WPFunctions;
160
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
161
  return $date->endOfMonth()->next(Carbon::MONDAY)->midDay();
34
  /** @var MetaInfo */
35
  private $mailerMetaInfo;
36
 
 
 
 
37
  /** @var NewslettersRepository */
38
  private $repository;
39
 
46
  SettingsController $settings,
47
  NewslettersRepository $repository,
48
  NewsletterStatisticsRepository $newsletter_statistics_repository,
49
+ MetaInfo $mailerMetaInfo
 
50
  ) {
51
+ parent::__construct();
52
  $this->mailer = $mailer;
53
  $this->settings = $settings;
54
  $this->renderer = $renderer;
55
  $this->mailerMetaInfo = $mailerMetaInfo;
 
56
  $this->repository = $repository;
57
  $this->newsletter_statistics_repository = $newsletter_statistics_repository;
58
  }
77
  return (bool)$settings['automated'];
78
  }
79
 
80
+ function processTaskStrategy(ScheduledTask $task, $timer) {
81
  try {
82
  $settings = $this->settings->get(Worker::SETTINGS_KEY);
83
  $newsletters = $this->getNewsletters();
150
  return $context;
151
  }
152
 
153
+ function getNextRunDate() {
154
  $wp = new WPFunctions;
155
  $date = Carbon::createFromTimestamp($wp->currentTime('timestamp'));
156
  return $date->endOfMonth()->next(Carbon::MONDAY)->midDay();
lib/Cron/Workers/StatsNotifications/Worker.php CHANGED
@@ -27,9 +27,6 @@ class Worker {
27
  const TASK_TYPE = 'stats_notification';
28
  const SETTINGS_KEY = 'stats_notifications';
29
 
30
- /** @var float */
31
- public $timer;
32
-
33
  /** @var Renderer */
34
  private $renderer;
35
 
@@ -66,10 +63,8 @@ class Worker {
66
  StatsNotificationsRepository $repository,
67
  NewsletterLinkRepository $newsletter_link_repository,
68
  NewsletterStatisticsRepository $newsletter_statistics_repository,
69
- EntityManager $entity_manager,
70
- $timer = false
71
  ) {
72
- $this->timer = $timer ?: microtime(true);
73
  $this->renderer = $renderer;
74
  $this->mailer = $mailer;
75
  $this->settings = $settings;
@@ -82,7 +77,8 @@ class Worker {
82
  }
83
 
84
  /** @throws \Exception */
85
- function process() {
 
86
  $settings = $this->settings->get(self::SETTINGS_KEY);
87
  foreach ($this->repository->findScheduled(Sending::RESULT_BATCH_SIZE) as $stats_notification_entity) {
88
  try {
@@ -97,13 +93,13 @@ class Worker {
97
  } finally {
98
  $this->markTaskAsFinished($stats_notification_entity->getTask());
99
  }
100
- $this->cron_helper->enforceExecutionLimit($this->timer);
101
  }
102
  }
103
 
104
  private function constructNewsletter(StatsNotificationEntity $stats_notification_entity) {
105
  $newsletter = $stats_notification_entity->getNewsletter();
106
- $link = $this->newsletter_link_repository->findTopLinkForNewsletter($newsletter->getId());
107
  $context = $this->prepareContext($newsletter, $link);
108
  $subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
109
  return [
27
  const TASK_TYPE = 'stats_notification';
28
  const SETTINGS_KEY = 'stats_notifications';
29
 
 
 
 
30
  /** @var Renderer */
31
  private $renderer;
32
 
63
  StatsNotificationsRepository $repository,
64
  NewsletterLinkRepository $newsletter_link_repository,
65
  NewsletterStatisticsRepository $newsletter_statistics_repository,
66
+ EntityManager $entity_manager
 
67
  ) {
 
68
  $this->renderer = $renderer;
69
  $this->mailer = $mailer;
70
  $this->settings = $settings;
77
  }
78
 
79
  /** @throws \Exception */
80
+ function process($timer = false) {
81
+ $timer = $timer ?: microtime(true);
82
  $settings = $this->settings->get(self::SETTINGS_KEY);
83
  foreach ($this->repository->findScheduled(Sending::RESULT_BATCH_SIZE) as $stats_notification_entity) {
84
  try {
93
  } finally {
94
  $this->markTaskAsFinished($stats_notification_entity->getTask());
95
  }
96
+ $this->cron_helper->enforceExecutionLimit($timer);
97
  }
98
  }
99
 
100
  private function constructNewsletter(StatsNotificationEntity $stats_notification_entity) {
101
  $newsletter = $stats_notification_entity->getNewsletter();
102
+ $link = $this->newsletter_link_repository->findTopLinkForNewsletter((int)$newsletter->getId());
103
  $context = $this->prepareContext($newsletter, $link);
104
  $subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
105
  return [
lib/Cron/Workers/SubscriberLinkTokens.php CHANGED
@@ -17,7 +17,7 @@ class SubscriberLinkTokens extends SimpleWorker {
17
  const BATCH_SIZE = 10000;
18
  const AUTOMATIC_SCHEDULING = false;
19
 
20
- function processTaskStrategy(ScheduledTask $task) {
21
  $count = Subscriber::whereNull('link_token')->count();
22
  if ($count) {
23
  $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
@@ -25,12 +25,12 @@ class SubscriberLinkTokens extends SimpleWorker {
25
  sprintf('UPDATE %s SET link_token = SUBSTRING(MD5(CONCAT(?, email)), 1, ?) WHERE link_token IS NULL LIMIT ?', Subscriber::$_table),
26
  [$auth_key, Subscriber::OBSOLETE_LINK_TOKEN_LENGTH, self::BATCH_SIZE]
27
  );
28
- self::schedule();
29
  }
30
  return true;
31
  }
32
 
33
- static function getNextRunDate() {
34
  $wp = new WPFunctions();
35
  return Carbon::createFromTimestamp($wp->currentTime('timestamp'));
36
  }
17
  const BATCH_SIZE = 10000;
18
  const AUTOMATIC_SCHEDULING = false;
19
 
20
+ function processTaskStrategy(ScheduledTask $task, $timer) {
21
  $count = Subscriber::whereNull('link_token')->count();
22
  if ($count) {
23
  $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
25
  sprintf('UPDATE %s SET link_token = SUBSTRING(MD5(CONCAT(?, email)), 1, ?) WHERE link_token IS NULL LIMIT ?', Subscriber::$_table),
26
  [$auth_key, Subscriber::OBSOLETE_LINK_TOKEN_LENGTH, self::BATCH_SIZE]
27
  );
28
+ $this->schedule();
29
  }
30
  return true;
31
  }
32
 
33
+ function getNextRunDate() {
34
  $wp = new WPFunctions();
35
  return Carbon::createFromTimestamp($wp->currentTime('timestamp'));
36
  }
lib/Cron/Workers/UnsubscribeTokens.php CHANGED
@@ -18,16 +18,16 @@ class UnsubscribeTokens extends SimpleWorker {
18
  const BATCH_SIZE = 1000;
19
  const AUTOMATIC_SCHEDULING = false;
20
 
21
- function processTaskStrategy(ScheduledTask $task) {
22
  $meta = $task->getMeta();
23
  do {
24
- $this->cron_helper->enforceExecutionLimit($this->timer);
25
  $subscribers_count = $this->addTokens(Subscriber::class, $meta['last_subscriber_id']);
26
  $task->meta = $meta;
27
  $task->save();
28
  } while ($subscribers_count === self::BATCH_SIZE);
29
  do {
30
- $this->cron_helper->enforceExecutionLimit($this->timer);
31
  $newsletters_count = $this->addTokens(Newsletter::class, $meta['last_newsletter_id']);
32
  $task->meta = $meta;
33
  $task->save();
@@ -52,7 +52,7 @@ class UnsubscribeTokens extends SimpleWorker {
52
  return count($instances);
53
  }
54
 
55
- static function getNextRunDate() {
56
  $wp = new WPFunctions;
57
  return Carbon::createFromTimestamp($wp->currentTime('timestamp'));
58
  }
18
  const BATCH_SIZE = 1000;
19
  const AUTOMATIC_SCHEDULING = false;
20
 
21
+ function processTaskStrategy(ScheduledTask $task, $timer) {
22
  $meta = $task->getMeta();
23
  do {
24
+ $this->cron_helper->enforceExecutionLimit($timer);
25
  $subscribers_count = $this->addTokens(Subscriber::class, $meta['last_subscriber_id']);
26
  $task->meta = $meta;
27
  $task->save();
28
  } while ($subscribers_count === self::BATCH_SIZE);
29
  do {
30
+ $this->cron_helper->enforceExecutionLimit($timer);
31
  $newsletters_count = $this->addTokens(Newsletter::class, $meta['last_newsletter_id']);
32
  $task->meta = $meta;
33
  $task->save();
52
  return count($instances);
53
  }
54
 
55
+ function getNextRunDate() {
56
  $wp = new WPFunctions;
57
  return Carbon::createFromTimestamp($wp->currentTime('timestamp'));
58
  }
lib/Cron/Workers/WooCommercePastOrders.php CHANGED
@@ -25,21 +25,20 @@ class WooCommercePastOrders extends SimpleWorker {
25
 
26
  function __construct(
27
  WCHelper $woocommerce_helper,
28
- WooCommercePurchases $woocommerce_purchases,
29
- $timer = false
30
  ) {
31
  $this->woocommerce_helper = $woocommerce_helper;
32
  $this->woocommerce_purchases = $woocommerce_purchases;
33
- parent::__construct($timer);
34
  }
35
 
36
  function checkProcessingRequirements() {
37
- return $this->woocommerce_helper->isWooCommerceActive() && empty(self::getCompletedTasks()); // run only once
38
  }
39
 
40
- function processTaskStrategy(ScheduledTask $task) {
41
  $oldest_click = StatisticsClicks::orderByAsc('created_at')->limit(1)->findOne();
42
- if (!$oldest_click) {
43
  return true;
44
  }
45
 
@@ -74,7 +73,7 @@ class WooCommercePastOrders extends SimpleWorker {
74
  return false;
75
  }
76
 
77
- static function getNextRunDate() {
78
  return Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp')); // schedule immediately
79
  }
80
  }
25
 
26
  function __construct(
27
  WCHelper $woocommerce_helper,
28
+ WooCommercePurchases $woocommerce_purchases
 
29
  ) {
30
  $this->woocommerce_helper = $woocommerce_helper;
31
  $this->woocommerce_purchases = $woocommerce_purchases;
32
+ parent::__construct();
33
  }
34
 
35
  function checkProcessingRequirements() {
36
+ return $this->woocommerce_helper->isWooCommerceActive() && empty($this->getCompletedTasks()); // run only once
37
  }
38
 
39
+ function processTaskStrategy(ScheduledTask $task, $timer) {
40
  $oldest_click = StatisticsClicks::orderByAsc('created_at')->limit(1)->findOne();
41
+ if (!$oldest_click instanceof StatisticsClicks) {
42
  return true;
43
  }
44
 
73
  return false;
74
  }
75
 
76
+ function getNextRunDate() {
77
  return Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp')); // schedule immediately
78
  }
79
  }
lib/Cron/Workers/WooCommerceSync.php CHANGED
@@ -21,22 +21,18 @@ class WooCommerceSync extends SimpleWorker {
21
  /** @var WooCommerceHelper */
22
  private $woocommerce_helper;
23
 
24
- function __construct(WooCommerceSegment $woocommerce_segment, WooCommerceHelper $woocommerce_helper, $timer = false) {
25
  $this->woocommerce_segment = $woocommerce_segment;
26
  $this->woocommerce_helper = $woocommerce_helper;
27
- parent::__construct($timer);
28
  }
29
 
30
  function checkProcessingRequirements() {
31
  return $this->woocommerce_helper->isWooCommerceActive();
32
  }
33
 
34
- function processTaskStrategy(ScheduledTask $task) {
35
  $this->woocommerce_segment->synchronizeCustomers();
36
  return true;
37
  }
38
-
39
- function complete(ScheduledTask $task) {
40
- return parent::complete($task);
41
- }
42
  }
21
  /** @var WooCommerceHelper */
22
  private $woocommerce_helper;
23
 
24
+ function __construct(WooCommerceSegment $woocommerce_segment, WooCommerceHelper $woocommerce_helper) {
25
  $this->woocommerce_segment = $woocommerce_segment;
26
  $this->woocommerce_helper = $woocommerce_helper;
27
+ parent::__construct();
28
  }
29
 
30
  function checkProcessingRequirements() {
31
  return $this->woocommerce_helper->isWooCommerceActive();
32
  }
33
 
34
+ function processTaskStrategy(ScheduledTask $task, $timer) {
35
  $this->woocommerce_segment->synchronizeCustomers();
36
  return true;
37
  }
 
 
 
 
38
  }
lib/Cron/Workers/WorkersFactory.php CHANGED
@@ -5,242 +5,102 @@ namespace MailPoet\Cron\Workers;
5
  if (!defined('ABSPATH')) exit;
6
 
7
 
8
- use MailPoet\Config\Renderer;
9
- use MailPoet\Cron\CronHelper;
10
  use MailPoet\Cron\Workers\Bounce as BounceWorker;
11
  use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck as PremiumKeyCheckWorker;
12
  use MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck as SendingServiceKeyCheckWorker;
13
  use MailPoet\Cron\Workers\Scheduler as SchedulerWorker;
14
  use MailPoet\Cron\Workers\SendingQueue\Migration as MigrationWorker;
15
- use MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler;
16
  use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
17
  use MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails as StatsNotificationsWorkerForAutomatedEmails;
18
- use MailPoet\Cron\Workers\StatsNotifications\NewsletterLinkRepository;
19
- use MailPoet\Cron\Workers\StatsNotifications\Scheduler as StatsNotificationScheduler;
20
- use MailPoet\Cron\Workers\StatsNotifications\StatsNotificationsRepository;
21
  use MailPoet\Cron\Workers\StatsNotifications\Worker as StatsNotificationsWorker;
22
  use MailPoet\Cron\Workers\WooCommerceSync as WooCommerceSyncWorker;
23
- use MailPoet\Logging\LoggerFactory;
24
- use MailPoet\Mailer\Mailer;
25
- use MailPoet\Mailer\MetaInfo;
26
- use MailPoet\Newsletter\NewslettersRepository;
27
- use MailPoet\Newsletter\Statistics\NewsletterStatisticsRepository;
28
- use MailPoet\Segments\SubscribersFinder;
29
- use MailPoet\Segments\WooCommerce as WooCommerceSegment;
30
- use MailPoet\Services\AuthorizedEmailsController;
31
- use MailPoet\Settings\SettingsController;
32
- use MailPoet\Statistics\Track\WooCommercePurchases;
33
- use MailPoet\Subscribers\InactiveSubscribersController;
34
- use MailPoet\WooCommerce\Helper as WooCommerceHelper;
35
- use MailPoet\WP\Functions as WPFunctions;
36
- use MailPoetVendor\Doctrine\ORM\EntityManager;
37
 
38
  class WorkersFactory {
 
 
39
 
40
- /** @var SendingErrorHandler */
41
- private $sending_error_handler;
42
-
43
- /** @var StatsNotificationScheduler */
44
- private $statsNotificationsScheduler;
45
-
46
- /** @var Mailer */
47
- private $mailer;
48
-
49
- /** @var SettingsController */
50
- private $settings;
51
-
52
- /** @var CronHelper */
53
- private $cron_helper;
54
-
55
- /** @var WooCommerceSegment */
56
- private $woocommerce_segment;
57
-
58
- /** @var InactiveSubscribersController */
59
- private $inactive_subscribers_controller;
60
-
61
- /** @var WooCommerceHelper */
62
- private $woocommerce_helper;
63
-
64
- /** @var WooCommercePurchases */
65
- private $woocommerce_purchases;
66
-
67
- /** @var AuthorizedEmailsController */
68
- private $authorized_emails_controller;
69
-
70
- /** @var Renderer */
71
- private $renderer;
72
-
73
- /** @var SubscribersFinder */
74
- private $subscribers_finder;
75
-
76
- /** @var MetaInfo */
77
- private $mailerMetaInfo;
78
-
79
- /** @var LoggerFactory */
80
- private $logger_factory;
81
-
82
- /** @var StatsNotificationsRepository */
83
- private $stats_notifications_repository;
84
-
85
- /** @var EntityManager */
86
- private $entity_manager;
87
-
88
- /**
89
- * @var NewslettersRepository
90
- */
91
- private $newsletters_repository;
92
-
93
- /** @var NewsletterLinkRepository */
94
- private $newsletter_link_repository;
95
-
96
- /** @var NewsletterStatisticsRepository */
97
- private $newsletter_statistics_repository;
98
-
99
- public function __construct(
100
- SendingErrorHandler $sending_error_handler,
101
- StatsNotificationScheduler $statsNotificationsScheduler,
102
- Mailer $mailer,
103
- Renderer $renderer,
104
- SettingsController $settings,
105
- CronHelper $cron_helper,
106
- WooCommerceSegment $woocommerce_segment,
107
- InactiveSubscribersController $inactive_subscribers_controller,
108
- WooCommerceHelper $woocommerce_helper,
109
- WooCommercePurchases $woocommerce_purchases,
110
- AuthorizedEmailsController $authorized_emails_controller,
111
- SubscribersFinder $subscribers_finder,
112
- MetaInfo $mailerMetaInfo,
113
- LoggerFactory $logger_factory,
114
- StatsNotificationsRepository $stats_notifications_repository,
115
- NewslettersRepository $newsletters_repository,
116
- NewsletterLinkRepository $newsletter_link_repository,
117
- NewsletterStatisticsRepository $newsletter_statistics_repository,
118
- EntityManager $entity_manager
119
- ) {
120
- $this->sending_error_handler = $sending_error_handler;
121
- $this->statsNotificationsScheduler = $statsNotificationsScheduler;
122
- $this->mailer = $mailer;
123
- $this->renderer = $renderer;
124
- $this->settings = $settings;
125
- $this->cron_helper = $cron_helper;
126
- $this->woocommerce_segment = $woocommerce_segment;
127
- $this->inactive_subscribers_controller = $inactive_subscribers_controller;
128
- $this->woocommerce_helper = $woocommerce_helper;
129
- $this->woocommerce_purchases = $woocommerce_purchases;
130
- $this->authorized_emails_controller = $authorized_emails_controller;
131
- $this->subscribers_finder = $subscribers_finder;
132
- $this->mailerMetaInfo = $mailerMetaInfo;
133
- $this->logger_factory = $logger_factory;
134
- $this->stats_notifications_repository = $stats_notifications_repository;
135
- $this->entity_manager = $entity_manager;
136
- $this->newsletters_repository = $newsletters_repository;
137
- $this->newsletter_link_repository = $newsletter_link_repository;
138
- $this->newsletter_statistics_repository = $newsletter_statistics_repository;
139
  }
140
 
141
  /** @return SchedulerWorker */
142
- function createScheduleWorker($timer) {
143
- return new SchedulerWorker($this->subscribers_finder, $this->logger_factory, $this->cron_helper, $timer);
144
  }
145
 
146
  /** @return SendingQueueWorker */
147
- function createQueueWorker($timer) {
148
- return new SendingQueueWorker(
149
- $this->sending_error_handler,
150
- $this->statsNotificationsScheduler,
151
- $this->logger_factory,
152
- $this->newsletters_repository,
153
- $this->cron_helper,
154
- $timer
155
- );
156
  }
157
 
158
  /** @return StatsNotificationsWorker */
159
- function createStatsNotificationsWorker($timer) {
160
- return new StatsNotificationsWorker(
161
- $this->mailer,
162
- $this->renderer,
163
- $this->settings,
164
- $this->cron_helper,
165
- $this->mailerMetaInfo,
166
- $this->stats_notifications_repository,
167
- $this->newsletter_link_repository,
168
- $this->newsletter_statistics_repository,
169
- $this->entity_manager,
170
- $timer
171
- );
172
  }
173
 
174
  /** @return StatsNotificationsWorkerForAutomatedEmails */
175
- function createStatsNotificationsWorkerForAutomatedEmails($timer) {
176
- return new StatsNotificationsWorkerForAutomatedEmails(
177
- $this->mailer,
178
- $this->renderer,
179
- $this->settings,
180
- $this->newsletters_repository,
181
- $this->newsletter_statistics_repository,
182
- $this->mailerMetaInfo,
183
- $timer
184
- );
185
  }
186
 
187
  /** @return SendingServiceKeyCheckWorker */
188
- function createSendingServiceKeyCheckWorker($timer) {
189
- return new SendingServiceKeyCheckWorker($this->settings, $timer);
190
  }
191
 
192
  /** @return PremiumKeyCheckWorker */
193
- function createPremiumKeyCheckWorker($timer) {
194
- return new PremiumKeyCheckWorker($this->settings, $timer);
195
  }
196
 
197
  /** @return BounceWorker */
198
- function createBounceWorker($timer) {
199
- return new BounceWorker($this->settings, $timer);
200
  }
201
 
202
  /** @return MigrationWorker */
203
- function createMigrationWorker($timer) {
204
- return new MigrationWorker($timer);
205
  }
206
 
207
  /** @return WooCommerceSyncWorker */
208
- function createWooCommerceSyncWorker($timer) {
209
- return new WooCommerceSyncWorker($this->woocommerce_segment, $this->woocommerce_helper, $timer);
210
  }
211
 
212
  /** @return ExportFilesCleanup */
213
- function createExportFilesCleanupWorker($timer) {
214
- return new ExportFilesCleanup($timer);
215
  }
216
 
217
  /** @return Beamer */
218
- function createBeamerkWorker($timer) {
219
- return new Beamer($this->settings, WPFunctions::get(), $timer);
220
  }
221
 
222
  /** @return InactiveSubscribers */
223
- function createInactiveSubscribersWorker($timer) {
224
- return new InactiveSubscribers($this->inactive_subscribers_controller, $this->settings, $timer);
225
  }
226
 
227
- /** @return UnsubscribeTokens */
228
- function createUnsubscribeTokensWorker($timer) {
229
- return new UnsubscribeTokens($timer);
230
  }
231
 
232
- /** @return SubscriberLinkTokens */
233
- function createSubscriberLinkTokensWorker($timer) {
234
- return new SubscriberLinkTokens($timer);
235
  }
236
 
237
  /** @return AuthorizedSendingEmailsCheck */
238
- function createAuthorizedSendingEmailsCheckWorker($timer) {
239
- return new AuthorizedSendingEmailsCheck($this->authorized_emails_controller, $timer);
240
  }
241
 
242
  /** @return WooCommercePastOrders */
243
- function createWooCommercePastOrdersWorker($timer) {
244
- return new WooCommercePastOrders($this->woocommerce_helper, $this->woocommerce_purchases, $timer);
245
  }
246
  }
5
  if (!defined('ABSPATH')) exit;
6
 
7
 
 
 
8
  use MailPoet\Cron\Workers\Bounce as BounceWorker;
9
  use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck as PremiumKeyCheckWorker;
10
  use MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck as SendingServiceKeyCheckWorker;
11
  use MailPoet\Cron\Workers\Scheduler as SchedulerWorker;
12
  use MailPoet\Cron\Workers\SendingQueue\Migration as MigrationWorker;
 
13
  use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
14
  use MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails as StatsNotificationsWorkerForAutomatedEmails;
 
 
 
15
  use MailPoet\Cron\Workers\StatsNotifications\Worker as StatsNotificationsWorker;
16
  use MailPoet\Cron\Workers\WooCommerceSync as WooCommerceSyncWorker;
17
+ use MailPoet\DI\ContainerWrapper;
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  class WorkersFactory {
20
+ /** @var ContainerWrapper */
21
+ private $container;
22
 
23
+ public function __construct(ContainerWrapper $container) {
24
+ $this->container = $container;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
 
27
  /** @return SchedulerWorker */
28
+ function createScheduleWorker() {
29
+ return $this->container->get(SchedulerWorker::class);
30
  }
31
 
32
  /** @return SendingQueueWorker */
33
+ function createQueueWorker() {
34
+ return $this->container->get(SendingQueueWorker::class);
 
 
 
 
 
 
 
35
  }
36
 
37
  /** @return StatsNotificationsWorker */
38
+ function createStatsNotificationsWorker() {
39
+ return $this->container->get(StatsNotificationsWorker::class);
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
  /** @return StatsNotificationsWorkerForAutomatedEmails */
43
+ function createStatsNotificationsWorkerForAutomatedEmails() {
44
+ return $this->container->get(StatsNotificationsWorkerForAutomatedEmails::class);
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /** @return SendingServiceKeyCheckWorker */
48
+ function createSendingServiceKeyCheckWorker() {
49
+ return $this->container->get(SendingServiceKeyCheckWorker::class);
50
  }
51
 
52
  /** @return PremiumKeyCheckWorker */
53
+ function createPremiumKeyCheckWorker() {
54
+ return $this->container->get(PremiumKeyCheckWorker::class);
55
  }
56
 
57
  /** @return BounceWorker */
58
+ function createBounceWorker() {
59
+ return $this->container->get(BounceWorker::class);
60
  }
61
 
62
  /** @return MigrationWorker */
63
+ function createMigrationWorker() {
64
+ return $this->container->get(MigrationWorker::class);
65
  }
66
 
67
  /** @return WooCommerceSyncWorker */
68
+ function createWooCommerceSyncWorker() {
69
+ return $this->container->get(WooCommerceSyncWorker::class);
70
  }
71
 
72
  /** @return ExportFilesCleanup */
73
+ function createExportFilesCleanupWorker() {
74
+ return $this->container->get(ExportFilesCleanup::class);
75
  }
76
 
77
  /** @return Beamer */
78
+ function createBeamerkWorker() {
79
+ return $this->container->get(Beamer::class);
80
  }
81
 
82
  /** @return InactiveSubscribers */
83
+ function createInactiveSubscribersWorker() {
84
+ return $this->container->get(InactiveSubscribers::class);
85
  }
86
 
87
+ /** @return UnsubscribeTokens */
88
+ function createUnsubscribeTokensWorker() {
89
+ return $this->container->get(UnsubscribeTokens::class);
90
  }
91
 
92
+ /** @return SubscriberLinkTokens */
93
+ function createSubscriberLinkTokensWorker() {
94
+ return $this->container->get(SubscriberLinkTokens::class);
95
  }
96
 
97
  /** @return AuthorizedSendingEmailsCheck */
98
+ function createAuthorizedSendingEmailsCheckWorker() {
99
+ return $this->container->get(AuthorizedSendingEmailsCheck::class);
100
  }
101
 
102
  /** @return WooCommercePastOrders */
103
+ function createWooCommercePastOrdersWorker() {
104
+ return $this->container->get(WooCommercePastOrders::class);
105
  }
106
  }
lib/DI/ContainerConfigurator.php CHANGED
@@ -131,14 +131,34 @@ class ContainerConfigurator implements IContainerConfigurator {
131
  // Cron
132
  $container->autowire(\MailPoet\Cron\CronHelper::class)->setPublic(true);
133
  $container->autowire(\MailPoet\Cron\CronTrigger::class)->setPublic(true);
 
134
  $container->autowire(\MailPoet\Cron\Daemon::class)->setPublic(true);
135
  $container->autowire(\MailPoet\Cron\DaemonHttpRunner::class)->setPublic(true);
136
  $container->autowire(\MailPoet\Cron\Supervisor::class)->setPublic(true);
 
 
137
  $container->autowire(\MailPoet\Cron\Workers\WorkersFactory::class)->setPublic(true);
138
  $container->autowire(\MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler::class)->setPublic(true);
139
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\Scheduler::class);
140
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\StatsNotificationsRepository::class);
141
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\NewsletterLinkRepository::class);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  // Custom field
143
  $container->autowire(\MailPoet\CustomFields\ApiDataSanitizer::class);
144
  // Features
131
  // Cron
132
  $container->autowire(\MailPoet\Cron\CronHelper::class)->setPublic(true);
133
  $container->autowire(\MailPoet\Cron\CronTrigger::class)->setPublic(true);
134
+ $container->autowire(\MailPoet\Cron\CronWorkerScheduler::class)->setPublic(true);
135
  $container->autowire(\MailPoet\Cron\Daemon::class)->setPublic(true);
136
  $container->autowire(\MailPoet\Cron\DaemonHttpRunner::class)->setPublic(true);
137
  $container->autowire(\MailPoet\Cron\Supervisor::class)->setPublic(true);
138
+ $container->autowire(\MailPoet\Cron\Triggers\MailPoet::class)->setPublic(true);
139
+ $container->autowire(\MailPoet\Cron\Triggers\WordPress::class)->setPublic(true);
140
  $container->autowire(\MailPoet\Cron\Workers\WorkersFactory::class)->setPublic(true);
141
  $container->autowire(\MailPoet\Cron\Workers\SendingQueue\SendingErrorHandler::class)->setPublic(true);
142
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\Scheduler::class);
143
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\StatsNotificationsRepository::class);
144
  $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\NewsletterLinkRepository::class);
145
+ // Cron workers
146
+ $container->autowire(\MailPoet\Cron\Workers\Scheduler::class)->setPublic(true);
147
+ $container->autowire(\MailPoet\Cron\Workers\SendingQueue\SendingQueue::class)->setPublic(true);
148
+ $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\Worker::class)->setPublic(true);
149
+ $container->autowire(\MailPoet\Cron\Workers\StatsNotifications\AutomatedEmails::class)->setPublic(true);
150
+ $container->autowire(\MailPoet\Cron\Workers\KeyCheck\SendingServiceKeyCheck::class)->setPublic(true);
151
+ $container->autowire(\MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck::class)->setPublic(true);
152
+ $container->autowire(\MailPoet\Cron\Workers\Bounce::class)->setPublic(true);
153
+ $container->autowire(\MailPoet\Cron\Workers\SendingQueue\Migration::class)->setPublic(true);
154
+ $container->autowire(\MailPoet\Cron\Workers\WooCommerceSync::class)->setPublic(true);
155
+ $container->autowire(\MailPoet\Cron\Workers\ExportFilesCleanup::class)->setPublic(true);
156
+ $container->autowire(\MailPoet\Cron\Workers\Beamer::class)->setPublic(true);
157
+ $container->autowire(\MailPoet\Cron\Workers\InactiveSubscribers::class)->setPublic(true);
158
+ $container->autowire(\MailPoet\Cron\Workers\UnsubscribeTokens::class)->setPublic(true);
159
+ $container->autowire(\MailPoet\Cron\Workers\SubscriberLinkTokens::class)->setPublic(true);
160
+ $container->autowire(\MailPoet\Cron\Workers\AuthorizedSendingEmailsCheck::class)->setPublic(true);
161
+ $container->autowire(\MailPoet\Cron\Workers\WooCommercePastOrders::class)->setPublic(true);
162
  // Custom field
163
  $container->autowire(\MailPoet\CustomFields\ApiDataSanitizer::class);
164
  // Features
lib/Doctrine/EntityTraits/AutoincrementedIdTrait.php CHANGED
@@ -16,7 +16,7 @@ trait AutoincrementedIdTrait {
16
  */
17
  private $id;
18
 
19
- /** @return int */
20
  public function getId() {
21
  return $this->id;
22
  }
16
  */
17
  private $id;
18
 
19
+ /** @return int|null */
20
  public function getId() {
21
  return $this->id;
22
  }
lib/Models/Model.php CHANGED
@@ -141,10 +141,14 @@ class Model extends \Sudzy\ValidModel {
141
  }
142
 
143
  /**
144
- * @return bool|static
145
  */
146
  static function create() {
147
- return parent::create();
 
 
 
 
148
  }
149
 
150
  /**
141
  }
142
 
143
  /**
144
+ * @return static
145
  */
146
  static function create() {
147
+ $created = parent::create();
148
+ if (is_bool($created)) {
149
+ throw new \Exception('ORM is not initialised');
150
+ }
151
+ return $created;
152
  }
153
 
154
  /**
lib/Models/Newsletter.php CHANGED
@@ -778,7 +778,7 @@ class Newsletter extends Model {
778
  foreach ($data['filter'] as $key => $value) {
779
  if ($key === 'segment') {
780
  $segment = Segment::findOne($value);
781
- if ($segment !== false) {
782
  $orm = $segment->newsletters();
783
  }
784
  }
@@ -1152,7 +1152,7 @@ class Newsletter extends Model {
1152
 
1153
  static function findOneWithOptions($id) {
1154
  $newsletter = self::findOne($id);
1155
- if ($newsletter === false) {
1156
  return false;
1157
  }
1158
  return self::filter('filterWithOptions', $newsletter->type)->findOne($id);
778
  foreach ($data['filter'] as $key => $value) {
779
  if ($key === 'segment') {
780
  $segment = Segment::findOne($value);
781
+ if ($segment instanceof Segment) {
782
  $orm = $segment->newsletters();
783
  }
784
  }
1152
 
1153
  static function findOneWithOptions($id) {
1154
  $newsletter = self::findOne($id);
1155
+ if (!$newsletter instanceof self) {
1156
  return false;
1157
  }
1158
  return self::filter('filterWithOptions', $newsletter->type)->findOne($id);
lib/Models/ScheduledTask.php CHANGED
@@ -163,4 +163,44 @@ class ScheduledTask extends Model {
163
  ->whereNull('tasks.deleted_at')
164
  ->findOne() ?: null;
165
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
163
  ->whereNull('tasks.deleted_at')
164
  ->findOne() ?: null;
165
  }
166
+
167
+ static function findDueByType($type, $limit = null) {
168
+ return self::findByTypeAndStatus($type, ScheduledTask::STATUS_SCHEDULED, $limit);
169
+ }
170
+
171
+ static function findRunningByType($type, $limit = null) {
172
+ return self::findByTypeAndStatus($type, null, $limit);
173
+ }
174
+
175
+ static function findFutureScheduledByType($type, $limit = null) {
176
+ return self::findByTypeAndStatus($type, ScheduledTask::STATUS_SCHEDULED, $limit, true);
177
+ }
178
+
179
+ static function findCompletedByType($type, $limit = null) {
180
+ return self::findByTypeAndStatus($type, ScheduledTask::STATUS_COMPLETED, $limit);
181
+ }
182
+
183
+ private static function findByTypeAndStatus($type, $status, $limit = null, $future = false) {
184
+ $query = ScheduledTask::where('type', $type)
185
+ ->whereNull('deleted_at');
186
+
187
+ $now = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
188
+ if ($future) {
189
+ $query->whereGt('scheduled_at', $now);
190
+ } else {
191
+ $query->whereLte('scheduled_at', $now);
192
+ }
193
+
194
+ if ($status === null) {
195
+ $query->whereNull('status');
196
+ } else {
197
+ $query->where('status', $status);
198
+ }
199
+
200
+ if ($limit !== null) {
201
+ $query->limit($limit);
202
+ }
203
+
204
+ return $query->findMany();
205
+ }
206
  }
lib/Models/StatisticsClicks.php CHANGED
@@ -23,7 +23,7 @@ class StatisticsClicks extends Model {
23
  ->where('newsletter_id', $newsletter_id)
24
  ->where('queue_id', $queue_id)
25
  ->findOne();
26
- if (!$statistics) {
27
  $statistics = self::create();
28
  $statistics->link_id = $link_id;
29
  $statistics->subscriber_id = $subscriber_id;
23
  ->where('newsletter_id', $newsletter_id)
24
  ->where('queue_id', $queue_id)
25
  ->findOne();
26
+ if (!$statistics instanceof self) {
27
  $statistics = self::create();
28
  $statistics->link_id = $link_id;
29
  $statistics->subscriber_id = $subscriber_id;
lib/Models/StatisticsWooCommercePurchases.php CHANGED
@@ -28,12 +28,12 @@ class StatisticsWooCommercePurchases extends Model {
28
  ->where('newsletter_id', $click->newsletter_id)
29
  ->findOne();
30
 
31
- if (!$statistics) {
32
  $statistics = self::create();
33
  $statistics->newsletter_id = $click->newsletter_id;
34
  $statistics->subscriber_id = $click->subscriber_id;
35
  $statistics->queue_id = $click->queue_id;
36
- $statistics->click_id = $click->id;
37
  $statistics->order_id = $order->get_id();
38
  }
39
 
28
  ->where('newsletter_id', $click->newsletter_id)
29
  ->findOne();
30
 
31
+ if (!$statistics instanceof self) {
32
  $statistics = self::create();
33
  $statistics->newsletter_id = $click->newsletter_id;
34
  $statistics->subscriber_id = $click->subscriber_id;
35
  $statistics->queue_id = $click->queue_id;
36
+ $statistics->click_id = (int)$click->id;
37
  $statistics->order_id = $order->get_id();
38
  }
39
 
lib/Newsletter/Scheduler/PostNotificationScheduler.php CHANGED
@@ -132,14 +132,19 @@ class PostNotificationScheduler {
132
  $schedule = '* * * * *';
133
  break;
134
  }
 
135
  $option_field = NewsletterOptionField::where('name', 'schedule')->findOne();
136
- $relation = NewsletterOption::where('newsletter_id', $newsletter->id)
137
- ->where('option_field_id', $option_field->id)
138
- ->findOne();
139
- if (!$relation) {
 
 
 
 
140
  $relation = NewsletterOption::create();
141
  $relation->newsletter_id = $newsletter->id;
142
- $relation->option_field_id = $option_field->id;
143
  }
144
  $relation->value = $schedule;
145
  $relation->save();
132
  $schedule = '* * * * *';
133
  break;
134
  }
135
+ $relation = null;
136
  $option_field = NewsletterOptionField::where('name', 'schedule')->findOne();
137
+ if ($option_field instanceof NewsletterOptionField) {
138
+ $relation = NewsletterOption::where('newsletter_id', $newsletter->id)
139
+ ->where('option_field_id', $option_field->id)
140
+ ->findOne();
141
+ } else {
142
+ throw new \Exception('NewsletterOptionField for schedule doesn’t exist.');
143
+ }
144
+ if (!$relation instanceof NewsletterOption) {
145
  $relation = NewsletterOption::create();
146
  $relation->newsletter_id = $newsletter->id;
147
+ $relation->option_field_id = (int)$option_field->id;
148
  }
149
  $relation->value = $schedule;
150
  $relation->save();
lib/Newsletter/Shortcodes/Categories/Subscriber.php CHANGED
@@ -18,7 +18,9 @@ class Subscriber {
18
  $newsletter,
19
  $subscriber
20
  ) {
21
- if ($subscriber !== false && !is_object($subscriber)) return $shortcode_details['shortcode'];
 
 
22
  $default_value = ($shortcode_details['action_argument'] === 'default') ?
23
  $shortcode_details['action_argument_value'] :
24
  '';
@@ -46,7 +48,7 @@ class Subscriber {
46
  ::where('subscriber_id', $subscriber->id)
47
  ->where('custom_field_id', $custom_field[1])
48
  ->findOne();
49
- return ($custom_field) ? $custom_field->value : false;
50
  }
51
  return false;
52
  }
18
  $newsletter,
19
  $subscriber
20
  ) {
21
+ if ($subscriber !== false && !($subscriber instanceof SubscriberModel)) {
22
+ return $shortcode_details['shortcode'];
23
+ }
24
  $default_value = ($shortcode_details['action_argument'] === 'default') ?
25
  $shortcode_details['action_argument_value'] :
26
  '';
48
  ::where('subscriber_id', $subscriber->id)
49
  ->where('custom_field_id', $custom_field[1])
50
  ->findOne();
51
+ return ($custom_field instanceof SubscriberCustomField) ? $custom_field->value : false;
52
  }
53
  return false;
54
  }
lib/Router/Endpoints/Track.php CHANGED
@@ -61,7 +61,7 @@ class Track {
61
  return false;
62
  }
63
  $data->queue = SendingQueue::findOne($data->queue_id);
64
- if ($data->queue) {
65
  $data->queue = SendingTask::createFromQueue($data->queue);
66
  }
67
  $data->subscriber = Subscriber::findOne($data->subscriber_id) ?: null;
61
  return false;
62
  }
63
  $data->queue = SendingQueue::findOne($data->queue_id);
64
+ if ($data->queue instanceof SendingQueue) {
65
  $data->queue = SendingTask::createFromQueue($data->queue);
66
  }
67
  $data->subscriber = Subscriber::findOne($data->subscriber_id) ?: null;
lib/Router/Endpoints/ViewInBrowser.php CHANGED
@@ -108,7 +108,7 @@ class ViewInBrowser {
108
  ) return false;
109
 
110
  // if queue and subscriber exist, subscriber must have received the newsletter
111
- if ($data->queue &&
112
  $data->subscriber &&
113
  !$data->queue->isSubscriberProcessed($data->subscriber->id)
114
  ) return false;
108
  ) return false;
109
 
110
  // if queue and subscriber exist, subscriber must have received the newsletter
111
+ if ($data->queue instanceof SendingQueue &&
112
  $data->subscriber &&
113
  !$data->queue->isSubscriberProcessed($data->subscriber->id)
114
  ) return false;
lib/Services/Bridge.php CHANGED
@@ -86,14 +86,26 @@ class Bridge {
86
  }
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
89
  function getAuthorizedEmailAddresses() {
90
- $this->initApi($this->settings->get(self::API_KEY_SETTING_NAME));
91
- return $this->api->getAuthorizedEmailAddresses();
 
92
  }
93
 
94
  function checkMSSKey($api_key) {
95
- $this->initApi($api_key);
96
- $result = $this->api->checkMSSKey();
 
97
  return $this->processKeyCheckResult($result);
98
  }
99
 
@@ -118,8 +130,9 @@ class Bridge {
118
  }
119
 
120
  function checkPremiumKey($key) {
121
- $this->initApi($key);
122
- $result = $this->api->checkPremiumKey();
 
123
  return $this->processKeyCheckResult($result);
124
  }
125
 
@@ -180,9 +193,15 @@ class Bridge {
180
  }
181
 
182
  function updateSubscriberCount($result) {
183
- if (!empty($result['state'])
184
- && ($result['state'] === self::KEY_VALID
185
- || $result['state'] === self::KEY_EXPIRING)
 
 
 
 
 
 
186
  ) {
187
  return $this->api->updateSubscriberCount(Subscriber::getTotalSubscribers());
188
  }
86
  }
87
  }
88
 
89
+ /**
90
+ * @param string $key
91
+ * @return API
92
+ */
93
+ private function getApi($key) {
94
+ $this->initApi($key);
95
+ assert($this->api instanceof API);
96
+ return $this->api;
97
+ }
98
+
99
  function getAuthorizedEmailAddresses() {
100
+ return $this
101
+ ->getApi($this->settings->get(self::API_KEY_SETTING_NAME))
102
+ ->getAuthorizedEmailAddresses();
103
  }
104
 
105
  function checkMSSKey($api_key) {
106
+ $result = $this
107
+ ->getApi($api_key)
108
+ ->checkMSSKey();
109
  return $this->processKeyCheckResult($result);
110
  }
111
 
130
  }
131
 
132
  function checkPremiumKey($key) {
133
+ $result = $this
134
+ ->getApi($key)
135
+ ->checkPremiumKey();
136
  return $this->processKeyCheckResult($result);
137
  }
138
 
193
  }
194
 
195
  function updateSubscriberCount($result) {
196
+ if (
197
+ (
198
+ !empty($result['state'])
199
+ && (
200
+ $result['state'] === self::KEY_VALID
201
+ || $result['state'] === self::KEY_EXPIRING
202
+ )
203
+ )
204
+ && ($this->api instanceof API)
205
  ) {
206
  return $this->api->updateSubscriberCount(Subscriber::getTotalSubscribers());
207
  }
lib/Settings/UserFlagsController.php CHANGED
@@ -12,7 +12,7 @@ class UserFlagsController {
12
 
13
  /** @var array|null */
14
  private $data = null;
15
-
16
  /** @var array */
17
  private $defaults;
18
 
@@ -37,7 +37,11 @@ class UserFlagsController {
37
 
38
  function getAll() {
39
  $this->ensureLoaded();
40
- return array_merge($this->defaults, $this->data);
 
 
 
 
41
  }
42
 
43
  function set($name, $value) {
12
 
13
  /** @var array|null */
14
  private $data = null;
15
+
16
  /** @var array */
17
  private $defaults;
18
 
37
 
38
  function getAll() {
39
  $this->ensureLoaded();
40
+ $data = $this->data;
41
+ if (!is_array($data)) {
42
+ $data = [];
43
+ }
44
+ return array_merge($this->defaults, $data);
45
  }
46
 
47
  function set($name, $value) {
lib/Statistics/GATracking.php CHANGED
@@ -57,7 +57,7 @@ class GATracking {
57
  foreach ($extracted_links as $extracted_link) {
58
  if ($extracted_link['type'] !== NewsletterLinks::LINK_TYPE_URL) {
59
  continue;
60
- } elseif (strpos(parse_url($extracted_link['link'], PHP_URL_HOST), $internal_host) === false) {
61
  // Process only internal links (i.e. pointing to current site)
62
  continue;
63
  }
57
  foreach ($extracted_links as $extracted_link) {
58
  if ($extracted_link['type'] !== NewsletterLinks::LINK_TYPE_URL) {
59
  continue;
60
+ } elseif (strpos((string)parse_url($extracted_link['link'], PHP_URL_HOST), $internal_host) === false) {
61
  // Process only internal links (i.e. pointing to current site)
62
  continue;
63
  }
lib/Statistics/Track/WooCommercePurchases.php CHANGED
@@ -33,7 +33,11 @@ class WooCommercePurchases {
33
  }
34
 
35
  // limit clicks to 'USE_CLICKS_SINCE_DAYS_AGO' range before order has been created
36
- $from = clone $order->get_date_created();
 
 
 
 
37
  $from->modify(-self::USE_CLICKS_SINCE_DAYS_AGO . ' days');
38
  $to = $order->get_date_created();
39
 
@@ -74,7 +78,7 @@ class WooCommercePurchases {
74
  }
75
 
76
  $click = StatisticsClicks::findOne($cookie_data['statistics_clicks']);
77
- if (!$click) {
78
  return null;
79
  }
80
 
33
  }
34
 
35
  // limit clicks to 'USE_CLICKS_SINCE_DAYS_AGO' range before order has been created
36
+ $from_date = $order->get_date_created();
37
+ if (is_null($from_date)) {
38
+ return;
39
+ }
40
+ $from = clone $from_date;
41
  $from->modify(-self::USE_CLICKS_SINCE_DAYS_AGO . ' days');
42
  $to = $order->get_date_created();
43
 
78
  }
79
 
80
  $click = StatisticsClicks::findOne($cookie_data['statistics_clicks']);
81
+ if (!$click instanceof StatisticsClicks) {
82
  return null;
83
  }
84
 
lib/Subscribers/ImportExport/Export/DynamicSubscribersGetter.php CHANGED
@@ -43,7 +43,11 @@ class DynamicSubscribersGetter extends SubscribersGetter {
43
  return [];
44
  }
45
 
46
- $name = Segment::findOne($segment_id)->name;
 
 
 
 
47
 
48
  foreach ($filters as $filter) {
49
  $subscribers = $filter->toSql($subscribers);
43
  return [];
44
  }
45
 
46
+ $segment = Segment::findOne($segment_id);
47
+ if (!$segment instanceof Segment) {
48
+ return [];
49
+ }
50
+ $name = $segment->name;
51
 
52
  foreach ($filters as $filter) {
53
  $subscribers = $filter->toSql($subscribers);
lib/Subscribers/ImportExport/Import/Import.php CHANGED
@@ -156,6 +156,9 @@ class Import {
156
  // if this is a custom column
157
  if (in_array($column, $this->subscribers_custom_fields)) {
158
  $custom_field = CustomField::findOne($column);
 
 
 
159
  // validate date type
160
  if ($custom_field->type === 'date') {
161
  $validation_rule = 'datetime';
156
  // if this is a custom column
157
  if (in_array($column, $this->subscribers_custom_fields)) {
158
  $custom_field = CustomField::findOne($column);
159
+ if (!$custom_field instanceof CustomField) {
160
+ continue;
161
+ }
162
  // validate date type
163
  if ($custom_field->type === 'date') {
164
  $validation_rule = 'datetime';
lib/Tasks/Sending.php CHANGED
@@ -47,11 +47,12 @@ class Sending {
47
  ];
48
 
49
  private function __construct(ScheduledTask $task = null, SendingQueue $queue = null) {
50
- if (is_null($task) && is_null($queue)) {
51
  $task = ScheduledTask::create();
52
  $task->type = self::TASK_TYPE;
53
  $task->save();
54
-
 
55
  $queue = SendingQueue::create();
56
  $queue->newsletter_id = 0;
57
  $queue->task_id = $task->id;
@@ -108,7 +109,7 @@ class Sending {
108
  $queue = SendingQueue::where('newsletter_id', $newsletter_id)
109
  ->orderByDesc('updated_at')
110
  ->findOne();
111
- if (!$queue) {
112
  return false;
113
  }
114
 
47
  ];
48
 
49
  private function __construct(ScheduledTask $task = null, SendingQueue $queue = null) {
50
+ if (!$task instanceof ScheduledTask) {
51
  $task = ScheduledTask::create();
52
  $task->type = self::TASK_TYPE;
53
  $task->save();
54
+ }
55
+ if (!$queue instanceof SendingQueue) {
56
  $queue = SendingQueue::create();
57
  $queue->newsletter_id = 0;
58
  $queue->task_id = $task->id;
109
  $queue = SendingQueue::where('newsletter_id', $newsletter_id)
110
  ->orderByDesc('updated_at')
111
  ->findOne();
112
+ if (!$queue instanceof SendingQueue) {
113
  return false;
114
  }
115
 
lib/Tasks/State.php CHANGED
@@ -7,6 +7,7 @@ if (!defined('ABSPATH')) exit;
7
 
8
  use Carbon\Carbon;
9
  use MailPoet\Cron\Workers\Scheduler;
 
10
  use MailPoet\Models\ScheduledTask;
11
  use MailPoet\Models\SendingQueue;
12
  use MailPoet\Newsletter\Url as NewsletterUrl;
@@ -84,10 +85,10 @@ class State
84
  'id' => (int)$task->id,
85
  'type' => $task->type,
86
  'priority' => (int)$task->priority,
87
- 'updated_at' => Carbon::createFromTimeString($task->updated_at)->timestamp,
88
  'scheduled_at' => $task->scheduled_at ? Carbon::createFromTimeString($task->scheduled_at)->timestamp : null,
89
  'status' => $task->status,
90
- 'newsletter' => $queue && $newsletter ? [
91
  'newsletter_id' => (int)$queue->newsletter_id,
92
  'queue_id' => (int)$queue->id,
93
  'subject' => $queue->newsletter_rendered_subject ?: $newsletter->subject,
7
 
8
  use Carbon\Carbon;
9
  use MailPoet\Cron\Workers\Scheduler;
10
+ use MailPoet\Models\Newsletter;
11
  use MailPoet\Models\ScheduledTask;
12
  use MailPoet\Models\SendingQueue;
13
  use MailPoet\Newsletter\Url as NewsletterUrl;
85
  'id' => (int)$task->id,
86
  'type' => $task->type,
87
  'priority' => (int)$task->priority,
88
+ 'updated_at' => Carbon::createFromTimeString((string)$task->updated_at)->timestamp,
89
  'scheduled_at' => $task->scheduled_at ? Carbon::createFromTimeString($task->scheduled_at)->timestamp : null,
90
  'status' => $task->status,
91
+ 'newsletter' => (($queue instanceof SendingQueue) && ($newsletter instanceof Newsletter)) ? [
92
  'newsletter_id' => (int)$queue->newsletter_id,
93
  'queue_id' => (int)$queue->id,
94
  'subject' => $queue->newsletter_rendered_subject ?: $newsletter->subject,
lib/Util/Helpers.php CHANGED
@@ -37,6 +37,9 @@ class Helpers {
37
  static function getMaxPostSize($bytes = false) {
38
  $maxPostSize = ini_get('post_max_size');
39
  if (!$bytes) return $maxPostSize;
 
 
 
40
  switch (substr($maxPostSize, -1)) {
41
  case 'M':
42
  case 'm':
37
  static function getMaxPostSize($bytes = false) {
38
  $maxPostSize = ini_get('post_max_size');
39
  if (!$bytes) return $maxPostSize;
40
+ if ($maxPostSize === false) {
41
+ return 0;
42
+ }
43
  switch (substr($maxPostSize, -1)) {
44
  case 'M':
45
  case 'm':
lib/Util/Security.php CHANGED
@@ -24,7 +24,15 @@ class Security {
24
  */
25
  static function generateRandomString($length = 5) {
26
  $length = max(5, (int)$length);
27
- $string = base_convert(bin2hex(random_bytes(ceil(3 * $length / 4))), 16, 36); // phpcs:ignore
 
 
 
 
 
 
 
 
28
  return substr($string, 0, $length);
29
  }
30
 
24
  */
25
  static function generateRandomString($length = 5) {
26
  $length = max(5, (int)$length);
27
+ $string = base_convert(
28
+ bin2hex(
29
+ random_bytes( // phpcs:ignore
30
+ (int)ceil(3 * $length / 4)
31
+ )
32
+ ),
33
+ 16,
34
+ 36
35
+ );
36
  return substr($string, 0, $length);
37
  }
38
 
lib/Util/Sudzy/ValidModel.php CHANGED
@@ -5,7 +5,7 @@ if (!defined('ABSPATH')) exit;
5
 
6
 
7
  /**
8
- * @method static ORMWrapper|bool create($data=null)
9
  */
10
  abstract class ValidModel extends \Model {
11
  protected $_validator = null; // Reference to Sudzy validator object
5
 
6
 
7
  /**
8
+ * @method static static|bool create($data=null)
9
  */
10
  abstract class ValidModel extends \Model {
11
  protected $_validator = null; // Reference to Sudzy validator object
lib/Util/pQuery/pQuery.php CHANGED
@@ -9,6 +9,12 @@ if (!defined('ABSPATH')) exit;
9
  class pQuery extends \pQuery {
10
  public static function parseStr($html) {
11
  $parser = new Html5Parser($html);
 
 
 
 
 
 
12
  return $parser->root;
13
  }
14
  }
9
  class pQuery extends \pQuery {
10
  public static function parseStr($html) {
11
  $parser = new Html5Parser($html);
12
+
13
+ if (!$parser->root instanceof \pQuery\DomNode) {
14
+ // this condition shouldn't happen it is here only for PHPStan
15
+ throw new \Exception('Renderer is not configured correctly');
16
+ }
17
+
18
  return $parser->root;
19
  }
20
  }
lib/WP/Functions.php CHANGED
@@ -86,6 +86,10 @@ class Functions {
86
  }
87
 
88
  function addMenuPage($page_title, $menu_title, $capability, $menu_slug, callable $function = null, $icon_url = '', $position = null) {
 
 
 
 
89
  return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
90
  }
91
 
@@ -101,7 +105,7 @@ class Functions {
101
  return add_shortcode($tag, $callback);
102
  }
103
 
104
- function addSubmenuPage($parent_slug, $page_title, $menu_title, $capability, $menu_slug, callable $function = null) {
105
  return add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
106
  }
107
 
@@ -259,7 +263,7 @@ class Functions {
259
  }
260
 
261
  /**
262
- * @param int|boolean $user_id
263
  */
264
  function getTheAuthorMeta($field = '', $user_id = false) {
265
  return get_the_author_meta($field, $user_id);
@@ -325,8 +329,8 @@ class Functions {
325
  }
326
 
327
  /**
328
- * @param string|boolean $deprecated
329
- * @param string|boolean $plugin_rel_path
330
  */
331
  function loadPluginTextdomain($domain, $deprecated = false, $plugin_rel_path = false) {
332
  return load_plugin_textdomain($domain, $deprecated, $plugin_rel_path);
86
  }
87
 
88
  function addMenuPage($page_title, $menu_title, $capability, $menu_slug, callable $function = null, $icon_url = '', $position = null) {
89
+ if (is_null($function)) {
90
+ $function = function () {
91
+ };
92
+ }
93
  return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
94
  }
95
 
105
  return add_shortcode($tag, $callback);
106
  }
107
 
108
+ function addSubmenuPage($parent_slug, $page_title, $menu_title, $capability, $menu_slug, callable $function) {
109
  return add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
110
  }
111
 
263
  }
264
 
265
  /**
266
+ * @param int|false $user_id
267
  */
268
  function getTheAuthorMeta($field = '', $user_id = false) {
269
  return get_the_author_meta($field, $user_id);
329
  }
330
 
331
  /**
332
+ * @param string|false $deprecated
333
+ * @param string|false $plugin_rel_path
334
  */
335
  function loadPluginTextdomain($domain, $deprecated = false, $plugin_rel_path = false) {
336
  return load_plugin_textdomain($domain, $deprecated, $plugin_rel_path);
mailpoet.php CHANGED
@@ -5,7 +5,7 @@ if (!defined('ABSPATH')) exit;
5
 
6
  /*
7
  * Plugin Name: MailPoet 3 (New)
8
- * Version: 3.40.0
9
  * Plugin URI: http://www.mailpoet.com
10
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
11
  * Author: MailPoet
@@ -19,7 +19,7 @@ if (!defined('ABSPATH')) exit;
19
  */
20
 
21
  $mailpoet_plugin = [
22
- 'version' => '3.40.0',
23
  'filename' => __FILE__,
24
  'path' => dirname(__FILE__),
25
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
5
 
6
  /*
7
  * Plugin Name: MailPoet 3 (New)
8
+ * Version: 3.40.1
9
  * Plugin URI: http://www.mailpoet.com
10
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
11
  * Author: MailPoet
19
  */
20
 
21
  $mailpoet_plugin = [
22
+ 'version' => '3.40.1',
23
  'filename' => __FILE__,
24
  'path' => dirname(__FILE__),
25
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mailpoet, wysija
3
  Tags: email, email marketing, post notification, woocommerce emails, email automation, newsletter, newsletter builder, newsletter subscribers
4
  Requires at least: 4.7
5
  Tested up to: 5.2
6
- Stable tag: 3.40.0
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -159,6 +159,9 @@ Check our [Knowledge Base](https://kb.mailpoet.com) or contact us through our [s
159
 
160
  == Changelog ==
161
 
 
 
 
162
  = 3.40.0 - 2019-11-18 =
163
  * Improved: newsletter editor performance;
164
  * Fix: broken translation string.
3
  Tags: email, email marketing, post notification, woocommerce emails, email automation, newsletter, newsletter builder, newsletter subscribers
4
  Requires at least: 4.7
5
  Tested up to: 5.2
6
+ Stable tag: 3.40.1
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
159
 
160
  == Changelog ==
161
 
162
+ = 3.40.1 - 2019-11-25 =
163
+ * Improved: minor changes and fixes.
164
+
165
  = 3.40.0 - 2019-11-18 =
166
  * Improved: newsletter editor performance;
167
  * Fix: broken translation string.
vendor-prefixed/autoload.php CHANGED
@@ -7,4 +7,4 @@ if (!defined('ABSPATH')) exit;
7
 
8
  // autoload.php @generated by Composer
9
  require_once __DIR__ . '/composer/autoload_real.php';
10
- return \MailPoetVendor\ComposerAutoloaderInit02b61928b3cf010e40bd3f7e8d265922::getLoader();
7
 
8
  // autoload.php @generated by Composer
9
  require_once __DIR__ . '/composer/autoload_real.php';
10
+ return \MailPoetVendor\ComposerAutoloaderInit0abe538ed3a9e3511c442b8bbd1a7759::getLoader();
vendor/autoload.php CHANGED
@@ -7,4 +7,4 @@ if (!defined('ABSPATH')) exit;
7
 
8
  require_once __DIR__ . '/composer/autoload_real.php';
9
 
10
- return ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45::getLoader();
7
 
8
  require_once __DIR__ . '/composer/autoload_real.php';
9
 
10
+ return ComposerAutoloaderInitea8c7349f3cbaa890380efd17f034967::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -5,7 +5,7 @@ if (!defined('ABSPATH')) exit;
5
 
6
  // autoload_real.php @generated by Composer
7
 
8
- class ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45
9
  {
10
  private static $loader;
11
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45
22
  return self::$loader;
23
  }
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
- spl_autoload_unregister(array('ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
@@ -51,19 +51,19 @@ class ComposerAutoloaderInitd342b8f04dbb1722fcae2893ad583c45
51
  $loader->register(true);
52
 
53
  if ($useStaticLoader) {
54
- $includeFiles = Composer\Autoload\ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::$files;
55
  } else {
56
  $includeFiles = require __DIR__ . '/autoload_files.php';
57
  }
58
  foreach ($includeFiles as $fileIdentifier => $file) {
59
- composerRequired342b8f04dbb1722fcae2893ad583c45($fileIdentifier, $file);
60
  }
61
 
62
  return $loader;
63
  }
64
  }
65
 
66
- function composerRequired342b8f04dbb1722fcae2893ad583c45($fileIdentifier, $file)
67
  {
68
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
69
  require $file;
5
 
6
  // autoload_real.php @generated by Composer
7
 
8
+ class ComposerAutoloaderInitea8c7349f3cbaa890380efd17f034967
9
  {
10
  private static $loader;
11
 
22
  return self::$loader;
23
  }
24
 
25
+ spl_autoload_register(array('ComposerAutoloaderInitea8c7349f3cbaa890380efd17f034967', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitea8c7349f3cbaa890380efd17f034967', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
+ call_user_func(\Composer\Autoload\ComposerStaticInitea8c7349f3cbaa890380efd17f034967::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
51
  $loader->register(true);
52
 
53
  if ($useStaticLoader) {
54
+ $includeFiles = Composer\Autoload\ComposerStaticInitea8c7349f3cbaa890380efd17f034967::$files;
55
  } else {
56
  $includeFiles = require __DIR__ . '/autoload_files.php';
57
  }
58
  foreach ($includeFiles as $fileIdentifier => $file) {
59
+ composerRequireea8c7349f3cbaa890380efd17f034967($fileIdentifier, $file);
60
  }
61
 
62
  return $loader;
63
  }
64
  }
65
 
66
+ function composerRequireea8c7349f3cbaa890380efd17f034967($fileIdentifier, $file)
67
  {
68
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
69
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -7,7 +7,7 @@ namespace Composer\Autoload;
7
  if (!defined('ABSPATH')) exit;
8
 
9
 
10
- class ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45
11
  {
12
  public static $files = array (
13
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@@ -1661,10 +1661,10 @@ class ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45
1661
  public static function getInitializer(ClassLoader $loader)
1662
  {
1663
  return \Closure::bind(function () use ($loader) {
1664
- $loader->prefixLengthsPsr4 = ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::$prefixLengthsPsr4;
1665
- $loader->prefixDirsPsr4 = ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::$prefixDirsPsr4;
1666
- $loader->fallbackDirsPsr4 = ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::$fallbackDirsPsr4;
1667
- $loader->classMap = ComposerStaticInitd342b8f04dbb1722fcae2893ad583c45::$classMap;
1668
 
1669
  }, null, ClassLoader::class);
1670
  }
7
  if (!defined('ABSPATH')) exit;
8
 
9
 
10
+ class ComposerStaticInitea8c7349f3cbaa890380efd17f034967
11
  {
12
  public static $files = array (
13
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
1661
  public static function getInitializer(ClassLoader $loader)
1662
  {
1663
  return \Closure::bind(function () use ($loader) {
1664
+ $loader->prefixLengthsPsr4 = ComposerStaticInitea8c7349f3cbaa890380efd17f034967::$prefixLengthsPsr4;
1665
+ $loader->prefixDirsPsr4 = ComposerStaticInitea8c7349f3cbaa890380efd17f034967::$prefixDirsPsr4;
1666
+ $loader->fallbackDirsPsr4 = ComposerStaticInitea8c7349f3cbaa890380efd17f034967::$fallbackDirsPsr4;
1667
+ $loader->classMap = ComposerStaticInitea8c7349f3cbaa890380efd17f034967::$classMap;
1668
 
1669
  }, null, ClassLoader::class);
1670
  }