Can't save custom skin

Bug #1233171 reported by Mike Kelly
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Aaron Wells

Bug Description

In 1.8RC1, when trying to save a custom skin, I always get the following error:

ERROR - something bad happened after headers have been sent. Check the error log for more information.

MySQL, OSX, Firefox 23.0.1

Some entries from the PHP error log:

[30-Sep-2013 14:21:46 Europe/London] [WAR] cd (lib/pieforms/pieform.php:495) Cannot modify header information - headers already sent by (output started at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lang/en.utf8/skin.php:1)
[30-Sep-2013 14:21:46 Europe/London] Call stack (most recent first):
[30-Sep-2013 14:21:46 Europe/London] * log_message("Cannot modify header information - headers already...", 8, true, true, "/Volumes/Macintosh HD/Users/mikekelly/Webwork/git_...", 495) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/errors.php:446
[30-Sep-2013 14:21:46 Europe/London] * error(2, "Cannot modify header information - headers already...", "/Volumes/Macintosh HD/Users/mikekelly/Webwork/git_...", 495, array(size 13)) at Unknown:0
[30-Sep-2013 14:21:46 Europe/London] * header("HTTP/1.1 303 See Other") at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:495
[30-Sep-2013 14:21:46 Europe/London] * Pieform->__construct(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:170
[30-Sep-2013 14:21:46 Europe/London] * Pieform::process(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:71
[30-Sep-2013 14:21:46 Europe/London] * pieform(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/skin/design.php:503
[30-Sep-2013 14:21:46 Europe/London]
[30-Sep-2013 14:21:46 Europe/London] [WAR] cd (lib/pieforms/pieform.php:496) Cannot modify header information - headers already sent by (output started at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lang/en.utf8/skin.php:1)
[30-Sep-2013 14:21:46 Europe/London] Call stack (most recent first):
[30-Sep-2013 14:21:46 Europe/London] * log_message("Cannot modify header information - headers already...", 8, true, true, "/Volumes/Macintosh HD/Users/mikekelly/Webwork/git_...", 496) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/errors.php:446
[30-Sep-2013 14:21:46 Europe/London] * error(2, "Cannot modify header information - headers already...", "/Volumes/Macintosh HD/Users/mikekelly/Webwork/git_...", 496, array(size 13)) at Unknown:0
[30-Sep-2013 14:21:46 Europe/London] * header("Location:http://localhost/mamp/maharacore//skin/in...") at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:496
[30-Sep-2013 14:21:46 Europe/London] * Pieform->__construct(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:170
[30-Sep-2013 14:21:46 Europe/London] * Pieform::process(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:71
[30-Sep-2013 14:21:46 Europe/London] * pieform(array(size 8)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/skin/design.php:503
[30-Sep-2013 14:21:46 Europe/London]
[30-Sep-2013 14:22:34 Europe/London] [WAR] 73 (lib/web.php:2709) Headers already sent when redirect() was called (output started in /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lang/en.utf8/skin.php on line 1
[30-Sep-2013 14:22:34 Europe/London] Call stack (most recent first):
[30-Sep-2013 14:22:34 Europe/London] * redirect("/view/view.php?id=6") at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/view/skin.php:193
[30-Sep-2013 14:22:34 Europe/London] * viewskin_submit(object(Pieform), array(size 5)) at Unknown:0
[30-Sep-2013 14:22:34 Europe/London] * call_user_func_array("viewskin_submit", array(size 2)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:528
[30-Sep-2013 14:22:34 Europe/London] * Pieform->__construct(array(size 2)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:170
[30-Sep-2013 14:22:34 Europe/London] * Pieform::process(array(size 2)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pieforms/pieform.php:71
[30-Sep-2013 14:22:34 Europe/London] * pieform(array(size 2)) at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/view/skin.php:86
[30-Sep-2013 14:22:34 Europe/London]

Tags: skins
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: none → 1.8.0
tags: added: skins
Revision history for this message
Robert Lyon (robertl-9) wrote :

I suspect it might be the form rendering code being mixed in with smarty template code and has a select dropdown in the form.

Revision history for this message
Robert Lyon (robertl-9) wrote :

Hmm, now that I read the error messages it looks to be wigging out on line 496 of the lib/pieforms/pieform.php file.
which is a header('Location: ') call, which should be reached if one hit cancel in a form (not when they are saving it).

Skins can be made both in the Portfolio -> Skins section and in the Administration -> Configure site -> Skins section

Is this behaviour happening in both places?

I am unable to replicate the error on my instance.

Revision history for this message
Mike Kelly (m-f-kelly) wrote :

Yes, I'm getting the same error from the admin pages too. Strange one.
Maybe I've missed something? I checked again just now - checked out commit 92356eb6a27337280e4e21659397a4dc9e62b81e (Version bump for 1.8rc2dev) and installed to a new database. Same error.

Aaron Wells (u-aaronw)
Changed in mahara:
assignee: nobody → Son Nguyen (ngson2000)
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Hi Mike,

"Output before headers sent" can be a tough one to track down. It just means header() got called after something, *anything*, printed some output. This can be as simple as an empty line before "<?php" or after "?>" in one file.

So, that said, I'm able to replicate this error if I put some whitespace outside the <? ?> tags on my config.php file, but if I fix that, no problems.

Can you see if you get this same error when you install 1.7_STABLE? If so, that would indicate it's an issue with your setup.

Cheers,
Aaron

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Hi Mike,

Oh, or better yet, do a "view HTML source" on one of the affected pages and see what's printed on the very first line. That may give us some idea of what is being output before the headers.

Cheers again,
Aaron

Aaron Wells (u-aaronw)
Changed in mahara:
status: New → Incomplete
importance: Undecided → High
Aaron Wells (u-aaronw)
Changed in mahara:
status: Incomplete → Confirmed
Revision history for this message
Aaron Wells (u-aaronw) wrote :

I just had the same porblem. It turned out there was a BOM ( http://en.wikipedia.org/wiki/Byte_order_mark ) at the beginning of lang/en.utf8/skin.php, and PHP isn't great at handling those. I now realize this was sort of obvious because it's mentioned in the first line of that error:

"output started at /Volumes/Macintosh HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lang/en.utf8/skin.php:1"

Dropping the BOM makes it work correctly. I'll push a patch.

Revision history for this message
Aaron Wells (u-aaronw) wrote :
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/2580
Committed: http://gitorious.org/mahara/mahara/commit/1a2e2f71807052416ec8fe5eafec62ec73c932ad
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit 1a2e2f71807052416ec8fe5eafec62ec73c932ad
Author: Aaron Wells <email address hidden>
Date: Mon Oct 7 14:06:44 2013 +1300

Removing initial BOM from a lang file, which breaks PHP's ability to load it

Bug1233171

Change-Id: I655eb2f035497a52960765852fa8095ec7cd94e8

Aaron Wells (u-aaronw)
Changed in mahara:
status: Confirmed → Fix Committed
assignee: Son Nguyen (ngson2000) → Aaron Wells (u-aaronw)
Revision history for this message
Mike Kelly (m-f-kelly) wrote :

Good catch. I had to create a completely new skin.php file here and copy the content across. The BOM wasn't visible in the original file even when I was displaying invisible characters.

Revision history for this message
Mike Kelly (m-f-kelly) wrote : Re: [Bug 1233171] Re: Can't save custom skin
Download full text (7.2 KiB)

Hi Aaron,
I just got your messages on this. Your BOM bug fix worked here.
Thanks,
Mike

Mike Kelly
Learning Technologies Developer

University of the Arts London
Centre for Learning and Teaching in Art and Design (CLTAD)
272 High Holborn
London WC1V 7EY
United Kingdom

Tel: +44 (0)20 7514 6206
Website: www.arts.ac.uk/study-at-ual/learning-and-teaching/
<http://www.arts.ac.uk/study-at-ual/learning-and-teaching/>
Blog: http://cltad.myblog.arts.ac.uk/

In office Monday to Thursday.

On 03/10/2013 21:32, "Aaron Wells" <email address hidden> wrote:

>Hi Mike,
>
>Oh, or better yet, do a "view HTML source" on one of the affected pages
>and see what's printed on the very first line. That may give us some
>idea of what is being output before the headers.
>
>Cheers again,
>Aaron
>
>--
>You received this bug notification because you are subscribed to the bug
>report.
>https://bugs.launchpad.net/bugs/1233171
>
>Title:
> Can't save custom skin
>
>Status in Mahara ePortfolio:
> New
>
>Bug description:
> In 1.8RC1, when trying to save a custom skin, I always get the
> following error:
>
> ERROR - something bad happened after headers have been sent. Check the
> error log for more information.
>
> MySQL, OSX, Firefox 23.0.1
>
> Some entries from the PHP error log:
>
> [30-Sep-2013 14:21:46 Europe/London] [WAR] cd
>(lib/pieforms/pieform.php:495) Cannot modify header information - headers
>already sent by (output started at /Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lang/en.
>utf8/skin.php:1)
> [30-Sep-2013 14:21:46 Europe/London] Call stack (most recent first):
> [30-Sep-2013 14:21:46 Europe/London] * log_message("Cannot modify
>header information - headers already...", 8, true, true,
>"/Volumes/Macintosh HD/Users/mikekelly/Webwork/git_...", 495) at
>/Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/erro
>rs.php:446
> [30-Sep-2013 14:21:46 Europe/London] * error(2, "Cannot modify header
>information - headers already...", "/Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_...", 495, array(size 13)) at Unknown:0
> [30-Sep-2013 14:21:46 Europe/London] * header("HTTP/1.1 303 See
>Other") at /Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pief
>orms/pieform.php:495
> [30-Sep-2013 14:21:46 Europe/London] *
>Pieform->__construct(array(size 8)) at /Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pief
>orms/pieform.php:170
> [30-Sep-2013 14:21:46 Europe/London] * Pieform::process(array(size
>8)) at /Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/lib/pief
>orms/pieform.php:71
> [30-Sep-2013 14:21:46 Europe/London] * pieform(array(size 8)) at
>/Volumes/Macintosh
>HD/Users/mikekelly/Webwork/git_repositories_php/maharacore/htdocs/skin/des
>ign.php:503
> [30-Sep-2013 14:21:46 Europe/London]
> [30-Sep-2013 14:21:46 Europe/London] [WAR] cd
>(lib/pieforms/pieform.php:496) Cannot modify header information - headers
>already sent by (output starte...

Read more...

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Yeah, those BOM's are pretty sneaky. It didn't show up on any of my text editors either. The only program I could actually see it in was the command-line version of "git diff". I had to track it down by trial and error -- the program continued to fail when I deleted all the contents of skin.php; it ran if I deleted skin.php and replaced it with an empty file; it failed if I used skin.php empty of everything except the opening <?php line; and then finally it worked when I copied everything EXCEPT the first line into a new file. It was only then, when I was "git add"ing the changes, that git diff finally exposed the BOM character.

When I'm troubleshooting software, I try to keep Sherlock Holmes' adage in mind -- "When you have eliminated the impossible, whatever remains, however improbable, must be the truth." ;-)

Aaron Wells (u-aaronw)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.