diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job.php index aa443c1..f90a78f 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job.php @@ -28,25 +28,15 @@ protected function _prepareLayout() $this->removeButton('add'); $this->_addButton( 'add_new_job', - array( - 'label' => $this->__('Create new job'), - 'onclick' => "setLocation('{$this->getUrl('*/*/new')}')", - 'class' => 'add' - ) + ['label' => $this->__('Create new job'), 'onclick' => "setLocation('{$this->getUrl('*/*/new')}')", 'class' => 'add'] ); $this->_addButton( 'add_new', - array( - 'label' => $this->__('Generate Schedule'), - 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')", - ) + ['label' => $this->__('Generate Schedule'), 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')"] ); $this->_addButton( 'configure', - array( - 'label' => $this->__('Cron Configuration'), - 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', array('section' => 'system'))}#system_cron')", - ) + ['label' => $this->__('Cron Configuration'), 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', ['section' => 'system'])}#system_cron')"] ); return parent::_prepareLayout(); } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit.php index e1303ee..07e75b4 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit.php @@ -63,6 +63,6 @@ public function getHeaderText() */ public function getSaveUrl() { - return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null)); + return $this->getUrl('*/*/save', ['_current'=>true, 'back'=>null]); } } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Form.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Form.php index f011b50..2f1d188 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Form.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Form.php @@ -14,11 +14,7 @@ class Aoe_Scheduler_Block_Adminhtml_Job_Edit_Form extends Mage_Adminhtml_Block_W */ protected function _prepareForm() { - $form = new Varien_Data_Form(array( - 'id' => 'edit_form', - 'action' => $this->getData('action'), - 'method' => 'post' - )); + $form = new Varien_Data_Form(['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Tab/Form.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Tab/Form.php index f44e579..1ccd2c5 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Tab/Form.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Edit/Tab/Form.php @@ -78,175 +78,87 @@ protected function _prepareForm() { $job = $this->getJob(); $form = new Varien_Data_Form( - array( - 'id' => 'edit_form', - 'action' => $this->getData('action'), - 'method' => 'post' - ) + ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'] ); - $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('General'))); + $fieldset = $form->addFieldset('base_fieldset', ['legend' => $this->__('General')]); $this->_addElementTypes($fieldset); $fieldset->addField( 'job_code', 'text', - array( - 'name' => 'job_code', - 'label' => $this->__('Job code'), - 'title' => $this->__('Job code'), - 'class' => '', - 'required' => true, - 'disabled' => $job->getJobCode() ? true : false, - ) + ['name' => 'job_code', 'label' => $this->__('Job code'), 'title' => $this->__('Job code'), 'class' => '', 'required' => true, 'disabled' => $job->getJobCode() ? true : false] ); $fieldset->addField( 'name', 'text', - array( - 'name' => 'name', - 'label' => $this->__('Name'), - 'title' => $this->__('Name'), - 'class' => '', - 'required' => false, - 'after_element_html' => $this->getOriginalValueSnippet($job, 'name'), - ) + ['name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'class' => '', 'required' => false, 'after_element_html' => $this->getOriginalValueSnippet($job, 'name')] ); $fieldset->addField( 'short_description', 'textarea', - array( - 'name' => 'short_description', - 'label' => $this->__('Short description'), - 'title' => $this->__('Short description'), - 'class' => '', - 'required' => false, - 'after_element_html' => $this->getOriginalValueSnippet($job, 'short_description'), - ) + ['name' => 'short_description', 'label' => $this->__('Short description'), 'title' => $this->__('Short description'), 'class' => '', 'required' => false, 'after_element_html' => $this->getOriginalValueSnippet($job, 'short_description')] ); $fieldset->addField( 'description', 'textarea', - array( - 'name' => 'description', - 'label' => $this->__('Description'), - 'title' => $this->__('Description'), - 'class' => '', - 'required' => false, - 'after_element_html' => $this->getOriginalValueSnippet($job, 'description'), - ) + ['name' => 'description', 'label' => $this->__('Description'), 'title' => $this->__('Description'), 'class' => '', 'required' => false, 'after_element_html' => $this->getOriginalValueSnippet($job, 'description')] ); $fieldset->addField( 'run_model', 'text', - array( - 'name' => 'run_model', - 'label' => $this->__('Run model'), - 'title' => $this->__('Run model'), - 'class' => '', - 'required' => true, - 'note' => $this->__('e.g. "aoe_scheduler/task_heartbeat::run"'), - 'after_element_html' => $this->getOriginalValueSnippet($job, 'run/model'), - ) + ['name' => 'run_model', 'label' => $this->__('Run model'), 'title' => $this->__('Run model'), 'class' => '', 'required' => true, 'note' => $this->__('e.g. "aoe_scheduler/task_heartbeat::run"'), 'after_element_html' => $this->getOriginalValueSnippet($job, 'run/model')] ); $fieldset->addField( 'is_active', 'select', - array( - 'name' => 'is_active', - 'label' => $this->__('Status'), - 'title' => $this->__('Status'), - 'required' => true, - 'options' => array( - 0 => $this->__('Disabled'), - 1 => $this->__('Enabled') - ), - 'after_element_html' => $this->getOriginalValueSnippetFlag($job, 'is_active', 'Enabled', 'Disabled'), - ) + ['name' => 'is_active', 'label' => $this->__('Status'), 'title' => $this->__('Status'), 'required' => true, 'options' => [0 => $this->__('Disabled'), 1 => $this->__('Enabled')], 'after_element_html' => $this->getOriginalValueSnippetFlag($job, 'is_active', 'Enabled', 'Disabled')] ); - $fieldset = $form->addFieldset('cron_fieldset', array('legend' => $this->__('Scheduling'))); + $fieldset = $form->addFieldset('cron_fieldset', ['legend' => $this->__('Scheduling')]); $this->_addElementTypes($fieldset); $fieldset->addField( 'schedule_config_path', 'text', - array( - 'name' => 'schedule_config_path', - 'label' => $this->__('Cron configuration path'), - 'title' => $this->__('Cron configuration path'), - 'class' => '', - 'required' => false, - 'note' => $this->__( - 'Path to system configuration containing the cron configuration for this job. (e.g. system/cron/scheduler_cron_expr_heartbeat) This configuration - if set - has a higher priority over the cron expression configured with the job directly.' - ), - 'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/config_path'), - ) + ['name' => 'schedule_config_path', 'label' => $this->__('Cron configuration path'), 'title' => $this->__('Cron configuration path'), 'class' => '', 'required' => false, 'note' => $this->__( + 'Path to system configuration containing the cron configuration for this job. (e.g. system/cron/scheduler_cron_expr_heartbeat) This configuration - if set - has a higher priority over the cron expression configured with the job directly.' + ), 'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/config_path')] ); $fieldset->addField( 'schedule_cron_expr', 'text', - array( - 'name' => 'schedule_cron_expr', - 'label' => $this->__('Cron expression'), - 'title' => $this->__('Cron expression'), - 'required' => false, - 'note' => $this->__('e.g "*/5 * * * *" or "always"'), - 'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/cron_expr'), - ) + ['name' => 'schedule_cron_expr', 'label' => $this->__('Cron expression'), 'title' => $this->__('Cron expression'), 'required' => false, 'note' => $this->__('e.g "*/5 * * * *" or "always"'), 'after_element_html' => $this->getOriginalValueSnippet($job, 'schedule/cron_expr')] ); - $fieldset = $form->addFieldset('parameter_fieldset', array('legend' => $this->__('Extras'))); + $fieldset = $form->addFieldset('parameter_fieldset', ['legend' => $this->__('Extras')]); $this->_addElementTypes($fieldset); $fieldset->addField( 'parameters', 'textarea', - array( - 'name' => 'parameters', - 'label' => $this->__('Parameters'), - 'title' => $this->__('Parameters'), - 'class' => 'textarea', - 'required' => false, - 'note' => $this->__('These parameters will be passed to the model. It is up to the model to specify the format of these parameters (e.g. json/xml/...'), - 'after_element_html' => $this->getOriginalValueSnippet($job, 'parameters'), - ) + ['name' => 'parameters', 'label' => $this->__('Parameters'), 'title' => $this->__('Parameters'), 'class' => 'textarea', 'required' => false, 'note' => $this->__('These parameters will be passed to the model. It is up to the model to specify the format of these parameters (e.g. json/xml/...'), 'after_element_html' => $this->getOriginalValueSnippet($job, 'parameters')] ); $fieldset->addField( 'groups', 'textarea', - array( - 'name' => 'groups', - 'label' => $this->__('Groups'), - 'title' => $this->__('Groups'), - 'class' => 'textarea', - 'required' => false, - 'note' => $this->__('Comma-separated list of groups (tags) that can be used with the include/exclude command line options of scheduler.php'), - 'after_element_html' => $this->getOriginalValueSnippet($job, 'groups'), - ) + ['name' => 'groups', 'label' => $this->__('Groups'), 'title' => $this->__('Groups'), 'class' => 'textarea', 'required' => false, 'note' => $this->__('Comma-separated list of groups (tags) that can be used with the include/exclude command line options of scheduler.php'), 'after_element_html' => $this->getOriginalValueSnippet($job, 'groups')] ); - $fieldset = $form->addFieldset('dependency_fieldset', array('legend' => $this->__('Dependencies'))); + $fieldset = $form->addFieldset('dependency_fieldset', ['legend' => $this->__('Dependencies')]); $this->_addElementTypes($fieldset); $fieldset->addField( 'on_success', 'textarea', - array( - 'name' => 'on_success', - 'label' => $this->__('Run jobs on success'), - 'title' => $this->__('Run jobs on success'), - 'class' => 'textarea', - 'required' => false, - 'note' => $this->__('Comma-separated list of job codes that will be scheduled after the current cron job has completed successfully.') - ) + ['name' => 'on_success', 'label' => $this->__('Run jobs on success'), 'title' => $this->__('Run jobs on success'), 'class' => 'textarea', 'required' => false, 'note' => $this->__('Comma-separated list of job codes that will be scheduled after the current cron job has completed successfully.')] ); $this->setForm($form); @@ -284,7 +196,7 @@ protected function getOriginalValueSnippetFlag(Aoe_Scheduler_Model_Job $job, $ke return ''; } - $value = $this->__(!in_array($xmlJobData[$key], array(false, 'false', 0, '0'), true) ? $trueLabel : $falseLabel); + $value = $this->__(!in_array($xmlJobData[$key], [false, 'false', 0, '0'], true) ? $trueLabel : $falseLabel); return '
Original: ' . $value . '
'; } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Grid.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Grid.php index a21e0dc..e434724 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Grid.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Job/Grid.php @@ -44,33 +44,21 @@ protected function _prepareMassaction() $this->getMassactionBlock()->setFormFieldName('codes'); $this->getMassactionBlock()->addItem( 'schedule', - array( - 'label' => $this->__('Schedule now'), - 'url' => $this->getUrl('*/*/scheduleNow'), - ) + ['label' => $this->__('Schedule now'), 'url' => $this->getUrl('*/*/scheduleNow')] ); if (Mage::getStoreConfig('system/cron/enableRunNow')) { $this->getMassactionBlock()->addItem( 'run', - array( - 'label' => $this->__('Run now'), - 'url' => $this->getUrl('*/*/runNow'), - ) + ['label' => $this->__('Run now'), 'url' => $this->getUrl('*/*/runNow')] ); } $this->getMassactionBlock()->addItem( 'disable', - array( - 'label' => $this->__('Disable'), - 'url' => $this->getUrl('*/*/disable'), - ) + ['label' => $this->__('Disable'), 'url' => $this->getUrl('*/*/disable')] ); $this->getMassactionBlock()->addItem( 'enable', - array( - 'label' => $this->__('Enable'), - 'url' => $this->getUrl('*/*/enable'), - ) + ['label' => $this->__('Enable'), 'url' => $this->getUrl('*/*/enable')] ); return $this; } @@ -85,82 +73,42 @@ protected function _prepareColumns() { $this->addColumn( 'job_code', - array( - 'header' => $this->__('Job code'), - 'index' => 'job_code', - 'sortable' => false, - ) + ['header' => $this->__('Job code'), 'index' => 'job_code', 'sortable' => false] ); $this->addColumn( 'name', - array( - 'header' => $this->__('Name'), - 'index' => 'name', - 'sortable' => false, - ) + ['header' => $this->__('Name'), 'index' => 'name', 'sortable' => false] ); $this->addColumn( 'short_description', - array( - 'header' => $this->__('Short Description'), - 'index' => 'short_description', - 'sortable' => false, - ) + ['header' => $this->__('Short Description'), 'index' => 'short_description', 'sortable' => false] ); $this->addColumn( 'schedule_cron_expr', - array( - 'header' => $this->__('Cron expression'), - 'index' => 'schedule_cron_expr', - 'sortable' => false, - 'frame_callback' => array($this, 'decorateCronExpression'), - ) + ['header' => $this->__('Cron expression'), 'index' => 'schedule_cron_expr', 'sortable' => false, 'frame_callback' => [$this, 'decorateCronExpression']] ); $this->addColumn( 'run_model', - array( - 'header' => $this->__('Run model'), - 'index' => 'run_model', - 'sortable' => false, - ) + ['header' => $this->__('Run model'), 'index' => 'run_model', 'sortable' => false] ); $this->addColumn( 'parameters', - array( - 'header' => $this->__('Parameters'), - 'index' => 'parameters', - 'sortable' => false, - 'frame_callback' => array($this, 'decorateTrim'), - ) + ['header' => $this->__('Parameters'), 'index' => 'parameters', 'sortable' => false, 'frame_callback' => [$this, 'decorateTrim']] ); $this->addColumn( 'groups', - array( - 'header' => $this->__('Groups'), - 'index' => 'groups', - 'sortable' => false, - 'frame_callback' => array($this, 'decorateTrim'), - ) + ['header' => $this->__('Groups'), 'index' => 'groups', 'sortable' => false, 'frame_callback' => [$this, 'decorateTrim']] ); $this->addColumn( 'type', - array( - 'header' => $this->__('Type'), - 'sortable' => false, - 'frame_callback' => array($this, 'decorateType'), - ) + ['header' => $this->__('Type'), 'sortable' => false, 'frame_callback' => [$this, 'decorateType']] ); $this->addColumn( 'is_active', - array( - 'header' => $this->__('Status'), - 'index' => 'is_active', - 'sortable' => false, - 'frame_callback' => array($this, 'decorateStatus'), - ) + ['header' => $this->__('Status'), 'index' => 'is_active', 'sortable' => false, 'frame_callback' => [$this, 'decorateStatus']] ); return parent::_prepareColumns(); } @@ -188,7 +136,6 @@ public function decorateStatus($value) * Decorate cron expression * * @param $value - * @param Aoe_Scheduler_Model_Job $job * * @return string */ @@ -215,7 +162,6 @@ public function decorateTrim($value) * Decorate cron expression * * @param $value - * @param Aoe_Scheduler_Model_Job $job * * @return string */ @@ -233,7 +179,7 @@ public function decorateType($value, Aoe_Scheduler_Model_Job $job) */ public function getRowUrl($row) { - return $this->getUrl('*/*/edit', array('job_code' => $row->getJobCode())); + return $this->getUrl('*/*/edit', ['job_code' => $row->getJobCode()]); } /** @@ -243,6 +189,6 @@ public function getRowUrl($row) */ public function getGridUrl() { - return $this->getUrl('adminhtml/job/index', array('_current' => true)); + return $this->getUrl('adminhtml/job/index', ['_current' => true]); } } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler.php index bde863b..8b25759 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler.php @@ -29,17 +29,11 @@ protected function _prepareLayout() $this->removeButton('add'); $this->_addButton( 'add_new', - array( - 'label' => $this->__('Generate Schedule'), - 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')", - ) + ['label' => $this->__('Generate Schedule'), 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')"] ); $this->_addButton( 'configure', - array( - 'label' => $this->__('Cron Configuration'), - 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', array('section' => 'system'))}#system_cron')", - ) + ['label' => $this->__('Cron Configuration'), 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', ['section' => 'system'])}#system_cron')"] ); return parent::_prepareLayout(); } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler/Grid.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler/Grid.php index e234aed..c74f763 100755 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler/Grid.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Scheduler/Grid.php @@ -46,17 +46,11 @@ protected function _prepareMassaction() $this->getMassactionBlock()->setFormFieldName('schedule_ids'); $this->getMassactionBlock()->addItem( 'delete', - array( - 'label' => $this->__('Delete'), - 'url' => $this->getUrl('*/*/delete'), - ) + ['label' => $this->__('Delete'), 'url' => $this->getUrl('*/*/delete')] ); $this->getMassactionBlock()->addItem( 'kill', - array( - 'label' => $this->__('Kill'), - 'url' => $this->getUrl('*/*/kill'), - ) + ['label' => $this->__('Kill'), 'url' => $this->getUrl('*/*/kill')] ); return $this; } @@ -73,15 +67,9 @@ protected function _prepareColumns() $this->addColumn( 'schedule_id', - array( - 'header' => $this->__('Id'), - 'index' => 'schedule_id', - ) - ); - $config = array( - 'header' => $this->__('Job'), - 'index' => 'job_code', + ['header' => $this->__('Id'), 'index' => 'schedule_id'] ); + $config = ['header' => $this->__('Job'), 'index' => 'job_code']; switch (Mage::getStoreConfig('system/cron/listCodeFilterType')) { case Aoe_Scheduler_Model_Adminhtml_System_Config_Source_List_Code_Filtertype::SELECT: $config['type'] = 'options'; @@ -97,93 +85,47 @@ protected function _prepareColumns() ); $this->addColumn( 'created_at', - array( - 'header' => $this->__('Created'), - 'index' => 'created_at', - 'type' => 'datetime' - ) + ['header' => $this->__('Created'), 'index' => 'created_at', 'type' => 'datetime'] ); $this->addColumn( 'scheduled_at', - array( - 'header' => $this->__('Scheduled'), - 'index' => 'scheduled_at', - 'type' => 'datetime' - ) + ['header' => $this->__('Scheduled'), 'index' => 'scheduled_at', 'type' => 'datetime'] ); $this->addColumn( 'executed_at', - array( - 'header' => $this->__('Executed'), - 'index' => 'executed_at', - 'type' => 'datetime' - ) + ['header' => $this->__('Executed'), 'index' => 'executed_at', 'type' => 'datetime'] ); $this->addColumn( 'last_seen', - array( - 'header' => $this->__('Last seen'), - 'index' => 'last_seen', - 'type' => 'datetime' - ) + ['header' => $this->__('Last seen'), 'index' => 'last_seen', 'type' => 'datetime'] ); $this->addColumn( 'eta', - array( - 'header' => $this->__('ETA'), - 'index' => 'eta', - 'type' => 'datetime' - ) + ['header' => $this->__('ETA'), 'index' => 'eta', 'type' => 'datetime'] ); $this->addColumn( 'finished_at', - array( - 'header' => $this->__('Finished'), - 'index' => 'finished_at', - 'type' => 'datetime' - ) + ['header' => $this->__('Finished'), 'index' => 'finished_at', 'type' => 'datetime'] ); $this->addColumn( 'messages', - array( - 'header' => $this->__('Messages'), - 'index' => 'messages', - 'frame_callback' => array($this, 'decorateMessages') - ) + ['header' => $this->__('Messages'), 'index' => 'messages', 'frame_callback' => [$this, 'decorateMessages']] ); $this->addColumn( 'memory_usage', - array( - 'header' => $this->__('Memory Usage'), - 'index' => 'memory_usage', - 'type' => 'number', - 'renderer' => 'aoe_scheduler/adminhtml_scheduler_renderer_memory', - ) + ['header' => $this->__('Memory Usage'), 'index' => 'memory_usage', 'type' => 'number', 'renderer' => 'aoe_scheduler/adminhtml_scheduler_renderer_memory'] ); $this->addColumn( 'host', - array( - 'header' => $this->__('Host'), - 'index' => 'host', - ) + ['header' => $this->__('Host'), 'index' => 'host'] ); $this->addColumn( 'pid', - array( - 'header' => $this->__('Pid'), - 'index' => 'pid', - 'width' => '50', - ) + ['header' => $this->__('Pid'), 'index' => 'pid', 'width' => '50'] ); $this->addColumn( 'status', - array( - 'header' => $this->__('Status'), - 'index' => 'status', - 'frame_callback' => array($viewHelper, 'decorateStatus'), - 'type' => 'options', - 'options' => Mage::getSingleton('cron/schedule')->getAllStatuses() - ) + ['header' => $this->__('Status'), 'index' => 'status', 'frame_callback' => [$viewHelper, 'decorateStatus'], 'type' => 'options', 'options' => Mage::getSingleton('cron/schedule')->getAllStatuses()] ); return parent::_prepareColumns(); @@ -194,7 +136,6 @@ protected function _prepareColumns() * Decorate message * * @param string $value - * @param Aoe_Scheduler_Model_Schedule $row * * @return string */ @@ -245,6 +186,6 @@ protected function _filterStoreCondition($collection, $column) */ public function getGridUrl() { - return $this->getUrl('adminhtml/scheduler/index', array('_current' => true)); + return $this->getUrl('adminhtml/scheduler/index', ['_current' => true]); } } diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Timeline.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Timeline.php index c4afbb6..107b072 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/Timeline.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/Timeline.php @@ -26,7 +26,7 @@ class Aoe_Scheduler_Block_Adminhtml_Timeline extends Mage_Adminhtml_Block_Widget /** * @var array schedules */ - protected $schedules = array(); + protected $schedules = []; /** @@ -50,14 +50,8 @@ protected function _construct() protected function _prepareLayout() { $this->removeButton('add'); - $this->_addButton('add_new', array( - 'label' => $this->__('Generate Schedule'), - 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')", - )); - $this->_addButton('configure', array( - 'label' => $this->__('Cron Configuration'), - 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', array('section' => 'system'))}#system_cron')", - )); + $this->_addButton('add_new', ['label' => $this->__('Generate Schedule'), 'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')"]); + $this->_addButton('configure', ['label' => $this->__('Cron Configuration'), 'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', ['section' => 'system'])}#system_cron')"]); return parent::_prepareLayout(); } @@ -192,7 +186,6 @@ public function getEndtime() /** * Get attributes for div representing a gantt element * - * @param Aoe_Scheduler_Model_Schedule $schedule * @return string */ public function getGanttDivAttributes(Aoe_Scheduler_Model_Schedule $schedule) @@ -201,7 +194,7 @@ public function getGanttDivAttributes(Aoe_Scheduler_Model_Schedule $schedule) if ($schedule->getStatus() == Aoe_Scheduler_Model_Schedule::STATUS_RUNNING) { $duration = time() - strtotime($schedule->getStarttime()); } else { - $duration = $schedule->getDuration() ? $schedule->getDuration() : 0; + $duration = $schedule->getDuration() ?: 0; } $duration = $duration / $this->zoom; $duration = ceil($duration / 4) * 4 - 1; // round to numbers dividable by 4, then remove 1 px border @@ -247,7 +240,7 @@ public function _toHtml() { $html = parent::_toHtml(); if (!$html && !Mage::getStoreConfigFlag('dev/template/allow_symlink')) { - $url = $this->getUrl('adminhtml/system_config/edit', array('section' => 'dev')) . '#dev_template'; + $url = $this->getUrl('adminhtml/system_config/edit', ['section' => 'dev']) . '#dev_template'; $html = $this->__('Warning: You installed Aoe_Scheduler using symlinks (e.g. via modman), but forgot to allow symlinks for template files! Please go to System > Configuration > Advanced > Developer > Template Settings and set "Allow Symlinks" to "yes"', $url); } return $html; diff --git a/app/code/community/Aoe/Scheduler/Block/Adminhtml/TimelineDetail.php b/app/code/community/Aoe/Scheduler/Block/Adminhtml/TimelineDetail.php index 3a5935b..4da781c 100644 --- a/app/code/community/Aoe/Scheduler/Block/Adminhtml/TimelineDetail.php +++ b/app/code/community/Aoe/Scheduler/Block/Adminhtml/TimelineDetail.php @@ -22,7 +22,6 @@ class Aoe_Scheduler_Block_Adminhtml_TimelineDetail extends Mage_Adminhtml_Block_ /** * Set schedule * - * @param Aoe_Scheduler_Model_Schedule $schedule * @return Aoe_Scheduler_Block_Adminhtml_TimelineDetail */ public function setSchedule(Aoe_Scheduler_Model_Schedule $schedule) diff --git a/app/code/community/Aoe/Scheduler/Controller/AbstractController.php b/app/code/community/Aoe/Scheduler/Controller/AbstractController.php index 76f2d6d..78127ab 100755 --- a/app/code/community/Aoe/Scheduler/Controller/AbstractController.php +++ b/app/code/community/Aoe/Scheduler/Controller/AbstractController.php @@ -38,7 +38,7 @@ protected function _initAction() // check configuration if (Mage::getStoreConfig('system/cron/schedule_generate_every') > Mage::getStoreConfig('system/cron/schedule_ahead_for')) { - $this->_getSession()->addError($this->__('Configuration problem. "Generate Schedules Every" is higher than "Schedule Ahead for". Please check your configuration settings.', $this->getUrl('adminhtml/system_config/edit', array('section' => 'system')) . '#system_cron')); + $this->_getSession()->addError($this->__('Configuration problem. "Generate Schedules Every" is higher than "Schedule Ahead for". Please check your configuration settings.', $this->getUrl('adminhtml/system_config/edit', ['section' => 'system']) . '#system_cron')); } // Check the cron is being run as the configured user and whether or not to show the message @@ -115,7 +115,7 @@ protected function _checkCronUser() 'Scheduler appears to be running as system user "%s". It should be running as "%s". Use %s.%s Don\'t show this again.', $helper->getLastRunUser(), $configuredUser, - $this->getUrl('adminhtml/scheduler/setConfiguredUser', array('user' => $helper->getLastRunUser())), + $this->getUrl('adminhtml/scheduler/setConfiguredUser', ['user' => $helper->getLastRunUser()]), $helper->getLastRunUser(), ($helper->getShouldKillOnWrongUser()) ? ' Warning! Jobs will not run until this is resolved!.' : '', $this->getUrl('adminhtml/scheduler/hideUserWarning') @@ -127,7 +127,7 @@ protected function _checkCronUser() $this->__( 'No default user is configured for who should run the cron. Click here to define one. We suggest ' . 'using "%s". Don\'t show this again.', - $this->getUrl('adminhtml/system_config/edit', array('section' => 'system')) . '#system_cron', + $this->getUrl('adminhtml/system_config/edit', ['section' => 'system']) . '#system_cron', $helper->getRunningUser(), // suggest the user that runs the web server, makes sense $this->getUrl('adminhtml/scheduler/hideUserWarning') ) diff --git a/app/code/community/Aoe/Scheduler/Helper/Data.php b/app/code/community/Aoe/Scheduler/Helper/Data.php index 02e94d6..3272ebe 100644 --- a/app/code/community/Aoe/Scheduler/Helper/Data.php +++ b/app/code/community/Aoe/Scheduler/Helper/Data.php @@ -8,16 +8,16 @@ class Aoe_Scheduler_Helper_Data extends Mage_Core_Helper_Abstract { - const XML_PATH_MAX_RUNNING_TIME = 'system/cron/max_running_time'; - const XML_PATH_EMAIL_TEMPLATE = 'system/cron/error_email_template'; - const XML_PATH_EMAIL_IDENTITY = 'system/cron/error_email_identity'; - const XML_PATH_EMAIL_RECIPIENT = 'system/cron/error_email'; - const XML_PATH_CRON_USER = 'system/cron/cronUser'; - const XML_PATH_KILL_ON_WRONG_USER = 'system/cron/killOnIncorrectUser'; - const XML_PATH_SHOW_WRONG_USER_MSG = 'system/cron/showCronUserMessage'; - const XML_PATH_RUN_ONLY_IF_CACHE_PREFIX_ID_MATCHES = 'system/cron/runOnlyIfCachePrefixIdMatches'; + public const XML_PATH_MAX_RUNNING_TIME = 'system/cron/max_running_time'; + public const XML_PATH_EMAIL_TEMPLATE = 'system/cron/error_email_template'; + public const XML_PATH_EMAIL_IDENTITY = 'system/cron/error_email_identity'; + public const XML_PATH_EMAIL_RECIPIENT = 'system/cron/error_email'; + public const XML_PATH_CRON_USER = 'system/cron/cronUser'; + public const XML_PATH_KILL_ON_WRONG_USER = 'system/cron/killOnIncorrectUser'; + public const XML_PATH_SHOW_WRONG_USER_MSG = 'system/cron/showCronUserMessage'; + public const XML_PATH_RUN_ONLY_IF_CACHE_PREFIX_ID_MATCHES = 'system/cron/runOnlyIfCachePrefixIdMatches'; - const VAR_LAST_RUN_USER_CODE = 'aoescheduler_lastrunuser'; + public const VAR_LAST_RUN_USER_CODE = 'aoescheduler_lastrunuser'; protected $groupsToJobsMap = null; @@ -38,7 +38,7 @@ public function trimExplode($delim, $string, $removeEmptyValues = false) $result = array_map('trim', $explodedValues); if ($removeEmptyValues) { - $temp = array(); + $temp = []; foreach ($result as $value) { if ($value !== '') { $temp[] = $value; @@ -114,11 +114,12 @@ public function decorateTime($value, $echoToday = false, $dateFormat = null) } else { $dateConverter = Mage::getModel('core/date'); $value = $dateConverter->date($dateFormat, $value); - $replace = array( - $dateConverter->date('Y-m-d ', time()) => $echoToday ? Mage::helper('aoe_scheduler')->__('Today') . ', ' : '', // today + $replace = [ + $dateConverter->date('Y-m-d ', time()) => $echoToday ? Mage::helper('aoe_scheduler')->__('Today') . ', ' : '', + // today $dateConverter->date('Y-m-d ', strtotime('+1 day')) => Mage::helper('aoe_scheduler')->__('Tomorrow') . ', ', $dateConverter->date('Y-m-d ', strtotime('-1 day')) => Mage::helper('aoe_scheduler')->__('Yesterday') . ', ', - ); + ]; $value = str_replace(array_keys($replace), array_values($replace), $value); } return $value; @@ -146,16 +147,13 @@ public function getLastExecutionTime($jobCode) $schedules = Mage::getModel('cron/schedule')->getCollection(); /* @var $schedules Mage_Cron_Model_Mysql4_Schedule_Collection */ $schedules->getSelect()->limit(1)->order('executed_at DESC'); $schedules->addFieldToFilter( - array('status'), - array( - array('eq' => Aoe_Scheduler_Model_Schedule::STATUS_SUCCESS), - array('eq' => Aoe_Scheduler_Model_Schedule::STATUS_REPEAT) - ) + ['status'], + [['eq' => Aoe_Scheduler_Model_Schedule::STATUS_SUCCESS], ['eq' => Aoe_Scheduler_Model_Schedule::STATUS_REPEAT]] ); $schedules->addFieldToFilter('job_code', $jobCode); $schedules->load(); - if (count($schedules) == 0) { + if ((is_countable($schedules) ? count($schedules) : 0) == 0) { return false; } $executedAt = $schedules->getFirstItem()->getExecutedAt(); @@ -197,8 +195,6 @@ public function isDisabled($jobCode) * Check if a job matches the group include/exclude lists * * @param $jobCode - * @param array $include - * @param array $exclude * @return mixed */ public function matchesIncludeExclude($jobCode, array $include, array $exclude) @@ -210,7 +206,7 @@ public function matchesIncludeExclude($jobCode, array $include, array $exclude) sort($exclude); $key = $jobCode . '|' . implode(',', $include) . '|' . implode(',', $exclude); - static $cache = array(); + static $cache = []; if (!isset($cache[$key])) { if (count($include) == 0 && count($exclude) == 0) { $cache[$key] = true; @@ -236,7 +232,7 @@ public function matchesIncludeExclude($jobCode, array $include, array $exclude) public function getGroupsToJobsMap($forceRebuild = false) { if ($this->groupsToJobsMap === null || $forceRebuild) { - $map = array(); + $map = []; /* @var $jobs Aoe_Scheduler_Model_Resource_Job_Collection */ $jobs = Mage::getSingleton('aoe_scheduler/job')->getCollection(); @@ -272,7 +268,6 @@ public function addGroupJobs(array $jobs, array $groups) /** * Send error mail * - * @param Aoe_Scheduler_Model_Schedule $schedule * @param $error * @return void */ @@ -289,13 +284,13 @@ public function sendErrorMail(Aoe_Scheduler_Model_Schedule $schedule, $error) foreach ($recipients as $recipient) { $emailTemplate = Mage::getModel('core/email_template'); /* @var $emailTemplate Mage_Core_Model_Email_Template */ - $emailTemplate->setDesignConfig(array('area' => 'backend')); + $emailTemplate->setDesignConfig(['area' => 'backend']); $emailTemplate->sendTransactional( Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY), $recipient, null, - array('error' => $error, 'schedule' => $schedule) + ['error' => $error, 'schedule' => $schedule] ); } @@ -319,7 +314,7 @@ public function getCallBack($runModel) if (!method_exists($model, $run[2])) { Mage::throwException(Mage::helper('cron')->__('Invalid callback: Method for %s::%s does not exist', $run[1], $run[2])); } - $callback = array($model, $run[2]); + $callback = [$model, $run[2]]; return $callback; } @@ -335,7 +330,7 @@ public function validateCronExpression($cronExpression) $schedule = Mage::getModel('cron/schedule'); /* @var $schedule Mage_Cron_Model_Schedule */ $schedule->setCronExpr($cronExpression); - } catch (Exception $e) { + } catch (Exception) { return false; } return true; diff --git a/app/code/community/Aoe/Scheduler/Helper/GracefulDead.php b/app/code/community/Aoe/Scheduler/Helper/GracefulDead.php index 7e2105f..016537b 100644 --- a/app/code/community/Aoe/Scheduler/Helper/GracefulDead.php +++ b/app/code/community/Aoe/Scheduler/Helper/GracefulDead.php @@ -16,11 +16,11 @@ public static function configure() { static $configured = false; if (!$configured) { - register_shutdown_function(array('Aoe_Scheduler_Helper_GracefulDead', 'beforeDyingShutdown')); + register_shutdown_function(['Aoe_Scheduler_Helper_GracefulDead', 'beforeDyingShutdown']); if (extension_loaded('pcntl') && function_exists('pcntl_signal')) { declare(ticks = 1); - pcntl_signal(SIGINT, array('Aoe_Scheduler_Helper_GracefulDead', 'beforeDyingSigint')); // CTRL + C - pcntl_signal(SIGTERM, array('Aoe_Scheduler_Helper_GracefulDead', 'beforeDyingSigterm')); // kill%s', $key, $messages)); @@ -139,7 +139,7 @@ protected function getMassActionCodes($key = 'codes') { $codes = $this->getRequest()->getParam($key); if (!is_array($codes)) { - return array(); + return []; } $allowedCodes = Mage::getSingleton('aoe_scheduler/job')->getResource()->getJobCodes(); $codes = array_intersect(array_unique(array_filter(array_map('trim', $codes))), $allowedCodes); @@ -202,7 +202,7 @@ public function saveAction() $job->addData($data); //validating if (!$this->_validatePostData($data)) { - $this->_redirect('*/*/edit', array('job_code' => $job->getJobCode(), '_current' => true)); + $this->_redirect('*/*/edit', ['job_code' => $job->getJobCode(), '_current' => true]); return; } @@ -218,7 +218,7 @@ public function saveAction() $this->_getSession()->setFormData(false); // check if 'Save and Continue' if ($this->getRequest()->getParam('back', false)) { - $this->_redirect('*/*/edit', array('job_code' => $job->getJobCode(), '_current' => true)); + $this->_redirect('*/*/edit', ['job_code' => $job->getJobCode(), '_current' => true]); return; } @@ -241,11 +241,11 @@ public function saveAction() } $this->_getSession()->setFormData($data); - $this->_redirect('*/*/edit', array('job_code' => $this->getRequest()->getParam('job_code'))); + $this->_redirect('*/*/edit', ['job_code' => $this->getRequest()->getParam('job_code')]); return; } - $this->_redirect('*/*/', array('_current' => true)); + $this->_redirect('*/*/', ['_current' => true]); } /** diff --git a/app/code/community/Aoe/Scheduler/data/aoescheduler_setup/data-upgrade-0.5.4-0.5.5.php b/app/code/community/Aoe/Scheduler/data/aoescheduler_setup/data-upgrade-0.5.4-0.5.5.php index c6b5f3e..957151a 100644 --- a/app/code/community/Aoe/Scheduler/data/aoescheduler_setup/data-upgrade-0.5.4-0.5.5.php +++ b/app/code/community/Aoe/Scheduler/data/aoescheduler_setup/data-upgrade-0.5.4-0.5.5.php @@ -9,12 +9,7 @@ foreach ($codes as $code) { $this->getConnection()->insertOnDuplicate( $this->getTable('core/config_data'), - array( - 'scope' => 'default', - 'scope_id' => 0, - 'path' => 'crontab/jobs/' . $code . '/is_active', - 'value' => 0, - ) + ['scope' => 'default', 'scope_id' => 0, 'path' => 'crontab/jobs/' . $code . '/is_active', 'value' => 0] ); } } @@ -22,9 +17,5 @@ // Remove old config setting $this->getConnection()->delete( $this->getTable('core/config_data'), - array( - 'scope = ?' => 'default', - 'scope_id = ?' => 0, - 'path = ?' => 'system/cron/disabled_crons' - ) + ['scope = ?' => 'default', 'scope_id = ?' => 0, 'path = ?' => 'system/cron/disabled_crons'] ); diff --git a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/install-1.0.0.php b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/install-1.0.0.php index 3e47713..cabf6bc 100644 --- a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/install-1.0.0.php +++ b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/install-1.0.0.php @@ -12,29 +12,7 @@ 'parameters' ); -$columns = array( - 'parameters' => "TEXT NULL COMMENT 'Serialized Parameters' AFTER finished_at", - 'eta' => "timestamp NULL DEFAULT NULL COMMENT 'Estimated Time of Arrival'", - 'host' => "varchar(255) NULL COMMENT 'Host running this job'", - 'pid' => "varchar(255) NULL COMMENT 'Process id of this job'", - 'progress_message' => "TEXT NULL COMMENT 'Progress message'", - 'last_seen' => "timestamp NULL DEFAULT NULL COMMENT 'Last seen'", - 'kill_request' => "timestamp NULL DEFAULT NULL COMMENT 'Kill Request'", - 'scheduled_by' => array ( - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => true, - 'default' => null, - 'comment' => 'Scheduled by' - ), - 'scheduled_reason' => array( - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 256, - 'nullable' => true, - 'default' => null, - 'comment' => 'Scheduled Reason' - ) -); +$columns = ['parameters' => "TEXT NULL COMMENT 'Serialized Parameters' AFTER finished_at", 'eta' => "timestamp NULL DEFAULT NULL COMMENT 'Estimated Time of Arrival'", 'host' => "varchar(255) NULL COMMENT 'Host running this job'", 'pid' => "varchar(255) NULL COMMENT 'Process id of this job'", 'progress_message' => "TEXT NULL COMMENT 'Progress message'", 'last_seen' => "timestamp NULL DEFAULT NULL COMMENT 'Last seen'", 'kill_request' => "timestamp NULL DEFAULT NULL COMMENT 'Kill Request'", 'scheduled_by' => ['type' => Varien_Db_Ddl_Table::TYPE_INTEGER, 'unsigned' => true, 'nullable' => true, 'default' => null, 'comment' => 'Scheduled by'], 'scheduled_reason' => ['type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => 256, 'nullable' => true, 'default' => null, 'comment' => 'Scheduled Reason']]; foreach ($columns as $columnName => $definition) { if ($this->getConnection()->tableColumnExists($tableName, $columnName)) { diff --git a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.4.0-0.4.1.php b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.4.0-0.4.1.php index 6e12db5..33be2a8 100644 --- a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.4.0-0.4.1.php +++ b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.4.0-0.4.1.php @@ -9,7 +9,7 @@ try { $installer->getConnection()->dropColumn($tableName, 'parameters'); -} catch (Exception $e) { +} catch (Exception) { // ignored intentionally } diff --git a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.0-0.5.1.php b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.0-0.5.1.php index 273c3b7..621e22b 100644 --- a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.0-0.5.1.php +++ b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.0-0.5.1.php @@ -4,20 +4,8 @@ $installer->startSetup(); -$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'scheduled_by', array( - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => true, - 'default' => null, - 'comment' => 'Scheduled by' -)); +$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'scheduled_by', ['type' => Varien_Db_Ddl_Table::TYPE_INTEGER, 'unsigned' => true, 'nullable' => true, 'default' => null, 'comment' => 'Scheduled by']); -$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'scheduled_reason', array( - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 256, - 'nullable' => true, - 'default' => null, - 'comment' => 'Scheduled Reason' -)); +$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'scheduled_reason', ['type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => 256, 'nullable' => true, 'default' => null, 'comment' => 'Scheduled Reason']); $installer->endSetup(); diff --git a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.4-1.1.0.php b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.4-1.1.0.php index 576c978..c6cde4f 100644 --- a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.4-1.1.0.php +++ b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-0.5.4-1.1.0.php @@ -5,13 +5,7 @@ $this->getConnection()->modifyColumn( $this->getTable('cron/schedule'), 'status', - array( - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 30, - 'nullable' => false, - 'default' => 'pending', - 'comment' => 'Status' - ) + ['type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => 30, 'nullable' => false, 'default' => 'pending', 'comment' => 'Status'] ); $this->endSetup(); diff --git a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-1.4.0-1.5.0.php b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-1.4.0-1.5.0.php index 2ac07c5..d124c32 100644 --- a/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-1.4.0-1.5.0.php +++ b/app/code/community/Aoe/Scheduler/sql/aoescheduler_setup/mysql4-upgrade-1.4.0-1.5.0.php @@ -4,13 +4,6 @@ $installer->startSetup(); -$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'memory_usage', array( - 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, - 'length' => '12,4', - 'unsigned' => true, - 'nullable' => true, - 'default' => null, - 'comment' => 'Memory Used in MB', -)); +$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'memory_usage', ['type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, 'length' => '12,4', 'unsigned' => true, 'nullable' => true, 'default' => null, 'comment' => 'Memory Used in MB']); $installer->endSetup(); diff --git a/dev/tests/aoe_scheduler/AbstractTest.php b/dev/tests/aoe_scheduler/AbstractTest.php index a368e9e..3a16da9 100755 --- a/dev/tests/aoe_scheduler/AbstractTest.php +++ b/dev/tests/aoe_scheduler/AbstractTest.php @@ -3,8 +3,8 @@ abstract class AbstractTest extends PHPUnit_Framework_TestCase { - protected $jobs = array(); - protected $schedules = array(); + protected $jobs = []; + protected $schedules = []; protected function setUp() { @@ -45,37 +45,29 @@ protected function exec($command) */ public function runCronAlwaysProvider() { - return array( - array(function () { - // trigger dispatch - $observer = Mage::getModel('aoe_scheduler/observer'); /* @var $observer Aoe_Scheduler_Model_Observer */ - $observer->dispatchAlways(new Varien_Event_Observer()); - }), - array(function () { - shell_exec('php ' . Mage::getBaseDir() . '/cron.php'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh cron.php -mdefault 1'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action cron --mode default'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh --mode default'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }) - ); + return [[function () { + // trigger dispatch + $observer = Mage::getModel('aoe_scheduler/observer'); /* @var $observer Aoe_Scheduler_Model_Observer */ + $observer->dispatchAlways(new Varien_Event_Observer()); + }], [function () { + shell_exec('php ' . Mage::getBaseDir() . '/cron.php'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh cron.php -mdefault 1'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action cron --mode default'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh --mode default'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }]]; } /** @@ -85,36 +77,28 @@ public function runCronAlwaysProvider() */ public function runCronDefaultProvider() { - return array( - array(function () { - // trigger dispatch - $observer = Mage::getModel('aoe_scheduler/observer'); /* @var $observer Aoe_Scheduler_Model_Observer */ - $observer->dispatch(new Varien_Event_Observer()); - }), - array(function () { - shell_exec('php ' . Mage::getBaseDir() . '/cron.php'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh cron.php -mdefault 1'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action cron --mode default'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }), - array(function () { - shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh --mode default'); - shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); - }) - ); + return [[function () { + // trigger dispatch + $observer = Mage::getModel('aoe_scheduler/observer'); /* @var $observer Aoe_Scheduler_Model_Observer */ + $observer->dispatch(new Varien_Event_Observer()); + }], [function () { + shell_exec('php ' . Mage::getBaseDir() . '/cron.php'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/sh ' . Mage::getBaseDir() . '/cron.sh cron.php -mdefault 1'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action cron --mode default'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }], [function () { + shell_exec('/bin/bash ' . Mage::getBaseDir() . '/scheduler_cron.sh --mode default'); + shell_exec('cd ' . Mage::getBaseDir() . '/shell && php scheduler.php --action wait'); + }]]; } } diff --git a/dev/tests/aoe_scheduler/bootstrap.php b/dev/tests/aoe_scheduler/bootstrap.php index 252b753..75c92c1 100755 --- a/dev/tests/aoe_scheduler/bootstrap.php +++ b/dev/tests/aoe_scheduler/bootstrap.php @@ -1,13 +1,13 @@ jobs['jobWithGroupAandB'] = $jobWithGroupAandB; // fake schedule generation to avoid it to be generated on the next run: - Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null); + Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, ['crontab'], null); } /** @@ -52,7 +52,7 @@ public function scheduleJobAndRunCron() if ($sameRequest) { // dispatch event - $event = new Varien_Event_Observer(array('include_groups' => array($this->groups['groupA']))); + $event = new Varien_Event_Observer(['include_groups' => [$this->groups['groupA']]]); $observer = new Aoe_Scheduler_Model_Observer(); $observer->dispatch($event); } else { diff --git a/dev/tests/aoe_scheduler/tests/CronGroupsWhiteListTest.php b/dev/tests/aoe_scheduler/tests/CronGroupsWhiteListTest.php index 9f2cbce..6b29303 100755 --- a/dev/tests/aoe_scheduler/tests/CronGroupsWhiteListTest.php +++ b/dev/tests/aoe_scheduler/tests/CronGroupsWhiteListTest.php @@ -3,7 +3,7 @@ class CronGroupsWhiteListTest extends AbstractTest { - protected $groups = array(); + protected $groups = []; protected function setUp() { @@ -46,7 +46,7 @@ protected function setUp() } // fake schedule generation to avoid it to be generated on the next run: - Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null); + Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, ['crontab'], null); } /** @@ -72,11 +72,11 @@ public function scheduleJobAndRunCron() $this->assertTrue(in_array($this->schedules['jobWithGroupAandB']->getJobCode(), $map[$this->groups['groupA']])); $this->assertTrue(in_array($this->schedules['jobWithGroupAandB']->getJobCode(), $map[$this->groups['groupB']])); - $includeJobs = $helper->addGroupJobs(array(), array($this->groups['groupA'])); + $includeJobs = $helper->addGroupJobs([], [$this->groups['groupA']]); $this->assertTrue(in_array($this->schedules['jobWithGroupA']->getJobCode(), $includeJobs)); $this->assertTrue(in_array($this->schedules['jobWithGroupAandB']->getJobCode(), $includeJobs)); - $includeJobs = $helper->addGroupJobs(array(), array($this->groups['groupB'])); + $includeJobs = $helper->addGroupJobs([], [$this->groups['groupB']]); $this->assertTrue(in_array($this->schedules['jobWithGroupB']->getJobCode(), $includeJobs)); $this->assertTrue(in_array($this->schedules['jobWithGroupAandB']->getJobCode(), $includeJobs)); @@ -84,7 +84,7 @@ public function scheduleJobAndRunCron() if ($sameRequest) { // dispatch event - $event = new Varien_Event_Observer(array('include_groups' => array($this->groups['groupA']))); + $event = new Varien_Event_Observer(['include_groups' => [$this->groups['groupA']]]); $observer = new Aoe_Scheduler_Model_Observer(); $observer->dispatch($event); } else { diff --git a/dev/tests/aoe_scheduler/tests/SchedulingTest.php b/dev/tests/aoe_scheduler/tests/SchedulingTest.php index 8f458b0..2fe1170 100755 --- a/dev/tests/aoe_scheduler/tests/SchedulingTest.php +++ b/dev/tests/aoe_scheduler/tests/SchedulingTest.php @@ -35,7 +35,7 @@ public function scheduleJobAndRunCron($runCronCallBack) $scheduleManager->deleteAll(); // fake schedule generation to avoid it to be generated on the next run: - Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null); + Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, ['crontab'], null); $schedule = Mage::getModel('cron/schedule'); /* @var $schedule Aoe_Scheduler_Model_Schedule */ $jobCode = 'aoescheduler_testtask'; diff --git a/shell/scheduler.php b/shell/scheduler.php index 0115b1d..90c97b3 100644 --- a/shell/scheduler.php +++ b/shell/scheduler.php @@ -109,11 +109,8 @@ public function lastRunAction() $collection->addFieldToFilter('job_code', $code) ->addFieldToFilter( - array('status'), - array( - array('eq' => Aoe_Scheduler_Model_Schedule::STATUS_SUCCESS), - array('eq' => Aoe_Scheduler_Model_Schedule::STATUS_REPEAT) - ) + ['status'], + [['eq' => Aoe_Scheduler_Model_Schedule::STATUS_SUCCESS], ['eq' => Aoe_Scheduler_Model_Schedule::STATUS_REPEAT]] ) ->addOrder('finished_at', Varien_Data_Collection_Db::SORT_ORDER_DESC) ->getSelect()->limit(1); @@ -335,7 +332,7 @@ public function enableJobActionHelp() */ public function waitAction() { - $timeout = $this->getArg('timeout') ? $this->getArg('timeout') : 60; + $timeout = $this->getArg('timeout') ?: 60; $startTime = time(); $sleepBetweenPolls = 2; $processManager = Mage::getModel('aoe_scheduler/processManager'); /* @var $processManager Aoe_Scheduler_Model_ProcessManager */ @@ -356,9 +353,9 @@ public function waitAction() echo sprintf( "%-30s %-10s %-10s %-10s %-10s\n", $schedule->getJobCode(), - $schedule->getHost() ? $schedule->getHost() : '(no host)', - $schedule->getPid() ? $schedule->getPid() : '(no pid)', - $schedule->getLastSeen() ? $schedule->getLastSeen() : '(never)', + $schedule->getHost() ?: '(no host)', + $schedule->getPid() ?: '(no pid)', + $schedule->getLastSeen() ?: '(never)', $status ); } @@ -429,9 +426,9 @@ public function listAllRunningSchedulesAction() echo sprintf( "%-30s %-10s %-10s %-10s %-10s\n", $schedule->getJobCode(), - $schedule->getHost() ? $schedule->getHost() : '(no host)', - $schedule->getPid() ? $schedule->getPid() : '(no pid)', - $schedule->getLastSeen() ? $schedule->getLastSeen() : '(never)', + $schedule->getHost() ?: '(no host)', + $schedule->getPid() ?: '(no pid)', + $schedule->getLastSeen() ?: '(never)', $status ); } @@ -511,12 +508,7 @@ public function cronAction() $excludeGroups = array_filter(array_map('trim', explode(',', $this->getArg('excludeGroups')))); $includeJobs = array_filter(array_map('trim', explode(',', $this->getArg('includeJobs')))); $excludeJobs = array_filter(array_map('trim', explode(',', $this->getArg('excludeJobs')))); - Mage::dispatchEvent($mode, array( - 'include_groups' => $includeGroups, - 'exclude_groups' => $excludeGroups, - 'include_jobs' => $includeJobs, - 'exclude_jobs' => $excludeJobs, - )); + Mage::dispatchEvent($mode, ['include_groups' => $includeGroups, 'exclude_groups' => $excludeGroups, 'include_jobs' => $includeJobs, 'exclude_jobs' => $excludeJobs]); break; default: echo "\nInvalid mode!\n\n";