Skip to content

Commit c58032c

Browse files
authored
Pass Mage_Core_Model_Store_Exception to error reporting (#627)
1 parent c9aa653 commit c58032c

File tree

5 files changed

+6
-28
lines changed

5 files changed

+6
-28
lines changed

.phpstan.dist.baseline.neon

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ parameters:
4242
count: 1
4343
path: app/Mage.php
4444

45-
-
46-
rawMessage: 'Method Mage::printException() has no return type specified.'
47-
identifier: missingType.return
48-
count: 1
49-
path: app/Mage.php
50-
51-
-
52-
rawMessage: 'Method Mage::printException() has parameter $extra with no type specified.'
53-
identifier: missingType.parameter
54-
count: 1
55-
path: app/Mage.php
56-
5745
-
5846
rawMessage: 'Method Mage::register() has no return type specified.'
5947
identifier: missingType.return
@@ -10431,7 +10419,7 @@ parameters:
1043110419
-
1043210420
rawMessage: Variable $query might not be defined.
1043310421
identifier: variable.undefined
10434-
count: 2
10422+
count: 1
1043510423
path: app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php
1043610424

1043710425
-

app/Mage.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,9 @@ public static function init($code = '', $type = 'store', $options = [], $modules
623623
header('Location: ' . self::getBaseUrl());
624624
die;
625625
} catch (Mage_Core_Model_Store_Exception $e) {
626-
Maho::errorReport([], 404);
627-
die;
626+
self::printException($e, '', 404);
628627
} catch (Exception $e) {
629628
self::printException($e);
630-
die;
631629
}
632630
}
633631

@@ -663,13 +661,11 @@ public static function run($code = '', $type = 'store', $options = [])
663661
header('Location: ' . self::getBaseUrl());
664662
die();
665663
} catch (Mage_Core_Model_Store_Exception $e) {
666-
Maho::errorReport([], 404);
667-
die();
664+
self::printException($e, '', 404);
668665
} catch (Exception $e) {
669666
if (self::isInstalled()) {
670667
self::dispatchEvent('mage_run_installed_exception', ['exception' => $e]);
671668
self::printException($e);
672-
exit();
673669
}
674670
try {
675671
self::dispatchEvent('mage_run_exception', ['exception' => $e]);
@@ -821,7 +817,7 @@ public static function getIsDeveloperMode()
821817
/**
822818
* Display exception
823819
*/
824-
public static function printException(Throwable $e, $extra = '')
820+
public static function printException(Throwable $e, string $extra = '', int $httpResponseCode = 503): never
825821
{
826822
if (self::$_isDeveloperMode) {
827823
print '<pre>';
@@ -847,7 +843,7 @@ public static function printException(Throwable $e, $extra = '')
847843
$reportData['script_name'] = $_SERVER['SCRIPT_NAME'];
848844
}
849845

850-
Maho::errorReport($reportData);
846+
Maho::errorReport($reportData, $httpResponseCode);
851847
}
852848

853849
die();

app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public function _loadEntities($printQuery = false, $logQuery = false)
4545
$rows = $this->_fetchAll($query);
4646
} catch (Exception $e) {
4747
Mage::printException($e, $query);
48-
$this->printLogQuery(true, true, $query);
49-
throw $e;
5048
}
5149

5250
foreach ($rows as $v) {

app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,8 +1013,6 @@ public function _loadEntities($printQuery = false, $logQuery = false)
10131013
$rows = $this->_fetchAll($query);
10141014
} catch (Exception $e) {
10151015
Mage::printException($e, $query);
1016-
$this->printLogQuery(true, true, $query);
1017-
throw $e;
10181016
}
10191017

10201018
foreach ($rows as $v) {
@@ -1088,8 +1086,6 @@ public function _loadAttributes($printQuery = false, $logQuery = false)
10881086
$values = $this->getConnection()->fetchAll($select);
10891087
} catch (Exception $e) {
10901088
Mage::printException($e, $select);
1091-
$this->printLogQuery(true, true, $select);
1092-
throw $e;
10931089
}
10941090

10951091
foreach ($values as $value) {

app/code/core/Mage/Install/Model/Observer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function installFailure(Maho\Event\Observer $observer): void
2626
{
2727
echo '<h2>There was a problem proceeding with Maho installation.</h2>';
2828
echo '<p>Please contact developers with error messages on this page.</p>';
29-
echo Mage::printException($observer->getEvent()->getException());
29+
Mage::printException($observer->getEvent()->getException());
3030
}
3131
}

0 commit comments

Comments
 (0)