Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
102 views
in Technique[技术] by (71.8m points)

Yii2 - strpos(): Empty needle in PhpMessageSource.php on line 111

Please find below Stack Trace I pasted from apache error logs.

An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent. in /var/www/html/staging_v2/vendor/yiisoft/yii2/web/Response.php:373
Stack trace:
#0 
/var/www/html/staging_v2/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
#1 
/var/www/html/staging_v2/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException(Object(yii\base\ErrorException))
#3 
[internal function]: yii\base\ErrorHandler->handleException(Object(yii\base\ErrorException))
#4 

{main}
Previous exception:
yii\base\ErrorException: strpos(): Empty needle in /var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/PhpMessageSource.php:111
Stack trace:
#0 
[internal function]: yii\base\ErrorHandler->handleError(2, 'strpos(): Empty...', '/var/www/html/s...', 111, Array)
#1 
/var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/PhpMessageSource.php(111): strpos('en-US', '')
#2 
/var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/PhpMessageSource.php(78): yii\i18n\PhpMessageSource->loadFallbackMessages('yii', '', NULL, '/var/www/html/s...')
#3 /var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/MessageSource.php(107): yii\i18n\PhpMessageSource->loadMessages('yii', NULL)
#4 
/var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/MessageSource.php(87): yii\i18n\MessageSource->translateMessage('yii', '{attribute} can...', NULL)
#5 
/var/www/html/staging_v2/vendor/yiisoft/yii2/i18n/I18N.php(90): yii\i18n\MessageSource->translate('yii', '{attribute} can...', NULL)
#6 
/var/www/html/staging_v2/vendor/yiisoft/yii2/BaseYii.php(538): yii\i18n\I18N->translate('yii', '{attribute} can...', Array, NULL)
#7 
/var/www/html/staging_v2/vendor/yiisoft/yii2/validators/RequiredValidator.php(62): yii\BaseYii::t('yii', '{attribute} can...')
#8 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\validators\RequiredValidator->init()
#9 
[internal function]: yii\base\BaseObject->__construct(Array)
#10 
/var/www/html/staging_v2/vendor/yiisoft/yii2/di/Container.php(420): ReflectionClass->newInstanceArgs(Array)
#11 
/var/www/html/staging_v2/vendor/yiisoft/yii2/di/Container.php(171): yii\di\Container->build('yii\\validators\\...', Array, Array)
#12 
/var/www/html/staging_v2/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('yii\\validators\\...', Array, Array)
#13 
/var/www/html/staging_v2/vendor/yiisoft/yii2/validators/Validator.php(231): yii\BaseYii::createObject(Array)
#14 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(469): yii\validators\Validator::createValidator('yii\\validators\\...', Object(frontend\models\ContactForm), Array, Array)
#15 /var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(421): yii\base\Model->createValidators()
#16 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(190): yii\base\Model->getValidators()
#17 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(817): yii\base\Model->scenarios()
#18 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(435): yii\base\Model->activeAttributes()
#19 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Model.php(495): yii\base\Model->getActiveValidators('name')
#20 
/var/www/html/staging_v2/vendor/yiisoft/yii2/widgets/ActiveField.php(929): yii\base\Model->isAttributeRequired('name')
#21 
/var/www/html/staging_v2/vendor/yiisoft/yii2/widgets/ActiveField.php(405): yii\widgets\ActiveField->addAriaAttributes(Array)
#22 
/var/www/html/staging_v2/frontend/views/site/index.php(143): yii\widgets\ActiveField->textInput(Array)
#23 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/View.php(348): require('/var/www/html/s...')
#24 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile('/var/www/html/s...', Array)
#25 
/var/www/html/staging_v2/vendor/yiisoft/yii2/web/View.php(213): yii\base\View->renderFile('/var/www/html/s...', Array, Object(frontend\controllers\SiteController))
#26 /var/www/html/staging_v2/vendor/yiisoft/yii2/web/Controller.php(53): yii\web\View->renderAjax('index', Array, Object(frontend\controllers\SiteController))
#27 /var/www/html/staging_v2/frontend/controllers/SiteController.php(555): yii\web\Controller->renderAjax('index', Array)
#28 
[internal function]: frontend\controllers\SiteController->actionIndex()
#29 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#30 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#31 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('index', Array)
#32 
/var/www/html/staging_v2/vendor/yiisoft/yii2/web/Application.php(104): yii\base\Module->runAction('site/index', Array)
#33 
/var/www/html/staging_v2/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Application->handleRequest(Object(yii\web\Request))
#34 
/var/www/html/staging_v2/frontend/web/index.php(0): yii\base\Application->run()
#35 

You can find the issue here: https://staging-v2.storna.app Admin Portal works https://staging-v2.storna.app/admin API works too

Only landing pages have an issue.. it was working fine earlier.

What could be the issue?

There are only 2 issues in log. and 1 of which is warning and another is just a php7 notice. so I doubt it is due to this.

question from:https://stackoverflow.com/questions/65835893/yii2-strpos-empty-needle-in-phpmessagesource-php-on-line-111

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You seem to be using 2.0.40 version and this was already reported here. It seems the Problem only exists on PHP Version 7.1 - 7.4 as PHP 8.0 seems to pass successful with the reason being

Looks like the previous versions were resilient to language being set to null

You can either change your minimum-stability settings in the composer.json from stable to dev, and run composer update to update your yii framework to dev-master.

Or you can manually update those files only from this commit

I would use the second option as the first one will update all the packages too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...