PHP Class Aoe_Scheduler_Model_Schedule, Aoe_Scheduler

Inheritance: extends Mage_Cron_Model_Schedule
Datei anzeigen Open project: aoepeople/aoe_scheduler Class Usage Examples

Protected Properties

Property Type Description
$_eventObject string In an observer method you can use $observer->getData('schedule') or $observer->getData('data_object') to get this object
$_eventPrefix string Event name prefix for events that are dispatched by this class
$_redirect boolean Placeholder to keep track of active redirect buffer.
$_redirectOutputHandlerChunkSize Prior to PHP 5.4.0, the value 1 set the chunk size to 4096 bytes.
$errorSettingsBackup array Backup of the original error settings
$job Aoe_Scheduler_Model_Job
$jobWasLocked boolean

Public Methods

Method Description
_addBufferToMessages ( $buffer ) : string Used as callback function to redirect the output buffer directly into the messages field of this schedule.
addMessages ( $messages ) Append data to the current messages field.
canRun ( boolean $throwException = false ) : boolean Check if this schedule can be run
checkPid ( ) : boolean Check if process is running (linux only)
checkRunningAsCorrectUser ( ) : boolean Check if the user running the process matches the configured user. Message will capture cases where the user is not set too in its response message. Process may optionally be killed, or may be allowed to continue.
getAllStatuses ( )
getDuration ( ) : boolean | integer Get job duration.
getErrorLogFile ( ) : string Get error log filename
getJob ( ) : Aoe_Scheduler_Model_Job Get job configuration
getJobWasLocked ( ) : boolean Flag that shows that a previous execution was prevented because the job was locked
getParameters ( ) : mixed Get parameters (and fallback to job)
getStarttime ( ) : string Get start time (planned or actual)
getStatuses ( ) : array Gets statuses that are currently in the scheduler table
initializeFromJob ( Aoe_Scheduler_Model_Job $job ) Initialize from job
isAlive ( ) : boolean | null Is this process still alive?
isAlwaysTask ( ) : boolean Check if this is an "always" task
kill ( ) : void Kill this process
markAsDisappeared ( string $message = null ) : void Mark task as disappeared
process ( ) Process schedule
refresh ( ) Get fresh version of this object
requestKill ( integer $time = null, string $message = null ) Request kill
runNow ( boolean $tryLockJob = true, boolean $forceRun = false ) : Aoe_Scheduler_Model_Schedule Run this task now
saveMessages ( ) Save the messages directly to the schedule record.
schedule ( integer $time = null ) : Aoe_Scheduler_Model_Schedule Schedule this task to be executed at a given time
scheduleNow ( ) : Aoe_Scheduler_Model_Schedule Schedule this task to be executed as soon as possible
setCronExpr ( $expr ) Bypass parent's setCronExpr is the expression is "always" This will break trySchedule, but always tasks will never be tried to scheduled anyway
setLastRunUser ( string | null $user = null ) : self Set the user who ran the last successfully started schedule into a core variable

Protected Methods

Method Description
_beforeSave ( ) : Mage_Core_Model_Abstract Processing object before save data
_getPdoWarning ( PDO $pdo ) : mixed Retrieve the last PDO warning.
_startBufferToMessages ( ) Redirect all output to the messages field of this Schedule.
_stopBufferToMessages ( ) Stop redirecting all output to the messages field of this Schedule.
jobErrorContext ( ) Switch the job error context
log ( $message, null $level = null ) Log message to configured log file (or skip)
restoreErrorContext ( ) Restore the original error context

Method Details

_addBufferToMessages() public method

Used as callback function to redirect the output buffer directly into the messages field of this schedule.
public _addBufferToMessages ( $buffer ) : string
$buffer
return string

_beforeSave() protected method

Check if there are other schedules for the same job at the same time and skip saving in this case.
protected _beforeSave ( ) : Mage_Core_Model_Abstract
return Mage_Core_Model_Abstract

_getPdoWarning() protected method

Retrieve the last PDO warning.
protected _getPdoWarning ( PDO $pdo ) : mixed
$pdo PDO
return mixed

_startBufferToMessages() protected method

We use ob_start with _addBufferToMessages to redirect the output.
protected _startBufferToMessages ( )

_stopBufferToMessages() protected method

We use ob_end_flush to stop redirecting the output.
protected _stopBufferToMessages ( )

addMessages() public method

Append data to the current messages field.
public addMessages ( $messages )
$messages

canRun() public method

Check if this schedule can be run
public canRun ( boolean $throwException = false ) : boolean
$throwException boolean
return boolean

checkPid() public method

Check if process is running (linux only)
public checkPid ( ) : boolean
return boolean

checkRunningAsCorrectUser() public method

Check if the user running the process matches the configured user. Message will capture cases where the user is not set too in its response message. Process may optionally be killed, or may be allowed to continue.

getAllStatuses() public method

public getAllStatuses ( )

getDuration() public method

Get job duration.
public getDuration ( ) : boolean | integer
return boolean | integer time in seconds, or false

getErrorLogFile() public method

Get error log filename
public getErrorLogFile ( ) : string
return string

getJob() public method

Get job configuration
public getJob ( ) : Aoe_Scheduler_Model_Job
return Aoe_Scheduler_Model_Job

getJobWasLocked() public method

Flag that shows that a previous execution was prevented because the job was locked
public getJobWasLocked ( ) : boolean
return boolean

getParameters() public method

Get parameters (and fallback to job)
public getParameters ( ) : mixed
return mixed

getStarttime() public method

Get start time (planned or actual)
public getStarttime ( ) : string
return string

getStatuses() public method

Gets statuses that are currently in the scheduler table
public getStatuses ( ) : array
return array

initializeFromJob() public method

Initialize from job
public initializeFromJob ( Aoe_Scheduler_Model_Job $job )
$job Aoe_Scheduler_Model_Job

isAlive() public method

true -> alive false -> dead null -> we don't know because the task is running on a different server
public isAlive ( ) : boolean | null
return boolean | null

isAlwaysTask() public method

Check if this is an "always" task
public isAlwaysTask ( ) : boolean
return boolean

jobErrorContext() protected method

Switch the job error context
protected jobErrorContext ( )

kill() public method

Kill this process
public kill ( ) : void
return void

log() protected method

Log message to configured log file (or skip)
protected log ( $message, null $level = null )
$message
$level null

markAsDisappeared() public method

Mark task as disappeared
public markAsDisappeared ( string $message = null ) : void
$message string
return void

process() public method

Process schedule
public process ( )

refresh() public method

Get fresh version of this object
public refresh ( )

requestKill() public method

Request kill
public requestKill ( integer $time = null, string $message = null )
$time integer
$message string

restoreErrorContext() protected method

Restore the original error context
protected restoreErrorContext ( )

runNow() public method

Run this task now
public runNow ( boolean $tryLockJob = true, boolean $forceRun = false ) : Aoe_Scheduler_Model_Schedule
$tryLockJob boolean
$forceRun boolean
return Aoe_Scheduler_Model_Schedule

saveMessages() public method

If the messages field was not updated in the database, check if this is because of data truncation and fix the message length.
public saveMessages ( )

schedule() public method

Schedule this task to be executed at a given time
public schedule ( integer $time = null ) : Aoe_Scheduler_Model_Schedule
$time integer
return Aoe_Scheduler_Model_Schedule

scheduleNow() public method

Schedule this task to be executed as soon as possible
Deprecation: use Aoe_Scheduler_Model_Schedule::schedule() instead
public scheduleNow ( ) : Aoe_Scheduler_Model_Schedule
return Aoe_Scheduler_Model_Schedule

setCronExpr() public method

Bypass parent's setCronExpr is the expression is "always" This will break trySchedule, but always tasks will never be tried to scheduled anyway
public setCronExpr ( $expr )
$expr

setLastRunUser() public method

Set the user who ran the last successfully started schedule into a core variable
public setLastRunUser ( string | null $user = null ) : self
$user string | null Optional: if specified, overrides the default
return self

Property Details

$_eventObject protected_oe property

In an observer method you can use $observer->getData('schedule') or $observer->getData('data_object') to get this object
protected string $_eventObject
return string

$_eventPrefix protected_oe property

Event name prefix for events that are dispatched by this class
protected string $_eventPrefix
return string

$_redirect protected_oe property

Placeholder to keep track of active redirect buffer.
protected bool $_redirect
return boolean

$_redirectOutputHandlerChunkSize protected_oe property

Prior to PHP 5.4.0, the value 1 set the chunk size to 4096 bytes.
protected $_redirectOutputHandlerChunkSize

$errorSettingsBackup protected_oe property

Backup of the original error settings
protected array $errorSettingsBackup
return array

$job protected_oe property

protected Aoe_Scheduler_Model_Job $job
return Aoe_Scheduler_Model_Job

$jobWasLocked protected_oe property

protected bool $jobWasLocked
return boolean