Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
instanceOf: true,
earlyReturn: true,
strictBooleans: false,
carbon: false,
carbon: true,
rectorPreset: true,
phpunitCodeQuality: true,
doctrineCodeQuality: false,
Expand Down
3 changes: 2 additions & 1 deletion app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @package Mage
*/

use Carbon\Carbon;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
Expand Down Expand Up @@ -857,7 +858,7 @@ public static function isInstalled($options = [])
if (is_readable($localConfigFile)) {
$localConfig = simplexml_load_file($localConfigFile);
date_default_timezone_set('UTC');
if (($date = $localConfig->global->install->date) && strtotime((string) $date)) {
if (($date = $localConfig->global->install->date) && Carbon::parse((string) $date)->getTimestamp()) {
self::$_isInstalled = true;
}
}
Expand Down
8 changes: 5 additions & 3 deletions app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_AdminNotification
*/

use Carbon\Carbon;

/**
* AdminNotification Feed model
*
Expand Down Expand Up @@ -55,7 +57,7 @@ public function getFeedUrl()
*/
public function checkUpdate()
{
if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
if (($this->getFrequency() + $this->getLastUpdate()) > Carbon::now()->getTimestamp()) {
return $this;
}

Expand Down Expand Up @@ -92,7 +94,7 @@ public function checkUpdate()
*/
public function getDate($rssDate)
{
return gmdate(Varien_Db_Adapter_Pdo_Mysql::TIMESTAMP_FORMAT, strtotime($rssDate));
return gmdate(Varien_Db_Adapter_Pdo_Mysql::TIMESTAMP_FORMAT, Carbon::parse($rssDate)->getTimestamp());
}

/**
Expand Down Expand Up @@ -122,7 +124,7 @@ public function getLastUpdate()
*/
public function setLastUpdate()
{
Mage::app()->saveCache(time(), 'admin_notifications_lastcheck');
Mage::app()->saveCache(Carbon::now()->getTimestamp(), 'admin_notifications_lastcheck');
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Customer account form block
*
Expand Down Expand Up @@ -139,7 +141,7 @@ public function getCurrentStatus()
$log = $this->getCustomerLog();
if ($log->getLogoutAt()
|| !$log->getLastVisitAt()
|| strtotime(Varien_Date::now()) - strtotime($log->getLastVisitAt()) > Mage_Log_Model_Visitor::getOnlineMinutesInterval() * 60
|| Carbon::parse(Varien_Date::now())->getTimestamp() - Carbon::parse($log->getLastVisitAt())->getTimestamp() > Mage_Log_Model_Visitor::getOnlineMinutesInterval() * 60
) {
return Mage::helper('customer')->__('Offline');
}
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Adminhtml dashboard google chart block
*
Expand Down Expand Up @@ -215,7 +217,7 @@ public function generateChart(): array
$formats = Mage::app()->getLocale()->getTranslationList('datetime');
$format = $formats['yyMM'] ?? 'MM/yyyy';
$format = str_replace(['yyyy', 'yy', 'MM'], ['Y', 'y', 'm'], $format);
$this->_axisLabels[$idx][$_index] = date($format, strtotime($_label));
$this->_axisLabels[$idx][$_index] = Carbon::parse($_label)->format($format);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Adminhtml transaction detail
Expand Down Expand Up @@ -97,7 +98,7 @@ protected function _toHtml()
($this->_txn->getIsClosed()) ? Mage::helper('sales')->__('Yes') : Mage::helper('sales')->__('No'),
);

$createdAt = (strtotime($this->_txn->getCreatedAt()))
$createdAt = (Carbon::parse($this->_txn->getCreatedAt())->getTimestamp())
? $this->formatDate($this->_txn->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true)
: $this->__('N/A');
$this->setCreatedAtHtml($this->escapeHtml($createdAt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Sitemap grid link column renderer
*
Expand All @@ -21,9 +23,6 @@ class Mage_Adminhtml_Block_Sitemap_Grid_Renderer_Time extends Mage_Adminhtml_Blo
*/
public function render(Varien_Object $row)
{
return date(
Varien_Date::DATETIME_PHP_FORMAT,
strtotime($row->getSitemapTime()) + Mage::getSingleton('core/date')->getGmtOffset(),
);
return Carbon::createFromTimestamp(Carbon::parse($row->getSitemapTime())->getTimestamp() + Mage::getSingleton('core/date')->getGmtOffset())->format(Varien_Date::DATETIME_PHP_FORMAT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Custom import CSV file field for shipping table rates
*
Expand All @@ -30,7 +32,7 @@ public function getElementHtml()
{
$html = '';

$html .= '<input id="time_condition" type="hidden" name="' . $this->getName() . '" value="' . time() . '" />';
$html .= '<input id="time_condition" type="hidden" name="' . $this->getName() . '" value="' . Carbon::now()->getTimestamp() . '" />';

$html .= <<<EndHTML
<script type="text/javascript">
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Order create model
*
Expand Down Expand Up @@ -1705,7 +1707,7 @@ protected function _getNewCustomerEmail($customer)
$host = $this->getSession()
->getStore()
->getConfig(Mage_Customer_Model_Customer::XML_PATH_DEFAULT_EMAIL_DOMAIN);
$account = $customer->getIncrementId() ? $customer->getIncrementId() : time();
$account = $customer->getIncrementId() ? $customer->getIncrementId() : Carbon::now()->getTimestamp();
$email = $account . '@' . $host;
$account = $this->getData('account');
$account['email'] = $email;
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Adminhtml/Model/Sales/Order/Random.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Create random order
*
Expand Down Expand Up @@ -148,7 +150,7 @@ public function render()
protected function _getRandomDate()
{
$timestamp = mktime(random_int(0, 23), random_int(0, 59), 0, random_int(1, 11), random_int(1, 28), random_int(2006, 2007));
return date(Varien_Date::DATETIME_PHP_FORMAT, $timestamp);
return Carbon::createFromTimestamp($timestamp)->format(Varien_Date::DATETIME_PHP_FORMAT);
}

public function save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* @package Mage_Adminhtml
* @deprecated
Expand All @@ -17,10 +19,10 @@ public function toOptionArray()
{
return [
['label' => '', 'value' => ''],
['label' => sprintf('MM/DD/YY (%s)', date('m/d/y')), 'value' => '%m/%d/%y'],
['label' => sprintf('MM/DD/YYYY (%s)', date('m/d/Y')), 'value' => '%m/%d/%Y'],
['label' => sprintf('DD/MM/YY (%s)', date('d/m/y')), 'value' => '%d/%m/%y'],
['label' => sprintf('DD/MM/YYYY (%s)', date('d/m/Y')), 'value' => '%d/%m/%Y'],
['label' => sprintf('MM/DD/YY (%s)', Carbon::now()->format('m/d/y')), 'value' => '%m/%d/%y'],
['label' => sprintf('MM/DD/YYYY (%s)', Carbon::now()->format('m/d/Y')), 'value' => '%m/%d/%Y'],
['label' => sprintf('DD/MM/YY (%s)', Carbon::now()->format('d/m/y')), 'value' => '%d/%m/%y'],
['label' => sprintf('DD/MM/YYYY (%s)', Carbon::now()->format('d/m/Y')), 'value' => '%d/%m/%Y'],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Customer admin controller
*
Expand Down Expand Up @@ -334,7 +336,7 @@ public function saveAction()
// Force new customer confirmation
if ($isNewCustomer) {
$customer->setPassword($data['account']['password']);
$customer->setPasswordCreatedAt(time());
$customer->setPasswordCreatedAt(Carbon::now()->getTimestamp());
$customer->setForceConfirmed(true);
if ($customer->getPassword() === 'auto') {
$sendPassToEmail = true;
Expand Down Expand Up @@ -886,7 +888,7 @@ public function viewfileAction()
->setHeader('Pragma', 'public', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', $contentLength)
->setHeader('Last-Modified', date('r', (int) $contentModify))
->setHeader('Last-Modified', Carbon::createFromTimestamp((int) $contentModify)->format('r'))
->clearBody();
$this->getResponse()->sendHeaders();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Adminhtml sales order shipment controller
*
Expand Down Expand Up @@ -758,7 +760,7 @@ protected function _createPdfPageFromImageString($imageString)

imageinterlace($image, false);
$tmpFileName = sys_get_temp_dir() . DS . 'shipping_labels_'
. uniqid((string) mt_rand()) . time() . '.png';
. uniqid((string) mt_rand()) . Carbon::now()->getTimestamp() . '.png';
imagepng($image, $tmpFileName);
$pdfImage = Zend_Pdf_Image::imageWithPath($tmpFileName);
$page->drawImage($pdfImage, 0, 0, $xSize, $ySize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Adminhtml account controller
*
Expand Down Expand Up @@ -56,7 +58,7 @@ public function synchronizeAction()
$flag = $this->_getSyncFlag();
if ($flag && $flag->getState() == Mage_Core_Model_File_Storage_Flag::STATE_RUNNING
&& $flag->getLastUpdate()
&& time() <= (strtotime($flag->getLastUpdate()) + Mage_Core_Model_File_Storage_Flag::FLAG_TTL)
&& Carbon::now()->getTimestamp() <= (Carbon::parse($flag->getLastUpdate())->getTimestamp() + Mage_Core_Model_File_Storage_Flag::FLAG_TTL)
) {
return;
}
Expand Down Expand Up @@ -103,7 +105,7 @@ public function statusAction()
break;
case Mage_Core_Model_File_Storage_Flag::STATE_RUNNING:
if (!$flag->getLastUpdate()
|| time() <= (strtotime($flag->getLastUpdate()) + Mage_Core_Model_File_Storage_Flag::FLAG_TTL)
|| Carbon::now()->getTimestamp() <= (Carbon::parse($flag->getLastUpdate())->getTimestamp() + Mage_Core_Model_File_Storage_Flag::FLAG_TTL)
) {
$flagData = $flag->getFlagData();
if (is_array($flagData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Carbon\Carbon;

/**
* Store controller
*
Expand Down Expand Up @@ -480,7 +482,7 @@ protected function _backupDatabase($failPath, $arguments = [])
try {
$backupDb = Mage::getModel('backup/db');
$backup = Mage::getModel('backup/backup')
->setTime(time())
->setTime(Carbon::now()->getTimestamp())
->setType('db')
->setPath(Mage::getBaseDir('var') . DS . 'backups');

Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Api/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Api
*/

use Carbon\Carbon;

/**
* Webservice api session
*
Expand All @@ -29,7 +31,7 @@ class Mage_Api_Model_Session extends Mage_Core_Model_Session_Abstract
*/
public function start($sessionName = null)
{
$this->_currentSessId = md5(time() . uniqid('', true) . $sessionName);
$this->_currentSessId = md5(Carbon::now()->getTimestamp() . uniqid('', true) . $sessionName);
$this->sessionIds[] = $this->getSessionId();
return $this;
}
Expand Down Expand Up @@ -217,7 +219,7 @@ public function isSessionExpired($user)
return true;
}

$timeout = strtotime(Varien_Date::now()) - strtotime($user->getLogdate());
$timeout = Carbon::parse(Varien_Date::now())->getTimestamp() - Carbon::parse($user->getLogdate())->getTimestamp();
return $timeout > Mage::getStoreConfig('api/config/session_timeout');
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Authorizenet/Model/Directpost/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Authorizenet
*/

use Carbon\Carbon;

/**
* Authorize.net request model for DirectPost model.
*
Expand Down Expand Up @@ -155,7 +157,7 @@ public function setDataFromOrder(Mage_Sales_Model_Order $order, Mage_Authorizene
*/
public function signRequestData()
{
$fpTimestamp = (string) time();
$fpTimestamp = (string) Carbon::now()->getTimestamp();
$signatureKey = $this->_getSignatureKey();
if (!empty($signatureKey)) {
$hash = $this->_generateSha2RequestSign(
Expand Down
13 changes: 9 additions & 4 deletions app/code/core/Mage/Captcha/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Captcha
*/

use Carbon\Carbon;

/**
* Captcha Observer
*
Expand Down Expand Up @@ -141,6 +143,7 @@ public function checkRegisterCheckout($observer)
*
* @param Varien_Event_Observer $observer
* @return $this
* @throws Mage_Core_Exception
*/
public function checkUserLoginBackend($observer)
{
Expand Down Expand Up @@ -234,11 +237,13 @@ public function deleteOldAttempts()
* Delete Expired Captcha Images
*
* @return $this
* @throws Mage_Core_Exception
*/
public function deleteExpiredImages()
{
foreach (Mage::app()->getWebsites(true) as $website) {
$expire = time() - Mage::helper('captcha')->getConfigNode('timeout', $website->getDefaultStore()) * 60;
$timeout = (int) Mage::helper('captcha')->getConfigNode('timeout', $website->getDefaultStore());
$expire = Carbon::now()->subMinutes($timeout)->getTimestamp();
$imageDirectory = Mage::helper('captcha')->getImgDir($website);
foreach (new DirectoryIterator($imageDirectory) as $file) {
if ($file->isFile() && pathinfo($file->getFilename(), PATHINFO_EXTENSION) == 'png') {
Expand Down Expand Up @@ -320,13 +325,13 @@ public function checkSendfriendSend($observer)
Mage::getSingleton('catalog/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
Mage::getSingleton('catalog/session')->setFormData($request->getPost());
$id = (int) $request->getParam('id');
$sendId = (int) $request->getParam('id');
$catId = $request->getParam('cat_id');
if ($catId !== null) {
$id .= '/cat_id/' . (int) $catId;
$sendId .= '/cat_id/' . (int) $catId;
}

$controller->getResponse()->setRedirect(Mage::getUrl('*/*/send/id/' . $id));
$controller->getResponse()->setRedirect(Mage::getUrl('*/*/send/id/' . $sendId));
}
}

Expand Down
Loading
Loading