Per WP security best practices, sanitization should be handled as early
as possible. So this commit move updates the calls to sanitize the
segment name and description to the part of the code where the user
input is first processed, instead of when the data is saved to the
database.
[MAILPOET-5232]
This commits adds the sanitization right before the data is added to the
database (\MailPoet\Segments\SegmentsRepository::createOrUpdate()) and
removes the sanitization from
\MailPoet\Segments\DynamicSegments\SegmentSaveController::save() to
avoid sanitizing twice. save() calls createOrUpdate().
Before this commit, we were sanitizing the name and description of
dynamic segments but not regular segments.
[MAILPOET-5232]
This commit adds code to delete corresponding newsletter segment
entities when a given list is deleted. This is necessary to fix an error
when duplicating a newsletter that was sent with a list that was
deleted.
Without this change users see the following SQL error:
```
An exception occurred while executing ‘UPDATE wp_mailpoet_newsletter_segment SET segment_id = ?, updated_at = ? WHERE id = ?’ with params [null, “2023-03-23 09:07:52”, 66]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘segment_id’ cannot be null
```
[MAILPOET-5153]
This commit changes SegmentsRepository::getWPUsersSegment() so that it
behaves like Models\Segment::getWPSegment() and creates a WP segment
when none is found. This is needed to replace the latter with the former
in a subsequent commit.
[MAILPOET-4306]
Remove the following errors:
(Method|Property|Function) has no (return )?type specified.
(Method|Function) has parameter with no type (specified).
I have modified bulkDelete to be similar to bulkDelete on SubscribersRepository.php. This function is used in MailPoet\Test\API\JSON\v1\Segments.
[MAILPOET-3720]