Skip to content

Commit

Permalink
Merge branch 'tinymce6' of github.com:fballiano/openmage into tinymce6
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed May 9, 2023
2 parents 4dc6a93 + 1a3aefb commit f584bfe
Show file tree
Hide file tree
Showing 92 changed files with 233 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function loadPrices($filter, $limit, $offset = null, $lowerPrice = null,
if (!is_null($upperPrice)) {
$select->where("$priceExpression < " . $this->_getComparingValue($upperPrice, $filter));
}
$select->order("$priceExpression ASC")->limit($limit, $offset);
$select->order(new Zend_Db_Expr("$priceExpression ASC"))->limit($limit, $offset);

return $this->_getReadAdapter()->fetchCol($select);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ public function loadNextPrices($filter, $price, $rightIndex, $upperPrice = null)
if (!is_null($upperPrice)) {
$pricesSelect->where("$priceExpression < " . $this->_getComparingValue($upperPrice, $filter));
}
$pricesSelect->order("$priceExpression DESC")->limit($rightIndex - $offset + 1, $offset - 1);
$pricesSelect->order(new Zend_Db_Expr("$priceExpression DESC"))->limit($rightIndex - $offset + 1, $offset - 1);

return array_reverse($this->_getReadAdapter()->fetchCol($pricesSelect));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ public function update($productId, $data)
$idBySku = $product->getIdBySku($productId);
$productId = $idBySku ? $idBySku : $productId;

$product->setStoreId($this->_getStoreId())
->load($productId);
/** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = Mage::getModel('cataloginventory/stock_item')
->setStoreId($this->_getStoreId())
->loadByProduct($productId);

if (!$product->getId()) {
if (!$stockItem->getId()) {
$this->_fault('not_exists');
}

$stockItem = $product->getStockItem();
$stockData = array_replace($stockItem->getData(), (array)$data);
$stockItem->setData($stockData);

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Controller/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function getScheme()
{
return $this->getServer('HTTPS') == 'on'
|| $this->getServer('HTTP_X_FORWARDED_PROTO') == 'https'
|| (Mage::isInstalled() && Mage::app()->getStore()->isCurrentlySecure()) ?
|| (Mage::isInstalled() && Mage::app()->isCurrentlySecure()) ?
self::SCHEME_HTTPS :
self::SCHEME_HTTP;
}
Expand Down
31 changes: 31 additions & 0 deletions app/code/core/Mage/Core/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,37 @@ public function setRequest(Mage_Core_Controller_Request_Http $request)
return $this;
}

/**
* @return bool
*/
public function isCurrentlySecure()
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
return true;
}

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
return true;
}

if (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443)) {
return true;
}

if (Mage::isInstalled()) {
$offloaderHeader = strtoupper(trim((string) Mage::getConfig()->getNode(Mage_Core_Model_Store::XML_PATH_OFFLOADER_HEADER, 'default')));
if ($offloaderHeader) {
$offloaderHeader = preg_replace('/[^A-Z]+/', '_', $offloaderHeader);
$offloaderHeader = strpos($offloaderHeader, 'HTTP_') === 0 ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
if (!empty($_SERVER[$offloaderHeader]) && $_SERVER[$offloaderHeader] !== 'http') {
return true;
}
}
}

return false;
}

/**
* Retrieve response object
*
Expand Down
26 changes: 2 additions & 24 deletions app/code/core/Mage/Core/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,34 +749,12 @@ public function isFrontUrlSecure()
/**
* Check if request was secure
*
* @deprecated
* @return bool
*/
public function isCurrentlySecure()
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
return true;
}

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
return true;
}

if (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443)) {
return true;
}

if (Mage::isInstalled()) {
$offloaderHeader = strtoupper(trim((string) Mage::getStoreConfig(self::XML_PATH_OFFLOADER_HEADER)));
if ($offloaderHeader) {
$offloaderHeader = preg_replace('/[^A-Z]+/', '_', $offloaderHeader);
$offloaderHeader = strpos($offloaderHeader, 'HTTP_') === 0 ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
if (!empty($_SERVER[$offloaderHeader]) && $_SERVER[$offloaderHeader] !== 'http') {
return true;
}
}
}

return false;
return Mage::app()->isCurrentlySecure();
}

/*************************************************************************************
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Core/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,10 @@
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<comment><![CDATA[
Provide the name of the request header set by the upstream proxy to indicate a secure connection.
The header <code>X-Forwarded-Proto: https</code> is already checked by default regardless of this configuration option.
]]></comment>
</offloader_header>
</fields>
</secure>
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Index/Model/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ public function logEvent(Varien_Object $entity, $entityType, $eventType, $doSave
* @param Varien_Object $entity
* @param string $entityType
* @param string $eventType
* @throws Exception
* @return Mage_Index_Model_Indexer
* @throws Exception|Throwable
*/
public function processEntityAction(Varien_Object $entity, $entityType, $eventType)
public function processEntityAction(Varien_Object $entity, $entityType, $eventType): Mage_Index_Model_Indexer
{
$event = $this->logEvent($entity, $entityType, $eventType, false);
/**
Expand Down
63 changes: 63 additions & 0 deletions app/code/core/Mage/Index/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
class Mage_Index_Model_Observer
{
public const OLD_INDEX_EVENT_THRESHOLD_SECONDS = 24 * 60 * 60;
public const OLD_INDEX_EVENT_DELETE_COUNT = 1000;

/**
* Indexer model
*
Expand All @@ -35,6 +38,7 @@ public function __construct()
* Store after commit observer. Process store related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processStoreSave(Varien_Event_Observer $observer)
{
Expand All @@ -50,6 +54,7 @@ public function processStoreSave(Varien_Event_Observer $observer)
* Store group after commit observer. Process store group related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processStoreGroupSave(Varien_Event_Observer $observer)
{
Expand All @@ -65,6 +70,7 @@ public function processStoreGroupSave(Varien_Event_Observer $observer)
* Website save after commit observer. Process website related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processWebsiteSave(Varien_Event_Observer $observer)
{
Expand All @@ -80,6 +86,7 @@ public function processWebsiteSave(Varien_Event_Observer $observer)
* Store after commit observer. Process store related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processStoreDelete(Varien_Event_Observer $observer)
{
Expand All @@ -95,6 +102,7 @@ public function processStoreDelete(Varien_Event_Observer $observer)
* Store group after commit observer. Process store group related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processStoreGroupDelete(Varien_Event_Observer $observer)
{
Expand All @@ -110,6 +118,7 @@ public function processStoreGroupDelete(Varien_Event_Observer $observer)
* Website save after commit observer. Process website related indexes
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processWebsiteDelete(Varien_Event_Observer $observer)
{
Expand All @@ -125,6 +134,7 @@ public function processWebsiteDelete(Varien_Event_Observer $observer)
* Config data after commit observer.
*
* @param Varien_Event_Observer $observer
* @throws Throwable
*/
public function processConfigDataSave(Varien_Event_Observer $observer)
{
Expand All @@ -135,4 +145,57 @@ public function processConfigDataSave(Varien_Event_Observer $observer)
Mage_Index_Model_Event::TYPE_SAVE
);
}

/**
* Clean old index events for indexers in manual mode
*
* @return void
* @throws Exception
*/
public function cleanOutdatedEvents()
{
$manualIndexProcessCollection = Mage::getSingleton('index/indexer')
->getProcessesCollection()
->addFieldToFilter('mode', Mage_Index_Model_Process::MODE_MANUAL);

$now = new DateTime();
/** @noinspection PhpUnhandledExceptionInspection */
$dateInterval = new DateInterval('PT' . self::OLD_INDEX_EVENT_THRESHOLD_SECONDS . 'S');
$oldEventsThreshold = $now
->sub($dateInterval)
->format(Varien_Db_Adapter_Pdo_Mysql::TIMESTAMP_FORMAT);

$coreResource = Mage::getSingleton('core/resource');
$writeConnection = $coreResource->getConnection('core_write');
$indexEventTableName = $coreResource->getTableName('index/event');

/** @var Mage_Index_Model_Process $process */
foreach ($manualIndexProcessCollection as $process) {
$unprocessedEventsCollection = $process
->getUnprocessedEventsCollection()
->addFieldToFilter('created_at', ['lt' => $oldEventsThreshold])
->load();

$i = 0;
$eventList = [];
/** @var Mage_Index_Model_Event $unprocessedEvent */
foreach ($unprocessedEventsCollection as $unprocessedEvent) {
$i++;
$eventList[] = $unprocessedEvent->getId();
if ($i === self::OLD_INDEX_EVENT_DELETE_COUNT) {
break;
}
}

if (!empty($eventList)) {
$where = new Zend_Db_Expr(
sprintf(
'event_id in (%s)',
implode(',', $eventList)
)
);
$writeConnection->delete($indexEventTableName, $where);
}
}
}
}
12 changes: 12 additions & 0 deletions app/code/core/Mage/Index/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
<version>1.6.0.0</version>
</Mage_Index>
</modules>
<crontab>
<jobs>
<index_clean_events>
<schedule>
<cron_expr>30 */4 * * *</cron_expr>
</schedule>
<run>
<model>index/observer::cleanOutdatedEvents</model>
</run>
</index_clean_events>
</jobs>
</crontab>
<global>
<helpers>
<index>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@
</script>

<?php echo $this->helper('core/js')->getTranslatorScript() ?>
<?php echo $this->getChildHtml('calendar'); ?>
<?php echo $this->getChildHtml('optional_zip_countries'); ?>
<?php echo $this->getChildHtml(); ?>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="additional-addtocart-box">
<?php echo $this->getChildHtml(); ?>
</div>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" id="map-popup-button"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" id="map-popup-button"><?php echo $this->__('Add to Cart') ?></button>
</form>
</div>
<div class="map-popup-msrp" id="map-popup-msrp-box"><strong><?php echo $this->__('Price'); ?>:</strong> <span style="text-decoration:line-through;" id="map-popup-msrp"></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $_params = $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()]));
'<?php echo $this->helper('catalog/product_compare')->getAddToCartUrlCustom($_item, false) ?>',
'<?php echo $_params ?>',
'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
Expand Down Expand Up @@ -135,7 +135,7 @@ $_params = $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()]));
'<?php echo $this->helper('catalog/product_compare')->getAddToCartUrlCustom($_item, false) ?>',
'<?php echo $_params ?>',
'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
</p>
<?php else: ?>
Expand All @@ -161,7 +161,7 @@ $_params = $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()]));
</tbody>
</table>
<div class="buttons-set">
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Close Window')) ?>" class="button" onclick="window.close();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Close Window')) ?>" class="button" onclick="window.close();"><?php echo $this->__('Close Window') ?></button>
<span class="please-wait" id="compare-list-please-wait" style="display:none;">
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Please wait...')) ?>" title="<?php echo $this->__('Please wait...') ?>" class="v-middle" /> <?php echo $this->__('Please wait...') ?>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null;
<script type="text/javascript">decorateList('compare-items')</script>
<div class="actions">
<a href="<?php echo $_helper->getClearListUrl() ?>" onclick="return confirm('<?php echo Mage::helper('core')->quoteEscape($this->__('Are you sure you would like to remove all products from your comparison?')) ?>');"><?php echo $this->__('Clear All') ?></a>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Compare')) ?>" class="button" onclick="popWin('<?php echo $_helper->getListUrl() ?>','compare','top:0,left:0,width=820,height=600,resizable=yes,scrollbars=yes')"><span><span><?php echo $this->__('Compare') ?></span></span></button>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Compare')) ?>" class="button" onclick="popWin('<?php echo $_helper->getListUrl() ?>','compare','top:0,left:0,width=820,height=600,resizable=yes,scrollbars=yes')"><?php echo $this->__('Compare') ?></button>
</div>
<?php else: ?>
<p class="empty"><?php echo $this->__('You have no items to compare.') ?></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>"
class="button btn-cart"
onclick="customFormSubmit('<?php echo $_cartUrl ?>', '<?php echo $_params ?>', 'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
</p>
<?php else: ?>
Expand Down Expand Up @@ -120,7 +120,7 @@
title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>"
class="button btn-cart"
onclick="customFormSubmit('<?php echo $_cartUrl ?>', '<?php echo $_params ?>', 'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'<?php echo $this->getAddToCartUrlCustom($_product, [], false) ?>',
'<?php echo $_params ?>',
'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" />
<?php endif ?>
<button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><?php echo $buttonTitle ?></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
<?php endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'<?php echo $this->getAddToCartUrlCustom($_product, [], false) ?>',
'<?php echo $_params ?>',
'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'<?php echo $this->getAddToCartUrlCustom($_product, [], false) ?>',
'<?php echo $_params ?>',
'post')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
<?php echo $this->__('Add to Cart') ?>
</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
Expand Down
Loading

0 comments on commit f584bfe

Please sign in to comment.