function __construct() { // Check auto-maintenance settings $aConf = $GLOBALS['_MAX']['CONF']; $this->isAutoMaintenanceEnabled = !empty($aConf['maintenance']['autoMaintenance']); // Get time 1 hour ago $oServiceLocator =& OA_ServiceLocator::instance(); $oNow = $oServiceLocator->get('now'); if ($oNow) { $oOneHourAgo = new Date($oNow); } else { $oOneHourAgo = new Date(); } $oOneHourAgo->subtractSpan(new Date_Span('0-1-0-0')); // Get last runs $oLastCronRun = OX_Maintenance::getLastScheduledRun(); $oLastRun = OX_Maintenance::getLastRun(); // Reset minutes and seconds if (isset($oLastCronRun)) { $oLastCronRun->setMinute(0); $oLastCronRun->setSecond(0); } if (isset($oLastRun)) { $oLastRun->setMinute(0); $oLastRun->setSecond(0); } // Check if any kind of maintenance was run if (isset($oLastCronRun) && !$oOneHourAgo->after($oLastCronRun)) { $this->isScheduledMaintenanceRunning = true; } elseif (isset($oLastRun) && !$oOneHourAgo->after($oLastRun)) { $this->isAutoMaintenanceRunning = true; } }
function testGetLastRun() { $oMaintenance = new OX_Maintenance(); $this->assertNull($oMaintenance->getLastRun()); $iLastRun = strtotime('2002-01-01'); OA_Dal_ApplicationVariables::set('maintenance_timestamp', $iLastRun); $oDate = new Date((int) $iLastRun); $this->assertTrue($oDate->equals($oMaintenance->getLastRun())); OA_Dal_ApplicationVariables::delete('maintenance_timestamp'); }