Commit Graph

1259 Commits

Author SHA1 Message Date
Rodrigo Primo
844ea3f6d8 Truncate first and last names before adding to wp_mailpoet_subscribers
MailPoet syncs users from wp_users to wp_mailpoet_subscribers. The
problem is that WP stores first and last names in a longtext field and
MP uses a varchar(255) field. This was causing a fatal error when
synchronizing names over 255 characters. This commit fixes this problem
by using SUBSTRING() to make sure that the 255 characters limit is
enforced when adding values to the columns first_name and last_name of
the wp_mailpoet_subscribers table. This should get rid of the fatal
error and it shouldn't be a problem to most users as it is unlikely that
a real user has a first or last name that is longer than 255 characters.

[MAILPOET-3246]
2021-03-02 16:09:47 +01:00
Jan Lysý
cbea75927a Add ignoring improper subscribers from MailChimp
[MAILPOET-3404]
2021-03-02 14:29:27 +01:00
Jan Lysý
878e3eb28f Simplify newsletter body data repair
[MAILPOET-3430]
2021-03-02 13:48:07 +01:00
Jan Lysý
78717509c8 Add tests for newsletter data fixers
[MAILPOET-3430]
2021-03-02 13:48:07 +01:00
Rodrigo Primo
a50c20637a Create an empty WC_Emails stub instead of using stdClass in a test
This commit simply improves an integration test that I modified while
working on [MAILPOET-3421] to use an empty WC_Emails stub instead of
using stdClass.
2021-03-01 14:14:19 +01:00
Rodrigo Primo
edbb69a239 Use the woocommerce_email action to customize WC emails
This commit changes the WC action that MailPoet uses to hook into WC and
customize the footer and the header of WC e-mails. Before, MailPoet was
using the woommerce_init action. The problem with using this action to customize
the e-mails is that it runs on every request. Furthermore, since we were calling
WC->mailer() inside the callback, we were instantiating WC_Emails on
every single request (WooCommerce instantiate this class only when
needed).

Replacing woocommerce_init with woocommerce_email means that our code
will run only when needed (right after WooCommerce adds callbacks to the
actions woocommerce_email_header and woocommerce_email_footer) and that
we won't be unnecessarily instantiating WC_Emails ourselves. We get the
singleton instance of this class as a parameter.

[MAILPOET-3421]
2021-03-01 14:14:19 +01:00
Rodrigo Primo
575b34fc97 Fix "Purchased In This Category" email for product variations
The "Purchased In This Category" email was not working for variable
products. This was happening because MailPoet calls
WC_Product::get_category_ids() to get the list of WooCommerce
categories associated with a given product, but this method doesn't work
for product variations (see
https://github.com/woocommerce/woocommerce/issues/12942).

In this commit, I'm implementing a workaround. I changed the code to
check if the product is a product variation and, if so, get the
categories from the parent product instead of the product itself. But I
also plan to raise this issue with the WooCommerce team as, in my opinion,
it is odd that WC_Product::get_category_ids() doesn't work with product
variations and fails silently.

[MAILPOET-3416]
2021-03-01 13:32:52 +01:00
Rostislav Wolny
438c9a7469 Alter data validation regexp so that is not malformed by wptexturize
[MAILPOET-3440]
2021-03-01 10:08:08 +01:00
Rostislav Wolny
5c38069caa Add scheduled tasks cleanup to tests setup
[MAILPOET-3412]
2021-03-01 08:43:45 +01:00
Rostislav Wolny
ff284cb12f Fix flaky Import test
Comparing timestamps with delta parameter allow values that differs by 1 second.
[MAILPOET-3412]
2021-03-01 08:43:45 +01:00
Jan Lysý
2bf5e93125 Add integration test for ImportExportRepository
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
0347e44893 Use importExportRepository in import
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
d500f872d7 Refactor integration Import test
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
1deaef4321 Use Doctrine in integration test for Import
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
2f1899d810 Add new dependencies to ImportTest
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Rostislav Wolny
dc4727117c Fix view in browser link shortcode and extend test
[MAILPOET-3434]
2021-02-17 16:11:59 +01:00
Rostislav Wolny
6bf62ee90a Fix links in form checkbox label
[MAILPOET-3433]
2021-02-17 11:00:15 +01:00
Rostislav Wolny
54cee207ea Remove forgotten test debug code
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
6a63ac26c7 Fix naming sanitiser > sanitizer
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
d00e667b96 Check Custom HTML in form on save
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
1fbed46411 Add service for fixing form API data
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
e13b2c62a9 Add servise for fixing html in form blocks
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Jan Lysý
cd776fe0cf Add tries when CronHelpes ping ends with timeout
[MAILPOET-3413]
2021-02-15 09:34:38 +01:00
Pavel Dohnal
5b5e01465c [MAILPOET-3408] 2021-02-10 14:52:20 +01:00
Jan Lysý
6337c37e45 Update tests for third party API
[MAILPOET-3307]
2021-02-03 11:01:38 +01:00
Jan Lysý
f5987359c7 Add integration test on SegmentSaveController
[MAILPOET-3170]
2021-01-26 17:03:48 +01:00
Jan Lysý
180a238b40 Use timestamp for DateTime compare in Segments WPTest
[MAILPOET-3367]
2021-01-25 11:52:25 +01:00
Rostislav Wolny
9868f5cc21 Remove dynamic segments services that are no longer needed
[MAILPOET-3164]
2021-01-25 09:17:17 +01:00
Rostislav Wolny
8456581695 Refactor segment lists fetching methods to separate repository
[MAILPOET-3164]
2021-01-25 09:17:17 +01:00
Rostislav Wolny
cd578e6475 Refactor fetching list of subscribers for export
[MAILPOET-3146]
2021-01-25 09:17:17 +01:00
Pavel Dohnal
4e3dda9872 Fix flakey integration test
[MAILPOET-3336]
2021-01-25 09:04:20 +01:00
Jan Lysý
df794425b7 Remove phpstan-ignores from tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
922c52f7df Remove phpstan errors from the rest of the tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
cb60c827a2 Remove phpstan errors from integration Newsletter tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
d3af5a1621 Remove phpstan errors from integration Models tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
8e53e260ef Remove phpstan errors from integration Tasks tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
428392ed18 Remove phpstan errors from integration DynamicSegments tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
4fd0779dcb Remove phpstan errors from integration Config tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
c9004553c3 Remove phpstan errors from integration Cron tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
bcb62403a1 Remove phpstan errors from integration API tests
[MAILPOET-3235]
2021-01-18 14:39:42 +01:00
Jan Lysý
84f2d5de0b Add test on nextRunDate in KeyCheckWorker
[MAILPOET-3271]
2021-01-18 10:26:59 +01:00
Pavel Dohnal
822550f3c0 Refactor dynamic segments listings to doctrine
[MAILPOET-3361]
2021-01-11 13:24:12 +01:00
Rostislav Wolny
03400bc4f7 Prevent using invalid bounce email address
[MAILPOET-2933]
2021-01-11 11:37:33 +01:00
Rostislav Wolny
6c63a562d1 Validate bounce email on import from MP2
[MAILPOET-2933]
2021-01-11 11:37:33 +01:00
Jan Lysý
83eecc9dc5 Fix getting subscribers without a list
[MAILPOET-3285]
2021-01-11 11:23:52 +01:00
Jan Lysý
e66ad88146 Set newsletter Entity when stdClass instance given
[MAILPOET-3356]
2021-01-11 11:15:33 +01:00
Pavel Dohnal
b64525ecc5 Migrate tests
[MAILPOET-3168]
2021-01-08 10:37:50 +01:00
Pavel Dohnal
1d6cf56fd9 Refactor subscriber statistics to doctrine
[MAILPOET-3168]
2021-01-08 10:37:50 +01:00
wxa
f571506129 Use woocommerce_form_field for WC checkout optin [MAILPOET-2925] 2021-01-04 14:22:42 +01:00
Rostislav Wolny
b1feed43f6 Fix subscriber listing with dynamic segment filter
[MAILPOET-3319]
2021-01-04 13:14:55 +01:00