Commit Graph

13768 Commits

Author SHA1 Message Date
Rodrigo Primo
3a1c2b61a3 Fix PHP notice when the plugin user-switching is active
Some users were getting the PHP notice below when using the
user-switching (https://wordpress.org/plugins/user-switching/) plugin
to switch to a different user.

```
PHP Notice: get_cart was called incorrectly. Get cart should not be called before the wp_loaded action.
```

This notice is generated by WooCommerce when `WC_Cart::get_cart()` is
called before the `wp_loaded` action. user-switching calls a WooCommerce
method to empty the user session and the cart when switching users and
this happens before wp_loaded. MailPoet hooks into the
woocommerce_cart_emptied action
(c9ca134d30/lib/AutomaticEmails/WooCommerce/Events/AbandonedCart.php (L118))
to decide whether it should schedule or cancel an abandoned cart email.
When doing so, it calls WC_Cart::is_empty() which calls
WC_Cart::get_cart(). This is why the PHP notice is generated.

When the cart is emptied we don't need to check it again calling
WC_Cart::is_empty(). So, to get rid of the PHP notice, this commit adds an
extra condition to the if statement to only run WC_Cart::is_empty() if
the current action is not `woocommerce_cart_emptied`.

[MAILPOET-3374]
2021-03-01 14:44:38 +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
Pavel Dohnal
91386815a2 Use the latest woocommerce for the latest tests
[MAILPOET-3330]
2021-03-01 10:36:00 +01:00
Pavel Dohnal
1312139fb8 Use woocommerce 4.0.1 for the oldest tests
[MAILPOET-3330]
2021-03-01 10:36:00 +01:00
Pavel Dohnal
916aa847ca Use woocommerce 5.0.0 for the acceptance tests
[MAILPOET-3330]
2021-03-01 10:36:00 +01:00
Jan Lysý
93d79c7f94 Fix missing close button for success notice
[MAILPOET-3435]
2021-03-01 10:15:42 +01:00
Jan Lysý
c5a11b2bd8 Add acceptance test for the Gutenberg form block
[MAILPOET-3440]
2021-03-01 10:08:08 +01:00
Jan Lysý
76d79397c2 Add methods for name in a form to DataFactory
[MAILPOET-3440]
2021-03-01 10:08:08 +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
f8934705b4 Disable WP cron on Circle CI docker
[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
Rostislav Wolny
fa2313994d Allow higher npm versions
Newer node15 is distributed with npm7.5.
This change will allow using it for installation of JS dependencies.
[MAILPOET-3412]
2021-03-01 08:43:45 +01:00
Rostislav Wolny
7a7fd577a9 Switch builds on CI to images with disabled xdebug
[MAILPOET-3412]
2021-03-01 08:43:45 +01:00
Jan Lysý
c9ca134d30 Fix join parameters in SubscribersRepository
[MAILPOET-3445]
2021-02-25 17:36:27 +03:00
Rodrigo Primo
37f5ec190b Display the HelpScout chat for all plans with premium support
This commit fixes a problem in the logic used to decide whether or not
the HelpScout chat should be available on the MailPoet admin pages. Before,
we were displaying the chat for plans that include premium support and access
to MSS. But we also have plans, like the Blogger plan, that include
premium support, and should see the chat, but don't include access to
MSS. Those plans were not seeing the chat.

This was happening because the code was checking just for
`mailpoet_api_key_state.data.support_tier == 'premium'`. The
mailpoet_api_key_state setting is added to the database based on the
response from the bridge.mailpoet.com/me endpoint. This endpoint returns
a 403 error for plans that don't include the sending service.

In this commit, to fix this problem, the code now checks for both
`mailpoet_api_key_state.data.support_tier == 'premium'` and
`premium_key_state.data.support_tier == 'premium'`. The former setting
is added to the database based on the response of the
bridge.mailpoet.com/premium endpoint. This endpoint works for plans that
have access to MailPoet Premium, but don't have access to MSS. We need to
check for both settings as we also have some plans that include the
sending service, but don't include MailPoet Premium.

[MAILPOET-3438]
2021-02-25 13:35:54 +03:00
Rodrigo Primo
1e6e6a3883 Update Robo commands
This commit updates some Robo commands that were using `:` instead of
`-` to separete words for commands with more than two words resulting in
command not found errors. Simply replacing the aforementioned character
fixes the commands.

For two release related commands, it was also necessary to add the
`release` prefix.

[MAILPOET-3444]
2021-02-24 11:59:18 +01:00
Rodrigo Primo
8b500eafa5 Update SECURITY.md to point security researchers to HackerOne
This commit updates the SECURITY.md file to point security researchers
to HackerOne. I copied the SECURITY.md file from WooCommerce and made
some minor changes to reflect MailPoet specificities.

[MAILPOET-3410]
2021-02-23 14:01:10 +03:00
Rodrigo Primo
70138089d7 PHPCS: set the supported PHP versions in the ruleset file
This commit moves the definition of the supported PHP versions from
RoboFile.php file to the PHPCS configuration file, ruleset.xml. This
should make it easier to configure PHPCS in other places like the IDE.

I also removed the constraint of the highest supported PHP version
(previously, it was hard-coded to 8.0) as I believe we support new PHP
versions as soon as they are released. With this change, we don't need to
remember to update testVersion tag whenever there is a new PHP version.

[MAILPOET-3439]
2021-02-22 15:31:56 +03:00
Rodrigo Primo
f8c74af9e3 Add PHPCS checks to the pre-commit hook
This commit adds PHPCS checks, using `./do qa:code-sniffer`, to the
pre-commit hook. To be able to do this, I had to modify `./do
qa:code-sniffer` to call PHPCS only once and change its signature to
accept an optional parameters with the list of files to check. If this
parameter is not passed, all files are checked.

As discussed with the rest of the team, before we were calling PHPCS
multiple times to be able to check for compatibility with different
versions of PHP, but as far as we can tell this is not necessary, and we
can check for compatibility with PHP >= 7.1 for all files.

As far as I know, changing the signature of RoboFile::qaCodeSniffer() is
not a problem and I updated the only instance where this method is
called.

[MAILPOET-3439]
2021-02-22 15:31:56 +03: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ý
7b893dfb51 Move multi insert functionality to a special repository
[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ý
93e97717f7 Add missing return type to NewsletterOptionsRepository
[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
Jan Lysý
09acbb0d07 Use Doctrine instead of Paris in Import
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
78d87120f3 Add method for multi insert or update to Repository
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
8cfd47e656 Move custom field type constants to entity
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
0e1f7993b2 Fix removing from not default segments
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
32959b55b8 Fix deleting custom fields of WP and WC users
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Rostislav Wolny
8156134684 Keep old sending settings when activating MSS via key validation
[MAILPOET-3401]
2021-02-18 09:53:29 +01:00
Rostislav Wolny
0893766915 Fix searching segments in subscribers import
[MAILPOET-3423]
2021-02-17 20:26:12 +03:00
Pavel Dohnal
aad1495262 Prevent deleting lists with emails that are being sent
[MAILPOET-3417]
2021-02-17 16:31:31 +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
31df925cf4 Remove unnecessary code form short code task
[MAILPOET-3434]
2021-02-17 16:11:59 +01:00
Tautvidas Sipavicius
46f468b106 Release 3.60.1 2021-02-17 13:21:43 +02:00
Rostislav Wolny
6bf62ee90a Fix links in form checkbox label
[MAILPOET-3433]
2021-02-17 11:00:15 +01:00
Tautvidas Sipavicius
22d98eb4b1 Release 3.60.0 2021-02-16 12:29:49 +02:00
Rostislav Wolny
76279d3148 Fix form input validations
[MAILPOET-3415]
2021-02-15 19:05:14 +01:00
Pavel Dohnal
956b455b27 Fix function return types in subscribers stats
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
098af570e3 Fix function return types in import
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
beb02d2716 Fix function return types in form templates
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
7b7edb688c Fix function return types in rich text
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
c1a4304400 Fix function return types in placement of form editor
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
82840edd8d Fix function return types in components of form editor
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00
Pavel Dohnal
07ba872d69 Fix functions ts violation in blocks
[MAILPOET-3301]
2021-02-15 18:51:35 +01:00