0

I'm developing a custom theme and running into errors. The theme has been tested and working on various servers but, for some reason, since uploading to siteground I get the following error (file paths, vendor name etc. have been redacted and replaced with notes contained inside square brackets).

Warning: Cannot modify header information - headers already sent

"0":"Warning: Cannot modify header information - headers already sent by (output started at /[magento_root_directory]/app/design/frontend/[vendor]/[theme]/registration.php:1) in /[magento_root_directory]/vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php on line 148","1"

I've read that this is to do with whitespace before the <?php tag, but there is no whitespace.

My registration.php file is as follows (with vendor/theme name redacted):

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/[VendorName]/[themename]',
    __DIR__
);

This is copied exactly from the file. The <?php tag is on the first line and there is no whitespace following it.

The site is installed on a siteground shared hosting instance, though I don't think this should make a difference.

Does anyone know what the problem is?

There is a massive stacktrace following the error message, which I can share if this information is not enough.

When I visit the website homepage I see a blank page, with nothing logged in the console and the URL reads:

http://[my_website].com/pub/errors/report.php?id=[error_id]&skin=default

The page reloads, looping indefinitely and creating a new report each time with the same error message.

Update

My theme.xml file is as follows:

<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>[ThemeTitle]</title>
    <parent>Magento/blank</parent>
    <media>
        <preview_image>media/preview.jpg</preview_image>
    </media>
</theme>
  • Can you post your theme files which is necessary to create theme? Does it work when enable default luma theme? – Sukumar Gorai Sep 10 '18 at 10:28
  • Yes the default theme is working fine. My theme isn't even enabled, and it was working previously. Which files exactly do you mean? I guess registration.php, theme.xml and etc/view.xml? Are there any others you need to see @SukumarGorai ? Thanks – Joshua Flood Sep 10 '18 at 16:32
1

Just check registration.php file on UTF-8 BOM elements. This a symbol on the start of file what can be seen without special mode in editors.

  • I just opened with standard UTF-8 encoding, as well as UTF-8 with BOM, but both files look exactly the same. – Joshua Flood Sep 10 '18 at 22:11
  • @JoshuaFlood save file with encoding "UTF-8 without BOM". Files look exactly because BOM symbol non-readable and non-viewable by default. It's a typical PHP issues what happening sometimes – Serge Yudin Sep 10 '18 at 23:06
  • Thanks mate! Working perfectly! Do you know why the problem occurs? I've been using the theme on numerous servers without issues. The last time I installed it, I had to make some quick fixes which were not applied to my local version. I had to copy the edited theme directly from the old server, but the server itself was not working properly and was missing its default language packs when the provider first set it up. So, when I transferred the files from the broken server to the new one, perhaps they were encoded using a broken language pack... or something. Thanks again! – Joshua Flood Sep 10 '18 at 23:47
  • P.S. perhaps you could include your tip about saving with plain UTF-8 encoding in your answer, for those people who are as ill-informed as I am. – Joshua Flood Sep 10 '18 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.