Commit Graph

22460 Commits

Author SHA1 Message Date
Rostislav Wolny
6cb51a3841 Remove unused parameters in MailPoet.date.toDate
The options were just set in init but there was no effect.
[MAILPOET-6197]
2024-08-23 15:37:16 +02:00
Rostislav Wolny
122f73c3c2 Do not apply offset when manipulating with date in the Date picker
We use DateTime component on the send page.
The DateTime component uses DateText for picking date.
We add site's offset before we pass the date to the DateTime.

The date-text component is nested in the DateTime and was also applying
offset on the date.

The second issue was we needed to convert the value to JS Date.
The MailPoet.Date.toDate expects the value to be in UTC, and we provided an already converted date.

So for offset -07:00
MailPoet.Date.toDate('2023-09-01');
ends up
Thu Aug 31 2023 17:00:00 GMT-0700 (Pacific Daylight Time) and calendar display's incorrect value.

This commit fixes it so that we don't touch offset in the DateText component.
[MAILPOET-6197]
2024-08-23 15:37:07 +02:00
David Remer
2b2ee75288 Jump to version 5.0.0 2024-08-21 08:57:04 +03:00
David Remer
38b5932c81 Release 4.59.0 2024-08-21 08:57:04 +03:00
Rostislav Wolny
a81163df71 Keep Typescript at 5.0.2
pnpm dedupe upated Typescript.
The update of Typescript is more complex. We also need to update the eslint
because there is a warning that TS version is not supported and
eslint-config-airbnb-typescript was abandoned so we need to remove it and
do some changes in eslint config for TS

[MAILPOET-6191]
2024-08-20 16:24:12 +02:00
Rostislav Wolny
1116b87eee pnpm dedupe
[MAILPOET-6191]
2024-08-20 16:24:12 +02:00
Rostislav Wolny
192725036d Update axios package
The package is a subdependency of @wordpress/scripts
I tried pnpm update axios but it didn't work.
I removed @wordpress/scripts and installed the same version again
and it updated the axios.
[MAILPOET-6191]
2024-08-20 16:24:12 +02:00
Rostislav Wolny
f31109d07c Update required pnpm manager version
I update pnpm because the required version is quite old and
some devs are using newer version anyways and mixing versions
causes strange changelogs in package-lock.yml

I ran corepack up but I removed the sha from the version
because the previous version didn't have it as well.
[MAILPOET-6191]
2024-08-20 16:24:12 +02:00
Rostislav Wolny
d16e1b69e7 Add timezone info to system report
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
bb7ab59ed5 Improve readability of scheduler code
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
07221d9c68 Get rid of unnecessary parameter in the Scheduler
The fromTimestamp parameter was used only in tests.
This commit replaces the parameter in tests by mocks and removes it.
 [MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
cb96086eb7 Rename methods for manipulating date in scheduling UI
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
6a4d3833c7 Get rid of unnecessary usages of .toISOString
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
54b800763b Replace usages of prefixed date methods with renamed variants
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
8c6136525e Remove unused date.ts methods and rename the prefixed methods
There is no use case for the methods without the translation to site's timezone.
When the input doesn't specify the timezone we treat it as utc.
When the input provides timezone (e.g. '2024-08-13 10:00+02:00' or new Date('2024-08-13 10:00+02:00'))
We respect the timezone of the input and print the result in the site's timezone.

When the site's timezone is set +01:00

'2024-08-13 10:00' prints as 2024-08-13 11:00
'2024-08-13 10:00:+02:00' prints as 2024-08-13 09:00
new Date('2024-08-13 10:00:+02:00') prints as 2024-08-13 09:00
new Date('2024-08-13 10:00:+00:00') prints as 2024-08-13 11:00

[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
9f32c59e49 Use DBAL Driver middleware to handle the correct connection timezone
I looked into using DBAL events for this but found that DBAL events
are deprecated so I went with middleware as they are recommended
as a replacement for the DBAL events.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
3ea44e45d4 Remove adjustForTimezoneDifference functionality
This is no longer used. It was used in just a couple of places
and was fixing a difference between PHP time zone and browser time.
We rely on WordPress to set PHP timezone to UTC and we use the site's
timezone on the client so the fix is no longer useful.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
f814624e0e Set GMT timezone to WPDB
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
506652bdc4 Fix scheduling post notifications
The user picks time in a select box, and we expect they pick a time
in the site's timezone so the saved cron expression is in the site's timezone.
When we calculate the next run date, we do it in the site's timezone and
to get UTC time, we convert it.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
797a446470 Fix values in list of times in scheduling form
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
ef5ee6d59a Fix times in task lists on Help > System Status
The time adjustments are not necessary because we rely on WP setting
timezone to UTC.
Manipulation in adjustTimezone difference was causing us to display GMT time.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
dac4eb82a4 Show proper time in listing for scheduled newsletter
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
73ffe485e7 Use isInFutureGmt to check future on send page
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
49ae4e5517 Show proper times for action scheduler info on help page
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
c6916431b0 Use proper time in scheduling calendar on send page
We add offset before we display time and we remove when we pass it to callback.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
e9acdbf9ad Replace simple usages of date formating with offet aware methods
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
0bc5f3acc8 Add formatFromGmt etc to MailPoet.Date
This set of function expects input in GMT and add site's offset
They are meant to be used for data coming from server in GMT
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
9fa6890606 Pass GMT offset from WordPress settings to JS
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
5fdba0e170 Replace current_time usage in tests
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
33f4b2d729 Replace usage of WP's current_time without gmt parameter in libs
This commit replaces usages by Carbon::now or in case we need a timestamp it
keeps current_time but adds the gtm parameter as true.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
9209a25199 Improve LastSubsribedAtListener to use fresh now
The cached now may cause the value to not be exact.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
83fb7f55ea Use UTC time in TimestampListener
$this->wp->currentTime('timestamp') adds 'gmt_offset' value.
This was needed with PDO connection because the connection
used @session.time_zone set to the same offset value.

[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
9f56ee67b7 Skip null ids when deleting WP list subscribers with invalid emails
Theoretically, we may end up running the delete query with a condition like
WHERE wp_user_id IN (null, null);
This is a tiny optimization to skip null IDs to avoid running such a query.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
c95cd1073b Improve SubscriberLifetieEmailCountTest to use saved entity
The test was using an empty entity which was not presisted. This may
potentially cause issues as in some places, an entity with a proper type might be expected.
It was already causing that an SQL query ran with WHERE type = null condition which is always false.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
ec0210cdab Rename $value to $row in WPDB/Result for better readability
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
7f1c606040 Reintroduce legacy DB table name constants for backward compatibility
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
d53fde4250 Cleanup unused Doctrine drivers and other files
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
569204b594 Remove PDO
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
4531ae9e60 Use WPDB driver for Doctrine
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
200ea47926 Use mysqli to run test cleanups
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
accdb64894 Split mutli-query into multiple statements
WPDB doesn't support multi queries.

[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
8c4b2cf3ef Replace deprecated Statement::bindParam() and Statement::exec() with params
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
240f15e22a Fix missing array key
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
fd72597e2c Fix last insert ID type check
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
c25d7d6b53 Use single quotes for strings in SQL queries
This is more standard SQL and required by WPDB.

[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
3b3ebb1cbd Pass SQLSTATE and code to query exceptions so they are converted to DBAL exceptions properly
The conversion is done by MailPoetVendor\Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter
that is returned from MailPoetVendor\Doctrine\DBAL\Driver\AbstractMySQLDriver.

[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
c42c37e8b1 Implement parameter conversion and named parameters
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
53cad38099 Implement Statement and Connection::prepare()
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
dc66a6a349 Implement Result and Connection::query()
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Jan Jakes
2047f0b694 Implement Connection::exec() and other simple connection methods
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00