【发布时间】:2018-09-21 16:06:18
【问题描述】:
我有几个使用重定向的操作,但在转换到新服务器后,所有重定向现在都会导致空白页面。我在日志中没有收到任何错误,我已经尝试了这个问题中的建议YII2 redirect causes blank page
当我回显 var_dump(headers_sent()) 时,它返回 false。 Yii 调试日志也显示 405 状态码。以下是我的操作。
我什至尝试过使用header("Location: http://www.google.com"),它也会导致空白页
public function actionDashboard()
{
if(strtotime(UserInfo::findOne(Yii::$app->user->Id)->active_until) < strtotime(date("Y-m-d H:i:s"))){
Yii::$app->session->setFlash('warning', 'Please subscribe below.');
return $this->redirect(['site/subscription'], 405);
}
$model = new Score();
$deadlines = new EDeadlines();
return $this->render('dashboard', [
'deadlines' => $deadlines,
'model' => $model,
]);
}
public function actionSubscription()
{
Stripe::setApiKey(Yii::$app->params['stripe_sk']);
$userInfo = UserInfo::findOne(Yii::$app->user->Id);
$userInfo->customer_id != NULL ? $customer = Customer::retrieve($userInfo->customer_id) : $customer = NULL;
$userPayments = StripeInvoice::find()
->where('customer_id=:customer_id', [':customer_id' => $userInfo['customer_id']])
->orderBy(['date' => SORT_DESC])
->all();
$redeem_ch = NULL;
$customer != NULL ? $account_balance = $customer->account_balance : $account_balance = 0;
if($account_balance <= -1000 && $userInfo->refund_redeemed == 0):
$redeem_ch = StripeInvoice::find()->where(['refunded' => 0, 'customer_id' => $userInfo->customer_id])->one();
$userInfo->redeem_charge = $redeem_ch->charge_id;
$userInfo->save();
endif;
return $this->render('subscription', [
'userInfo' => $userInfo,
'customer' => $customer,
'account_balance' => $account_balance,
'userPayments' => $userPayments,
'referral_count' => UserInfo::find()->where(['referrer_code' => $userInfo->your_referral_code])->count(),
]);
}
【问题讨论】: