Page MenuHomeIn-Portal Phabricator

D225.id526.diff
No OneTemporary

File Metadata

Created
Sun, Feb 1, 12:57 AM

D225.id526.diff

Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php
+++ core/kernel/application.php
@@ -1078,17 +1078,25 @@
}
/**
- * Only renders template
+ * Replaces current rendered template with given one.
*
- * @see kDBEventHandler::_errorNotFound()
+ * @param string|null $template Template.
+ *
+ * @return void
*/
- public function QuickRun()
+ public function QuickRun($template)
{
- // Replace current page content with 404.
- $this->InitParser();
+ /** @var kThemesHelper $themes_helper */
+ $themes_helper = $this->recallObject('ThemesHelper');
+ // Set Web Request variables to affect link building on template itself.
+ $this->SetVar('t', $template);
+ $this->SetVar('m_cat_id', $themes_helper->getPageByTemplate($template));
+
+ // Replace current page content with given template.
+ $this->InitParser();
$this->Parser->Clear();
- $this->HTML = $this->Parser->Run($this->GetVar('t'));
+ $this->HTML = $this->Parser->Run($template);
}
/**
Index: core/kernel/managers/rewrite_url_processor.php
===================================================================
--- core/kernel/managers/rewrite_url_processor.php
+++ core/kernel/managers/rewrite_url_processor.php
@@ -152,6 +152,9 @@
// don't cache 404 Not Found
$this->_setCachedUrl($url, Array ('vars' => $vars, 'passed' => $passed));
}
+ else {
+ header('HTTP/1.0 404 Not Found');
+ }
if ( $this->Application->GetVarDirect('t', 'Post') ) {
// template from POST overrides template from URL.
@@ -445,7 +448,12 @@
}
if ( $this->_partsToParse ) {
- $vars = array_merge($vars, $this->manager->prepare404($vars['m_theme']));
+ /** @var kThemesHelper $themes_helper */
+ $themes_helper = $this->Application->recallObject('ThemesHelper');
+
+ $not_found = $this->Application->ConfigValue('ErrorTemplate');
+ $vars['t'] = $not_found ? $not_found : 'error_notfound';
+ $vars['m_cat_id'] = $themes_helper->getPageByTemplate($vars['t'], $vars['m_theme']);
}
return $vars;
@@ -1078,4 +1086,4 @@
return $ret;
}
-}
\ No newline at end of file
+}
Index: core/kernel/managers/url_manager.php
===================================================================
--- core/kernel/managers/url_manager.php
+++ core/kernel/managers/url_manager.php
@@ -452,31 +452,6 @@
}
/**
- * Prepares case, when requested page wasn't found
- *
- * @param int $theme_id
- * @return array
- */
- public function prepare404($theme_id = null)
- {
- if ( !isset($theme_id) ) {
- $theme_id = $this->Application->GetVar('m_theme');
- }
-
- $not_found = $this->Application->ConfigValue('ErrorTemplate');
- $vars['t'] = $not_found ? $not_found : 'error_notfound';
-
- $themes_helper = $this->Application->recallObject('ThemesHelper');
- /* @var $themes_helper kThemesHelper */
-
- $vars['m_cat_id'] = $themes_helper->getPageByTemplate($vars['t'], $theme_id);
-
- header('HTTP/1.0 404 Not Found');
-
- return $vars;
- }
-
- /**
* Show 404 page and exit
*
* @return void
@@ -484,15 +459,13 @@
*/
public function show404()
{
- $vars = $this->prepare404();
+ header('HTTP/1.0 404 Not Found');
- foreach ($vars as $var_name => $var_value) {
- $this->Application->SetVar($var_name, $var_value);
- }
+ $not_found = $this->Application->ConfigValue('ErrorTemplate');
+ $template = $not_found ? $not_found : 'error_notfound';
- // ensure parser is available (e.g. 404 page requested from event)
- $this->Application->QuickRun();
+ $this->Application->QuickRun($template);
$this->Application->Done();
exit;
}
-}
\ No newline at end of file
+}

Event Timeline