Closed achertovsky closed 8 years ago
Could you check it on Yii 2.0.6 and provide the exact way to reproduce the problem?
yes. currently downgrading to 2.0.6 and trying with it. i'll tell about results
Problem 1
{
"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Project Template",
"keywords": ["yii2", "framework", "advanced", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"ext-imagick": "*",
"yiisoft/yii2": "2.0.6",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"duccio/apns-php" : "dev-master",
"bryglen/yii2-apns-gcm": "1.0.1",
"dektrium/yii2-user": "0.9.*@dev",
"odaialali/yii2-toastr": "dev-master",
"raoul2000/yii2-backstretch-widget": "*",
"guzuomuse/yii2-nicescroll": "dev-master",
"light/yii2-xmlparser": "*",
"dts/ebay-sdk-php": "^0.3.0",
"2amigos/yii2-tinymce-widget" : "~1.1",
"rmrevin/yii2-fontawesome": "^2.13",
"achertovsky/syslog": "@dev",
"kartik-v/yii2-widget-select2": "@dev",
"achertovsky/paypal-yii2": "@dev"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
HOWTO reproduce: i just override ErrorAction
namespace common\overrides\web;
use Yii;
use yii\base\Exception;
use yii\base\UserException;
use yii\helpers\Url;
class ErrorAction extends \yii\web\ErrorAction
{
public function run()
{
if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
// action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
$exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
}
if ($exception instanceof HttpException) {
$code = $exception->statusCode;
} else {
$code = $exception->getCode();
}
if ($exception instanceof Exception) {
$name = $exception->getName();
} else {
$name = $this->defaultName ?: Yii::t('yii', 'Error');
}
if ($code) {
$name .= " (#$code)";
}
if ($exception instanceof UserException) {
$message = $exception->getMessage();
} else {
$message = $this->defaultMessage ?: Yii::t('yii', 'An internal server error occurred.');
}
if (Yii::$app->getRequest()->getIsAjax()) {
return "$name: $message";
} else {
Yii::$app->getSession()->setFlash('error', $message);
return $this->controller->redirect(Url::toRoute(['/site/dashboard']));
}
}
}
changed it in SiteController
public function actions()
{
return [
'error' => [
'class' => 'common\overrides\web\ErrorAction',
],
];
}
goto unexist route (try to 404) and got no redirect. just clear page
While i was waiting i'm developing another site. there i use default error reporting.
So i navigate to page and expect 404, but got blank page
it is not a good idea to redirect instead of showing the error page. If the page you are redirecting to also has an error you get an infinite loop.
but got blank page
check the error log.
Doesn't seem to be framework issue.
I have no error inside logs. None error in application log, no errors in apache log.
I reproduce this bug on 3 project copies and all 3 times it happen after composer update to 2.0.7. Don't seems weird to you? I can broke 4-th project copy and write it all on video
As @cebe noted, most probably you have an error in your /site/dashboard
action so it is doing infinte redirect. That's part of your code, not a framework.
i have another project where i have not overrided this part. there also this bug. also upgraded to 2.0.7 i'm not getting 404 page. i'm get blank page
OK. Are you able to reproduce it on basic application template with minimal amount of modifications?
i have that kind of project. its almost clear. i will try reproduce it there.
@samdark it's a pity, but i can't reproduce it in another project. tomorrow i'll go to office and i will try to find reason from there.
but question is: why it's not working in my primary project? i recorded all to video. before upgrade all good, after it - crush. what can be reason of?
please, leave this ticket open until i will find the reason.
Could be anything. Unfortunately, if we can't reproduce it, we can't fix it.
What status code of this blank page?
404. with no redirect (it exclude suggestion of @cebe about infinite redirect)
same page 2.0.6: http://screencloud.net/v/yFAd 2.0.7: http://screencloud.net/v/D7sk
here is logs from ./frontend/runtime/logs/app.log in 2.0.6 and 2.0.7 Looks like 2.0.7 dont see my route.
2.0.6
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Application::bootstrap] Bootstrap with dektrium\user\Bootstrap::bootstrap()
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Module::getModule] Loading module: user
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Application::bootstrap] Bootstrap with common\components\Bootstrap::bootstrap()
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Module::getModule] Loading module: gii
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\gii\Module::bootstrap()
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\log\Dispatcher
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\web\UrlRule::parseRequest] Request parsed with URL rule: dashboard
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\web\Application::handleRequest] Route requested: 'site/dashboard'
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Controller::runAction] Route to run: site/dashboard
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\InlineAction::runWithParams] Running action: frontend\controllers\SiteController::actionDashboard()
2016-02-17 07:59:06 [127.0.0.1][9][-][trace][yii\base\Module::getModule] Loading module: item
in /data/projects/dsmtool/common/modules/item/models/targets/ItemEbay.php:470
in /data/projects/dsmtool/common/modules/user/models/User.php:467
in /data/projects/dsmtool/frontend/controllers/SiteController.php:88
2016-02-17 07:59:07 [127.0.0.1][9][-][trace][yii\base\View::renderFile] Rendering view file: /data/projects/dsmtool/themes/basic/frontend/views/site/dashboard.php
in /data/projects/dsmtool/frontend/controllers/SiteController.php:94
2016-02-17 07:59:07 [127.0.0.1][9][-][trace][yii\base\View::renderFile] Rendering view file: /data/projects/dsmtool/themes/basic/frontend/views/layouts/main.php
in /data/projects/dsmtool/frontend/controllers/SiteController.php:94
2.0.7
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with dektrium\user\Bootstrap::bootstrap()
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Module::getModule] Loading module: user
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with common\components\Bootstrap::bootstrap()
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Module::getModule] Loading module: gii
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with yii\gii\Module::bootstrap()
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with yii\log\Dispatcher
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\web\UrlManager::parseRequest] No matching URL rules. Using default URL parsing logic.
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\web\Application::handleRequest] Route requested: 'klgaskjgaskj'
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][error][yii\web\HttpException:404] exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "klgaskjgaskj".' in /data/projects/dsmtool/vendor/yiisoft/yii2/base/Module.php:460
Stack trace:
#0 /data/projects/dsmtool/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('klgaskjgaskj', Array)
#1 /data/projects/dsmtool/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /data/projects/dsmtool/frontend/web/index.php(32): yii\base\Application->run()
#3 {main}
Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in /data/projects/dsmtool/vendor/yiisoft/yii2/web/Application.php:96
Stack trace:
#0 /data/projects/dsmtool/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /data/projects/dsmtool/frontend/web/index.php(32): yii\base\Application->run()
#2 {main}
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Controller::runAction] Route to run: site/error
2016-02-17 07:54:08 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Action::runWithParams] Running action: common\overrides\web\ErrorAction::run()
Most likely you are required to flush your application cache. Please, check the release notes in UPGRADE.md
Thanks, but cache flush haven't help
alexander@workone:/data/projects/dsmtool$ ./yii cache/flush-all
The following cache components were processed:
* cache (yii\caching\FileCache)
alexander@workone:/data/projects/dsmtool$ tail -f -n22 ./frontend/runtime/logs/app.log
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with dektrium\user\Bootstrap::bootstrap()
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Module::getModule] Loading module: user
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with common\components\Bootstrap::bootstrap()
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Module::getModule] Loading module: gii
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with yii\gii\Module::bootstrap()
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Application::bootstrap] Bootstrap with yii\log\Dispatcher
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\web\UrlManager::parseRequest] No matching URL rules. Using default URL parsing logic.
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\web\Application::handleRequest] Route requested: 'dashboardasgas'
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][error][yii\web\HttpException:404] exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "dashboardasgas".' in /data/projects/dsmtool/vendor/yiisoft/yii2/base/Module.php:460
Stack trace:
#0 /data/projects/dsmtool/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('dashboardasgas', Array)
#1 /data/projects/dsmtool/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /data/projects/dsmtool/frontend/web/index.php(32): yii\base\Application->run()
#3 {main}
Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in /data/projects/dsmtool/vendor/yiisoft/yii2/web/Application.php:96
Stack trace:
#0 /data/projects/dsmtool/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /data/projects/dsmtool/frontend/web/index.php(32): yii\base\Application->run()
#2 {main}
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Controller::runAction] Route to run: site/error
2016-02-17 08:23:23 [127.0.0.1][9][0u3bqj9gfonbkdd6l8r1u0kpg0][trace][yii\base\Action::runWithParams] Running action: common\overrides\web\ErrorAction::run()
requirements.php
alexander@workone:/data/projects/dsmtool$ php ./requirements.php
Yii Application Requirement Checker
This script checks if your server configuration meets the requirements
for running Yii application.
It checks if the server is running the right version of PHP,
if appropriate PHP extensions have been loaded, and if php.ini file settings are correct.
Check conclusion:
-----------------
PHP version: OK
Reflection extension: OK
PCRE extension: OK
SPL extension: OK
Ctype extension: OK
MBString extension: OK
OpenSSL extension: OK
Intl extension: WARNING!!!
Required by: Internationalization support
Memo: PHP Intl extension 1.0.2 or higher is required when you want to use advanced parameters formatting
in Yii::t(), non-latin languages with Inflector::slug(),
IDN-feature of
EmailValidator or UrlValidator or the yii\i18n\Formatter class.
ICU version: WARNING!!!
Required by: Internationalization support
Memo: ICU 49.0 or higher is required when you want to use # placeholder in plural rules
(for example, plural in
Formatter::asRelativeTime()) in the yii\i18n\Formatter class. Your current ICU version is (ICU is missing).
ICU Data version: WARNING!!!
Required by: Internationalization support
Memo: ICU Data 49.1 or higher is required when you want to use # placeholder in plural rules
(for example, plural in
Formatter::asRelativeTime()) in the yii\i18n\Formatter class. Your current ICU Data version is (ICU Data is missing).
Fileinfo extension: OK
DOM extension: OK
PDO extension: OK
PDO SQLite extension: WARNING!!!
Required by: All DB-related classes
Memo: Required for SQLite database.
PDO MySQL extension: OK
PDO PostgreSQL extension: WARNING!!!
Required by: All DB-related classes
Memo: Required for PostgreSQL database.
Memcache extension: WARNING!!!
Required by: MemCache
APC extension: WARNING!!!
Required by: ApcCache
GD PHP extension with FreeType support: OK
ImageMagick PHP extension with PNG support: OK
Expose PHP: WARNING!!!
Required by: Security reasons
Memo: "expose_php" should be disabled at php.ini
PHP allow url include: OK
PHP mail SMTP: OK
------------------------------------------
Errors: 0 Warnings: 8 Total checks: 23
Please show your rules config. Also, which version were you using before updating from composer?
My routing rules?
Also, which version were you using before updating from composer?
yii2 version? it was 2.0.6
here is my route rules inside ./frontend/config/main.php
'components' => [
'urlManager' => [
'baseUrl' => '/',
'rules' => [
//template
'templates' => 'template/default/index',
//item
'find' => 'item/default/find',
'publish' => 'item/default/publish',
'monitor' => 'item/monitor/monitor',
//site
'statistics' => 'site/statistics',
'dashboard' => 'site/dashboard',
'logout' => 'site/logout',
'payment' => 'site/payment',
//user
'signup' => 'user/registration/register',
'signin' => 'user/security/login',
'account' => 'user/settings/profile',
],
],
//...
],
I don't see anything that should match /dashboardasgas
.
That means error action is triggered.
404 is there:
if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
// action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
$exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
}
Can you check if I'm correct about where 404 is triggered and if it's triggered?
Are you using AJAX to call that action or not?
Sorry, i wasn't near my PC.
i have no route called /dashboardasgas
. problem is the fact, that im trying to call error and in case of error it must redirect me to home page and show a TOASTR, but currently i'm getting a blank page.
after debugging i noticed that i'm not got inside
if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
// action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
$exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
}
Are you using AJAX to call that action or not?
no. i'm just go to the unexisting route. but in case of another errors it is possible to be AJAX
Main goal is to catch any error and show it in TOASTR
in 2.0.6 it also not going inside
if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
// action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
$exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
}
here is screenshot with debug inside ErrorAction. error there has type yii\web\NotFoundHttpException
http://screencloud.net/v/A4Us
OK. Got the reason. You forgot to send response:
$this->controller->redirect(Url::toRoute(['/site/index']))->send();
@samdark ->send() is always required? cause before i was using redirect without it
Not always. In case of controller, application is sending headers itself at the very end of request. In case of error normally error handler isn't using headers set so not sending it automatically.
@samdark thanks alot for your patience and time
You're welcome.
I overrided ErrorAction. I want not render error template, i want redirect from action to main page and show TOASTR. it worked before i updated my composer. i noticed that yii 2.0.7 released. maybe thats why? i'm waiting for response. i will give any required info