Update NewsletterOption and NewsletterOptionField removal date

This commit updates the remove date of the deprecated models
NewsletterOption and NewsletterOptionField. When they were initially
deprecated it was missed that two Newsletter model methods still used
them.

Those two methods are deprecated in this commit as apparently they are
not used anymore in MP's codebase.

[MAILPOET-5252]
This commit is contained in:
Rodrigo Primo
2023-04-28 11:38:48 -03:00
committed by Oluwaseun Olorunsola
parent 6f511c685b
commit 87f703f22a
3 changed files with 21 additions and 2 deletions

View File

@@ -105,7 +105,13 @@ class Newsletter extends Model {
);
}
/**
* @deprecated This method can be removed after 2023-10-28. Make sure it is removed together with
* \MailPoet\Models\NewsletterOption and \MailPoet\Models\NewsletterOptionField.
*/
public function options() {
self::deprecationError(__METHOD__);
return $this->hasManyThrough(
__NAMESPACE__ . '\NewsletterOptionField',
__NAMESPACE__ . '\NewsletterOption',
@@ -251,7 +257,13 @@ class Newsletter extends Model {
return $this;
}
/**
* @deprecated This method can be removed after 2023-10-28. Make sure it is removed together with
* \MailPoet\Models\NewsletterOption and \MailPoet\Models\NewsletterOptionField.
*/
public function withOptions() {
self::deprecationError(__METHOD__);
$options = $this->options()->findArray();
if (empty($options)) {
$this->options = [];
@@ -366,4 +378,11 @@ class Newsletter extends Model {
}
return self::filter('filterWithOptions', $newsletter->type)->findOne($id);
}
private static function deprecationError($methodName) {
trigger_error(
'Calling ' . esc_html($methodName) . ' is deprecated and will be removed. Use \MailPoet\Newsletter\NewslettersRepository and \MailPoet\Entities\NewsletterEntity instead.',
E_USER_DEPRECATED
);
}
}

View File

@@ -9,7 +9,7 @@ namespace MailPoet\Models;
* @property string $updatedAt
*
* @deprecated This model is deprecated. Use \MailPoet\Newsletter\Options\NewsletterOptionsRepository and
* \MailPoet\Entities\NewsletterOptionEntity instead. This class can be removed after 2022-11-11.
* \MailPoet\Entities\NewsletterOptionEntity instead. This class can be removed after 2023-10-28.
*/
class NewsletterOption extends Model {
public static $_table = MP_NEWSLETTER_OPTION_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration

View File

@@ -7,7 +7,7 @@ namespace MailPoet\Models;
* @property string $newsletterType
*
* @deprecated This model is deprecated. Use \MailPoet\Newsletter\Options\NewsletterOptionFieldsRepository and
* \MailPoet\Entities\NewsletterOptionFieldEntity instead. This class can be removed after 2022-11-11.
* \MailPoet\Entities\NewsletterOptionFieldEntity instead. This class can be removed after 2023-10-28.
*/
class NewsletterOptionField extends Model {
public static $_table = MP_NEWSLETTER_OPTION_FIELDS_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration