Skip to content

Commit b47534d

Browse files
committed
Remove CSS/JS merge functionality
1 parent 3901dad commit b47534d

File tree

13 files changed

+56
-589
lines changed

13 files changed

+56
-589
lines changed

app/code/core/Mage/Adminhtml/Block/Cache/Additional.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,4 @@ public function getCleanSwatchesUrl()
2121
{
2222
return $this->getUrl('*/*/cleanSwatches');
2323
}
24-
25-
public function getCleanMediaUrl()
26-
{
27-
return $this->getUrl('*/*/cleanMedia');
28-
}
2924
}

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ protected function _beforeSave()
4747
return $this;
4848
}
4949

50-
/**
51-
* Clean compiled JS/CSS when updating url configuration settings
52-
*/
53-
protected function _afterSave()
54-
{
55-
if ($this->isValueChanged()) {
56-
Mage::getModel('core/design_package')->cleanMergedJsCss();
57-
}
58-
59-
return $this;
60-
}
61-
6250
/**
6351
* @inheritDoc
6452
*/

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Secure.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/code/core/Mage/Adminhtml/controllers/CacheController.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,29 +146,6 @@ public function massRefreshAction()
146146
$this->_redirect('*/*');
147147
}
148148

149-
/**
150-
* Clean JS/css files cache
151-
*/
152-
public function cleanMediaAction()
153-
{
154-
try {
155-
Mage::getModel('core/design_package')->cleanMergedJsCss();
156-
Mage::dispatchEvent('clean_media_cache_after');
157-
$this->_getSession()->addSuccess(
158-
Mage::helper('adminhtml')->__('The JavaScript/CSS cache has been cleaned.'),
159-
);
160-
} catch (Mage_Core_Exception $e) {
161-
$this->_getSession()->addError($e->getMessage());
162-
} catch (Exception $e) {
163-
$this->_getSession()->addException(
164-
$e,
165-
Mage::helper('adminhtml')->__('An error occurred while clearing the JavaScript/CSS cache.'),
166-
);
167-
}
168-
169-
$this->_redirect('*/*');
170-
}
171-
172149
/**
173150
* Clean catalog files cache
174151
*/

app/code/core/Mage/Adminhtml/controllers/System/CacheController.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,6 @@ public function saveAction()
9595

9696
Mage::app()->saveUseCache($enable);
9797

98-
// clean javascript/css cache
99-
if ($this->getRequest()->getPost('jscss_action')) {
100-
if (Mage::getDesign()->cleanMergedJsCss()) {
101-
$this->_getSession()->addSuccess(
102-
Mage::helper('adminhtml')->__('The JavaScript/CSS cache has been cleared.'),
103-
);
104-
} else {
105-
$this->_getSession()->addError(Mage::helper('adminhtml')->__('Failed to clear the JavaScript/CSS cache.'));
106-
}
107-
}
108-
10998
/**
11099
* Run catalog actions
111100
*/

app/code/core/Mage/Core/Helper/Data.php

Lines changed: 27 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getEncryptor()
9797
* @param float $value
9898
* @param bool $format
9999
* @param bool $includeContainer
100-
* @return mixed
100+
* @return float|string
101101
*/
102102
public static function currency($value, $format = true, $includeContainer = true)
103103
{
@@ -111,7 +111,7 @@ public static function currency($value, $format = true, $includeContainer = true
111111
* @param int|Mage_Core_Model_Store $store
112112
* @param bool $format
113113
* @param bool $includeContainer
114-
* @return mixed
114+
* @return float|string
115115
*/
116116
public static function currencyByStore($value, $store = null, $format = true, $includeContainer = true)
117117
{
@@ -121,8 +121,8 @@ public static function currencyByStore($value, $store = null, $format = true, $i
121121
}
122122

123123
$value = $store->convertPrice($value, $format, $includeContainer);
124-
} catch (Exception $e) {
125-
$value = $e->getMessage();
124+
} catch (Exception $exception) {
125+
$value = $exception->getMessage();
126126
}
127127

128128
return $value;
@@ -146,6 +146,7 @@ public function formatCurrency($value, $includeContainer = true)
146146
* @param float $price
147147
* @param bool $includeContainer
148148
* @return string
149+
* @throws Mage_Core_Model_Store_Exception
149150
*/
150151
public function formatPrice($price, $includeContainer = true)
151152
{
@@ -275,14 +276,15 @@ public function validateKey($key)
275276
* @param int $len
276277
* @param string|null $chars
277278
* @return string
279+
* @throws Exception
278280
*/
279281
public function getRandomString($len, $chars = null)
280282
{
281283
if (is_null($chars)) {
282284
$chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS;
283285
}
284286

285-
for ($i = 0, $str = '', $lc = strlen($chars) - 1; $i < $len; $i++) {
287+
for ($index = 0, $str = '', $lc = strlen($chars) - 1; $index < $len; $index++) {
286288
$str .= $chars[random_int(0, $lc)];
287289
}
288290

@@ -347,6 +349,7 @@ public function getVersionHash(Mage_Core_Model_Encryption $encryptionModel)
347349
*
348350
* @param bool|int|Mage_Core_Model_Store|null|string $store
349351
* @return int
352+
* @throws Mage_Core_Model_Store_Exception
350353
*/
351354
public function getStoreId($store = null)
352355
{
@@ -356,7 +359,7 @@ public function getStoreId($store = null)
356359
/**
357360
* @param string $string
358361
* @param bool $german
359-
* @return false|string
362+
* @return string
360363
*
361364
* @SuppressWarnings("PHPMD.ErrorControlOperator")
362365
*/
@@ -397,21 +400,19 @@ public function removeAccents($string, $german = false)
397400
}
398401

399402
$replacements[$german] = [];
400-
foreach ($subst as $k => $v) {
401-
$replacements[$german][$k < 256 ? chr($k) : '&#' . $k . ';'] = $v;
403+
foreach ($subst as $key => $value) {
404+
$replacements[$german][$key < 256 ? chr($key) : '&#' . $key . ';'] = $value;
402405
}
403406
}
404407

405408
// convert string from default database format (UTF-8)
406409
// to encoding which replacement arrays made with (ISO-8859-1)
407-
if ($s = @iconv('UTF-8', 'ISO-8859-1', $string)) {
408-
$string = $s;
410+
if ($encoded = @iconv('UTF-8', 'ISO-8859-1', $string)) {
411+
$string = $encoded;
409412
}
410413

411414
// Replace
412-
$string = strtr($string, $replacements[$german]);
413-
414-
return $string;
415+
return strtr($string, $replacements[$german]);
415416
}
416417

417418
/**
@@ -567,19 +568,19 @@ public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = fal
567568
$keyIsLast = "{$prefix}is_last";
568569

569570
$count = count($array); // this will force Iterator to load
570-
$i = 0;
571+
$index = 0;
571572
$isEven = false;
572573
foreach ($array as $key => $element) {
573574
if (is_object($element)) {
574-
$this->_decorateArrayObject($element, $keyIsFirst, ($i === 0), $forceSetAll || ($i === 0));
575+
$this->_decorateArrayObject($element, $keyIsFirst, ($index === 0), $forceSetAll || ($index === 0));
575576
$this->_decorateArrayObject($element, $keyIsOdd, !$isEven, $forceSetAll || !$isEven);
576577
$this->_decorateArrayObject($element, $keyIsEven, $isEven, $forceSetAll || $isEven);
577578
$isEven = !$isEven;
578-
$i++;
579-
$this->_decorateArrayObject($element, $keyIsLast, ($i === $count), $forceSetAll || ($i === $count));
579+
$index++;
580+
$this->_decorateArrayObject($element, $keyIsLast, ($index === $count), $forceSetAll || ($index === $count));
580581
} elseif (is_array($element)) {
581-
if ($forceSetAll || ($i === 0)) {
582-
$array[$key][$keyIsFirst] = ($i === 0);
582+
if ($forceSetAll || ($index === 0)) {
583+
$array[$key][$keyIsFirst] = ($index === 0);
583584
}
584585

585586
if ($forceSetAll || !$isEven) {
@@ -591,9 +592,9 @@ public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = fal
591592
}
592593

593594
$isEven = !$isEven;
594-
$i++;
595-
if ($forceSetAll || ($i === $count)) {
596-
$array[$key][$keyIsLast] = ($i === $count);
595+
$index++;
596+
if ($forceSetAll || ($index === $count)) {
597+
$array[$key][$keyIsLast] = ($index === $count);
597598
}
598599
}
599600
}
@@ -695,9 +696,9 @@ public function xmlToAssoc(SimpleXMLElement $xml)
695696
$array = [];
696697
foreach ($xml as $key => $value) {
697698
if (isset($value->$key)) {
698-
$i = 0;
699+
$index = 0;
699700
foreach ($value->$key as $v) {
700-
$array[$key][$i++] = (string) $v;
701+
$array[$key][$index++] = (string) $v;
701702
}
702703
} else {
703704
// try to transform it into string value, trimming spaces between elements
@@ -778,113 +779,6 @@ public function uniqHash($prefix = '')
778779
return $prefix . md5(uniqid(microtime() . mt_rand(), true));
779780
}
780781

781-
/**
782-
* Merge specified files into one
783-
*
784-
* By default will not merge, if there is already merged file exists and it
785-
* was modified after its components
786-
* If target file is specified, will attempt to write merged contents into it,
787-
* otherwise will return merged content
788-
* May apply callback to each file contents. Callback gets parameters:
789-
* (<existing system filename>, <file contents>)
790-
* May filter files by specified extension(s)
791-
* Returns false on error
792-
*
793-
* @param string|false $targetFile - file path to be written
794-
* @param bool $mustMerge
795-
* @param callable $beforeMergeCallback
796-
* @param array|string $extensionsFilter
797-
* @return bool|string
798-
* @SuppressWarnings("PHPMD.ErrorControlOperator")
799-
*/
800-
public function mergeFiles(
801-
array $srcFiles,
802-
$targetFile = false,
803-
$mustMerge = false,
804-
$beforeMergeCallback = null,
805-
$extensionsFilter = []
806-
) {
807-
try {
808-
// check whether merger is required
809-
$shouldMerge = $mustMerge || !$targetFile;
810-
if (!$shouldMerge) {
811-
if (!file_exists($targetFile)) {
812-
$shouldMerge = true;
813-
} else {
814-
$targetMtime = filemtime($targetFile);
815-
foreach ($srcFiles as $file) {
816-
if (!file_exists($file)) {
817-
// no translation intentionally
818-
Mage::logException(new Exception(sprintf('File %s not found.', $file)));
819-
} elseif (@filemtime($file) > $targetMtime) {
820-
$shouldMerge = true;
821-
break;
822-
}
823-
}
824-
}
825-
}
826-
827-
// merge contents into the file
828-
if ($shouldMerge) {
829-
if ($targetFile && !is_writable(dirname($targetFile))) {
830-
// no translation intentionally
831-
throw new Exception(sprintf('Path %s is not writeable.', dirname($targetFile)));
832-
}
833-
834-
// filter by extensions
835-
if ($extensionsFilter) {
836-
if (!is_array($extensionsFilter)) {
837-
$extensionsFilter = [$extensionsFilter];
838-
}
839-
840-
foreach ($srcFiles as $key => $file) {
841-
$fileExt = strtolower(pathinfo($file, PATHINFO_EXTENSION));
842-
if (!in_array($fileExt, $extensionsFilter)) {
843-
unset($srcFiles[$key]);
844-
}
845-
}
846-
}
847-
848-
if (empty($srcFiles)) {
849-
// no translation intentionally
850-
throw new Exception('No files to compile.');
851-
}
852-
853-
$data = '';
854-
foreach ($srcFiles as $file) {
855-
if (!file_exists($file)) {
856-
continue;
857-
}
858-
859-
$contents = file_get_contents($file) . "\n";
860-
// phpcs:ignore Ecg.Security.ForbiddenFunction.Found
861-
if ($beforeMergeCallback && is_callable($beforeMergeCallback)) {
862-
$contents = call_user_func($beforeMergeCallback, $file, $contents);
863-
}
864-
865-
$data .= $contents;
866-
}
867-
868-
if (!$data) {
869-
// no translation intentionally
870-
throw new Exception(sprintf("No content found in files:\n%s", implode("\n", $srcFiles)));
871-
}
872-
873-
if ($targetFile) {
874-
file_put_contents($targetFile, $data, LOCK_EX);
875-
} else {
876-
return $data; // no need to write to file, just return data
877-
}
878-
}
879-
880-
return true; // no need in merger or merged into file successfully
881-
} catch (Exception $e) {
882-
Mage::logException($e);
883-
}
884-
885-
return false;
886-
}
887-
888782
/**
889783
* Return default country code
890784
*
@@ -1015,7 +909,7 @@ public function getEscapedCSVData(array $data)
1015909
$value = (string) $value;
1016910

1017911
$firstLetter = substr($value, 0, 1);
1018-
if ($firstLetter && in_array($firstLetter, ['=', '+', '-'])) {
912+
if (in_array($firstLetter, ['=', '+', '-'])) {
1019913
$data[$key] = ' ' . $value;
1020914
}
1021915
}
@@ -1036,7 +930,7 @@ public function unEscapeCSVData($data)
1036930
foreach ($data as $key => $value) {
1037931
$value = (string) $value;
1038932

1039-
if (preg_match("/^ [=\-+]/", $value)) {
933+
if (preg_match('/^ [=\-+]/', $value)) {
1040934
$data[$key] = ltrim($value);
1041935
}
1042936
}

0 commit comments

Comments
 (0)