mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
changed api call to flush before call the api using response callback.
This commit is contained in:
parent
ab96e75968
commit
d1c97227f0
3 changed files with 26 additions and 8 deletions
|
@ -34,16 +34,17 @@ class Session
|
|||
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
|
||||
}
|
||||
|
||||
$site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : '';
|
||||
$response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, $_SERVER['REMOTE_ADDR']);
|
||||
if (!is_null($response)
|
||||
Response::addPostRenderCallback(function(){
|
||||
$site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : '';
|
||||
$response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, $_SERVER['REMOTE_ADDR']);
|
||||
if (!is_null($response)
|
||||
&& key_exists('data', $response)
|
||||
&& key_exists('visitor_id', $response['data'])) {
|
||||
$_SESSION[static::USER_ID] = $response['data']['visitor_id'];
|
||||
} else {
|
||||
$_SESSION[static::USER_ID] = '';
|
||||
}
|
||||
|
||||
$_SESSION[static::USER_ID] = $response['data']['visitor_id'];
|
||||
} else {
|
||||
$_SESSION[static::USER_ID] = '';
|
||||
}
|
||||
});
|
||||
|
||||
static::initFlashes();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ class Response
|
|||
protected static $metaImages = [];
|
||||
protected static $facebookAnalyticsType = "PageView";
|
||||
|
||||
private static $PostRenderCallbacks = array();
|
||||
|
||||
public static function setMetaDescription($description)
|
||||
{
|
||||
static::$metaDescription = $description;
|
||||
|
@ -369,6 +371,19 @@ class Response
|
|||
);
|
||||
}
|
||||
|
||||
public static function addPostRenderCallback( $cb )
|
||||
{
|
||||
array_push(static::$PostRenderCallbacks, $cb);
|
||||
}
|
||||
|
||||
public static function invokePostRenderCallbacks()
|
||||
{
|
||||
foreach(static::$PostRenderCallbacks as &$cb )
|
||||
{
|
||||
$cb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public static function addBodyCssClass($classOrClasses)
|
||||
// {
|
||||
|
|
|
@ -28,6 +28,8 @@ try {
|
|||
View::compileCss();
|
||||
}
|
||||
Controller::dispatch(Request::getRoutingUri());
|
||||
flush();
|
||||
Response::invokePostRenderCallbacks();
|
||||
} catch (Throwable $e) {
|
||||
if (IS_PRODUCTION) {
|
||||
Slack::sendErrorIfProd($e);
|
||||
|
|
Loading…
Add table
Reference in a new issue