mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-09-02 18:25:11 +00:00
notify us when a 404 happens
This commit is contained in:
parent
0bc617a0b9
commit
a8977d904d
3 changed files with 22 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
class Controller
|
||||
{
|
||||
protected static $queuedFunctions = [];
|
||||
|
||||
public static function dispatch($uri)
|
||||
{
|
||||
try
|
||||
|
@ -146,4 +148,17 @@ class Controller
|
|||
|
||||
return ['internal/redirect', ['url' => $url]];
|
||||
}
|
||||
|
||||
public static function queueToRunAfterResponse(callable $fn)
|
||||
{
|
||||
static::$queuedFunctions[] = $fn;
|
||||
}
|
||||
|
||||
public static function shutdown()
|
||||
{
|
||||
foreach(static::$queuedFunctions as $fn)
|
||||
{
|
||||
call_user_func($fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,10 @@ class NavActions extends Actions
|
|||
|
||||
public static function execute404()
|
||||
{
|
||||
$uri = Request::getRelativeUri();
|
||||
Controller::queueToRunAfterResponse(function() use($uri) {
|
||||
Slack::sendErrorIfProd('404 for url ' . $uri);
|
||||
});
|
||||
Response::setStatus(404);
|
||||
return ['page/404'];
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ define('IS_PRODUCTION', $_SERVER['SERVER_NAME'] == 'lbry.io');
|
|||
ini_set('display_errors', IS_PRODUCTION ? 'off' : 'on');
|
||||
error_reporting(IS_PRODUCTION ? 0 : (E_ALL | E_STRICT));
|
||||
|
||||
register_shutdown_function('Controller::shutdown');
|
||||
|
||||
try
|
||||
{
|
||||
i18n::register();
|
||||
|
@ -21,7 +23,7 @@ try
|
|||
{
|
||||
View::compileCss();
|
||||
}
|
||||
Controller::dispatch(strtok(Request::getRelativeUri(), '?'));
|
||||
Controller::dispatch(Request::getRelativeUri());
|
||||
}
|
||||
catch(Throwable $e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue