Magento Error: Headers already sent [duplicate] - php

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I got this error while adding products to the cart in my site:
Cannot send headers; headers already sent in /home/website/public_html/app/code/local/Perpetual/MultiAdd/controllers/Checkout/CartController.php, line 153
Trace:
#0 /home/website/public_html/lib/Zend/Controller/Response/Abstract.php(147): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/website/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(585): Zend_Controller_Response_Abstract->setRedirect('http://www.trum...')
#2 /home/website/public_html/app/code/core/Mage/Checkout/controllers/CartController.php(85): Mage_Core_Controller_Varien_Action->_redirect('checkout/cart')
#3 /home/website/public_html/app/code/local/Perpetual/MultiAdd/controllers/Checkout/CartController.php(203): Mage_Checkout_CartController->_goBack()
#4 /home/website/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Perpetual_MultiAdd_Checkout_CartController->addmultipleAction()
#5 /home/website/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch('addmultiple')
#6 /home/website/public_html/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#7 /home/website/public_html/wholesale/index.php(65): Mage::run('wholesale', 'website')
#8 {main}
Edit: Disabled extraneous plugin and that did not solve issue.
It appears that headers are sent in line #1 and attempted to be sent again in the file referenced in the error, CartController.php -
$url = $this->_getSession()->getRedirectUrl(true)
if ($url) {
$this->getResponse()->setRedirect($url);
} else {
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
}
Any ideas on how to stop Magento from sending headers before Mage does?

There should be a module settings file in app/etc/modules/ with a boolean in it. Disabling a module output doesn't disable the module. Only its output.
Removing the module from the community folder should do the job, but it could be dirty depending on whether this plugin has created tables on your database or not.

Suspicious module disabled?
Ok, let's go for another answer then.
First, check whether you get any output before the error stack trace. An output provokes the sending of headers for this output.

GO var/report and find out the problem file.
Check if there is any space before

Related

Fatal Error WordPress Custom Post Type UI + WPML

After updating the wp-core, wpml plugin the other language link stopped working, after this, we contacted the support, and tried to roll back everything, and nothing helps
We noticed the conflict between two plugins WPML and Custom Post Type UI.
We started getting this Fatal Error:
Fatal error: Uncaught ValueError: Missing format specifier at end of string in /home/itdspl/domains/itds.tld/public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php:416 Stack trace: #0 /home/itdspl/domains/itds.tld/public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php(416): sprintf('Nigdy wi\xC4\x99cej %', 'Case Study') #1 /home/itdspl/domains/itds.tld/public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php(320): cptui_register_single_post_type(Array) #2 /home/itdspl/domains/itds.tld/public_html/wp-includes/class-wp-hook.php(308): cptui_create_custom_post_types('') #3 /home/itdspl/domains/itds.tld/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #4 /home/itdspl/domains/itds.tld/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /home/itdspl/domains/itds.tld/public_html/wp-settings.php(617): do_action('init') #6 /home/itdspl/domains/itds.tld/public_html/wp-config.php(198): require_once('/home/itdspl/do...') #7 /home/itdspl/domains/itds.tld/public_html/wp-load.php(50): require_once('/home/itdspl/do...') #8 /home/itdspl/domains/itds.tld/public_html/wp-blog-header.php(13): require_once('/home/itdspl/do...') #9 /home/itdspl/domains/itds.tld/public_html/index.php(17): require('/home/itdspl/do...') #10 {main} thrown in /home/itdspl/domains/itds.tld/public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 416
How it can be resolved? From where should I start or what to do?
What is an idiot minus to this question??? The problem was not in the plugin code!
After days of searching for the issue and talking to support, I found an issue in String Translation for plugins.
We haven't translated the Custom Post Type UI plugin, and we found that from 400 lines of strings only one was translated and it caused the issue.
No %s Found >>>> Nie %
So this % at the end of the string was the main problem. Obviously that this sign "%" it's incorrect for the code to be in the end. I don't know how that happened since we didn't do this, but probably some issues after updating.
So, be aware, that it could be a really small thing and actually not obvious to check. We searched really deeply since we couldn't see any fatal errors even with a debug mode.

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

Magento white page at front and backend

After customizing some files last week, both the back end and front end of the site I’m developing for went blank. I have already searched the internet and tried out some possible solutions, but none of them works.
Somehow I can’t manage to show any error message. I already uncommented ini_set(’display_errors’, 1);, changed error_reporting(E_ALL | E_STRICT); into error_reporting(E_ALL); and I tried even more possible solutions.
I also edited the memory to 128M, changed some settings in php.ini, changed local.xml.sample to local.xml. Nothing seems to work.
I seriously have no idea how I can solve this, so that’s why I’m here. I hope someone can help me. If you need more information, please ask, I don’t really know what’s necessary to answer my question.
After adding the following lines to index.php I managed to get error messages:
error_reporting(E_ALL);
ini_set(’display_errors’, 1);
ini_set(‘memory_limit’, ’256M’);
The error I get is:
Cannot send headers; headers already sent in /home/cheapas/public_html/index.php, line 39
Trace:
#0 /home/cheapas/public_html/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/cheapas/public_html/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader(’Content-Type’, ‘text/html; char...’)
#2 /home/cheapas/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse()
#3 /home/cheapas/public_html/app/code/core/Mage/Core/Model/Url/Rewrite.php(204): Mage_Core_Controller_Varien_Front->getResponse()
#4 /home/cheapas/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(166): Mage_Core_Model_Url_Rewrite->rewrite()
#5 /home/cheapas/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /home/cheapas/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#7 /home/cheapas/public_html/index.php(91): Mage::run(’’, ‘store’)
#8 {main}
Guess what, line 39 is: ini_set(‘memory_limit’, ’256M’);
When I delete this line I get a blank page again, so that doesn’t solve anything. Does anyone have an idea on solving this? Thanks!
As you may have understood, I actually can get error messages to show when I force an error by adding an unknown or uncomplete line to my index.php. Somehow there is a problem which doesn’t want to show up.

Keep on getting error on website using AnchorCMS

I’m attempting to use AnchorCMS. I keep on getting this message at the bottom of my page.
Uncaught Exception
Undefined offset: 6
Origin
on line 90
Trace
#0 [internal function]: System\Error::shutdown()
#1 {main}
I’ve already tried deleting and reloading all files.
I also have the same problem as you. I tried to edit in Anchor/config/error.php report => true to report => false, but I’ve got a server error. Then I deleted the value (true or false), left it blank, and it succeed.

How to fix "Cannot send headers; headers already sent" in Zend? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Headers already sent by PHP
I am new to zend.I tried to create simple form having two fields using zend. When i click submit button got the following error,
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in D:\xampp\htdocs\study\quickstart\application\controllers\EmployeeController.php, line 35' in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php:282 Stack trace: #0 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(300): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php(727): Zend_Controller_Response_Abstract->sendHeaders() #2 D:\xampp\php\PEAR\Zend\Controller\Front.php(984): Zend_Controller_Response_Abstract->sendResponse() #3 D:\xampp\php\PEAR\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front->dispatch() #4 D:\xampp\php\PEAR\Zend\Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() #5 D:\xampp\htdocs\study\quickstart\public\index.php(25): Zend_Application->run() #6 {main} thrown in D:\xampp\php\PEAR\Zend\Controller\Response\Abstract.php on line 282
I checked the following link,
zend header already send problem
I removed white spaces and gave close tag in all files, But still i am getting same error.
How to fix this error ?
Following shows EmployeeController.php:
<?php
class EmployeeController extends Zend_Controller_Action
{
public function init()
{
}
public function indexAction()
{
$form = new Default_Form_Empdetails();
$this->view->form = $form;
$request = $this->getRequest();
$formData = $request->getPost();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$empName = $form->getValue('empName');
$empAddress = $form->getValue('empAddress');
$emp = new Default_Model_DBTable_Employee();
$emp->addAlbum($empName, $empAddress);
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
}
}
?>
Kindly help me
It may be because of extra white spaces after php closing tag (?>) in some file.
Also read this Post:
PHP development: why redirects don't work (headers already sent)
Any HTML output, including the DOCTYPE declaration or any HTML tag,
including the head of the page
Extra whitespace before the opening PHP tag of the page, or outside the
PHP tags of an include file
Using print() or echo before calling header() or session_start()
Using virtual() to include files
Using the byte-order mark (BOM) at the beginning of a page
For example:

Categories