CoolCMS API

AdvertExpirationNoticeTrait

Cron batch operations on advert expiration.

  • notifyUpcomingExpirations() sends BZ_ADVERT_EXPIRATION_NOTICE to adverts that expire within N days (setting 5/advert.expiration.noticeDays) and sets notice_expiration=1 so the notice is not repeated.
  • deleteLongExpired() silently marks deleted=1 on adverts expired for more than M days (setting 5/advert.expiration.deleteDays); no e-mail.
Tags
requires

AdvertManager expects these members of the host class:

  • findAll(), updateColumn() (BaseManager traity)
  • $emailManager->sendEmail(...) (EmailManager)
  • getPresenterContext() (PresenterTrait)
  • $languageContext (LanguageTrait)
  • getSettingContext() (SettingsTrait)
  • $cronFailureManager (back-off for failing adverts)

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

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
Result

notifyUpcomingExpirations()

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
Return values
Result
On this page

Search results