AdvertExpirationNoticeTrait
Cron batch operations on advert expiration.
notifyUpcomingExpirations()sendsBZ_ADVERT_EXPIRATION_NOTICEto adverts that expire within N days (setting 5/advert.expiration.noticeDays) and setsnotice_expiration=1so the notice is not repeated.deleteLongExpired()silently marksdeleted=1on adverts expired for more than M days (setting 5/advert.expiration.deleteDays); no e-mail.
Tags
Table of Contents
Constants
- EXPIRATION_NOTICE_QUEUE : string = 'bazaar.advert.expiration-notice'
Methods
- deleteLongExpired() : Result
- Silently marks (deleted=1) adverts that expired more than M days ago.
- notifyUpcomingExpirations() : array{notified: int, failed: int, skipped: int, markerFailed: int}
- Finds active adverts expiring within N days that were not notified yet, sends the notice e-mail and sets `notice_expiration=1`.
- sendExpirationNoticeEmail() : Result
- Sends `BZ_ADVERT_EXPIRATION_NOTICE` for one advert. The language is taken primarily from the advert's `insertLanguageId`; a cron run has no front `languageContext` like a regular request.
Constants
EXPIRATION_NOTICE_QUEUE
private
string
EXPIRATION_NOTICE_QUEUE
= 'bazaar.advert.expiration-notice'
Methods
deleteLongExpired()
Silently marks (deleted=1) adverts that expired more than M days ago.
public
deleteLongExpired([int $limit = 200 ]) : Result
One bulk UPDATE per batch.
IMPORTANT: returns Result; success carries data = ['deleted' => int]. A failed bulk
updateColumn() is a failure (the cron must not report ok when nothing was marked)
and no reindex runs.
Parameters
- $limit : int = 200
Return values
ResultnotifyUpcomingExpirations()
Finds active adverts expiring within N days that were not notified yet, sends the notice e-mail and sets `notice_expiration=1`.
public
notifyUpcomingExpirations([int $limit = 50 ]) : array{notified: int, failed: int, skipped: int, markerFailed: int}
When sending fails, the flag stays unset and the next cron run retries.
markerFailed = the e-mail was queued but the noticeExpiration marker was not written
(the next run sends it again).
An advert whose notice does not go out (e-mail failure, missing address, marker not written) gets a back-off (CronFailureManager) and the selection skips it meanwhile; otherwise 50 such adverts at the head would starve all the others of their notice.
Parameters
- $limit : int = 50
Return values
array{notified: int, failed: int, skipped: int, markerFailed: int}sendExpirationNoticeEmail()
Sends `BZ_ADVERT_EXPIRATION_NOTICE` for one advert. The language is taken primarily from the advert's `insertLanguageId`; a cron run has no front `languageContext` like a regular request.
private
sendExpirationNoticeEmail(Advert $advert) : Result
Parameters
- $advert : Advert