phpBB Debug Notice | Cannot Modify Header Information

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Suggested Hosts
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
MandoaOrg
Registered User
Posts: 8
Joined: Sat Jan 29, 2011 10:22 pm

phpBB Debug Notice | Cannot Modify Header Information

Post by MandoaOrg » Thu Feb 03, 2011 8:25 am

Support Request Template
What version of phpBB are you using? phpBB 3.0.8
What is your board's URL? http://forum.mandoa.org
Who do you host your board with? http://www.hostmonster.com
How did you install your board? First install was with a script manager. When that broke, I removed it and used the download package from phpBB.com
Is your board a fresh install or a conversion? Fresh Install
Do you have any MODs installed? Yes
Is registration required to reproduce this issue? Yes
What MODs do you have installed?
Allowed Extensions Mod
Auto Database Backup
BBcode Buttons on Quick Reply
Convert quoted images to url
Genders
Popup Layer on New PMs
Post First Before Voting
Prime BBCode Spoiler
Prime Signature Cap
Quote User Back Link (QUBL)
ReIMG Image Resizer
Search users' posts in viewtopic
th23 Last Post Subject
What styles do you currently have installed?
prosilver * <--This one is set to default and is currently used by all users.
se_sprites
Lucid Lime
blackbox_green
LiquidBlack
CA Orbital
prosilver Special Edition
UniversalSpace
twilightBB
khaki_black
subsilver2Clean
subsilver2
SE Square Left
K_Kitty
Minimal
Superior
Supernova
What language(s) is your board currently using? English (UK)
Which database type/version are you using? MySQL 5
What is your level of experience? New to phpBB but not PHP
What username can be used to view this issue? test_user
What password can be used to view this issue? Password
When did your problem begin? Presumably after installing a bunch of mods. I don't think it was happening before I installed the mods. This problem happened in my first iteration of the board, and then again in my second iteration. In fact, the reason I reinstalled the board altogether is because of this issue and my inability to track it down, despite uninstalling all my mods and styles and changing all kinds of settings. I never did try and track the issue through the code, though.
Please describe your problem. I installed a bunch of mods and wound up with a few problems, and couldn't successfully uninstall most of them, so I backed up my database from within phpmyadmin, deleted all files, and resintalled from a fresh download package.

I then restored the database, and emptied the mods table since none of them were installed or active anymore.

I finally reinstalled the mods listed above, since they were the only features I found absolutely necessary.

Now, whenever I make a post containing BBCode (never one not containing it), the following errors appear in the following situations:

When I press "Preview:"

[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 43: Invalid argument supplied for foreach()
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4535: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3706)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4537: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3706)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4538: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3706)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4539: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3706)

When I press "Submit:"

[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 43: Invalid argument supplied for foreach()

Warning: Cannot modify header information - headers already sent by (output started at /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php:3706) in /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php on line4535

Warning: Cannot modify header information - headers already sent by (output started at /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php:3706) in /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php on line4537

Warning: Cannot modify header information - headers already sent by (output started at /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php:3706) in /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php on line4538

Warning: Cannot modify header information - headers already sent by (output started at /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php:3706) in /home1/thomasp1/public_html/mandotranslator/forum/includes/functions.php on line4539

----------

These problems never cause any cessation of activity on the board, they just show up and are annoying. The post always completes successfully and appears normally in the topic.

If you log into my forum to test it out, please restrict your tests to the "Testing Forum," just out of convenience. It would be much appreciated.

Also, I just noticed, the "Search" box in the upper-right corner changes when I press "Preview," too: instead of saying "Search" in the box, it says "Search…" (In case those characters don't show up right, that's "Search" followed by the carat-accented a, the Euro symbol, and the split vertical bar a.k.a. broken bar or parted rule.)
Generated by SRT Generator ($Rev: 4778 $)
Last edited by Pit$Bull on Thu Feb 03, 2011 9:37 am, edited 2 times in total.
Reason: Topic icon changed

User avatar
AmigoJack
Registered User
Posts: 5155
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: phpBB Debug Notice | Cannot Modify Header Information

Post by AmigoJack » Thu Feb 03, 2011 8:38 am

MandoaOrg wrote:file /includes/message_parser.php
...is unoriginal, judging that message. Attach it to a reply, so we can view it.
The worst thing about censorship is ███████████

MandoaOrg
Registered User
Posts: 8
Joined: Sat Jan 29, 2011 10:22 pm

Re: phpBB Debug Notice | Cannot Modify Header Information

Post by MandoaOrg » Thu Feb 03, 2011 8:50 am

Gladly. :)

Amusingly enough, opening the source for the file tells me it is responsible for converting BBCode, which makes perfect sense. :P

File is attached.

----------

So...looking at the two php files (message_parser.php and functions.php), and taking into account the error messages, I'm probably stating the obvious, but it appears that the code is trying to send the header to the browser, but some other function already sent the header before it could get around to it. Looking at line 4535 in functions.php, I see it specifying headers, and the error message says the error happens at line 4535 (where it tries to send the header), because the headers were already sent at line 3706. The strange thing about that is that line 3706 is the line where it starts assembling [phpBB Debug] messages, and I see nothing about headers in that section of the code. The section in message_parser.php where the error occurs is in the foreach() loop, and it says invalid arguments...so the array $qmatch[2] is likely receiving invalid (or null) entries from someplace, which it is unprepared to handle...maybe...

All I can say is that with my limited knowledge of PHP, that foreach() loop is pretty elegant in its execution for a find and replace function. I wish I could write code like that without seeing it applied first. :P

I should have started looking at the code in the first place, because then I would have been full-awake, undistracted, and caffeine-fueled (in other words, in coding mode). I'm willing to bet this is because of a mod I installed, but the problem will be finding out which one is to blame. I'd be willing to bet it's one of these four, since they all have to do with modifying BBCode:
BBcode Buttons on Quick Reply
Convert quoted images to url
Prime BBCode Spoiler
Quote User Back Link (QUBL)

UPDATE:

Oh jeez. I should really not do this stuff when it's 3 AM. I just figured it out. At line 41 in message_parser.php, there is a comment that gives it all away. I will spell it out below:

Code: Select all

//Start MOD Convert quoted images to url 	
		preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
		foreach ($qmatch[2]as $qmatchin){
			$qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$this->message = str_replace($qmatchin, $qres, $this->message);
		}
		//End MOD Convert quoted images to url
I solved my own problem while sitting here spouting possibilities to you all. Thank you for being a sounding board, and for serving as an archive to store my self-made solution for future usefulness. Or something.

Good night/morning. :P
Attachments
message_parser.php
(49.55 KiB) Downloaded 10 times

User avatar
AmigoJack
Registered User
Posts: 5155
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: phpBB Debug Notice | Cannot Modify Header Information

Post by AmigoJack » Thu Feb 03, 2011 9:44 am

The modification looks suspicious:
  1. It's at a logically wrong place (inserted at the wrong position by you or any tool) and
  2. it's too optimistic (imprecise coding by the MOD author)
Find this:

Code: Select all

        if (!$this->bbcodes)
                        //Start MOD Convert quoted images to url     
        preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
        foreach ($qmatch[2]as $qmatchin){
            $qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $this->message = str_replace($qmatchin, $qres, $this->message);
        }
        //End MOD Convert quoted images to url
        {
            $this->bbcode_init();
        } 
and change it to:

Code: Select all

        if (!$this->bbcodes)
        {
            $this->bbcode_init();
        }
        //Start MOD Convert quoted images to url     
        if( preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch ) )
        foreach ($qmatch[2] as $qmatchin) {
            $qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
            $this->message = str_replace($qmatchin, $qres, $this->message);
        }
        //End MOD Convert quoted images to url  
The picture filename extension recognition is also too restrictive, but that's out of scope for this topic.
The worst thing about censorship is ███████████

MandoaOrg
Registered User
Posts: 8
Joined: Sat Jan 29, 2011 10:22 pm

Re: phpBB Debug Notice | Cannot Modify Header Information

Post by MandoaOrg » Fri Feb 04, 2011 2:12 am

Thank you for the code help, but I already uninstalled the mod. Far too few pictures are posted on my forum (only one so far) for me to even need the mod in the first place.

I really appreciate your help and listening to me just ramble on all night. I'll keep a link to this topic in case I decide I need to reinstall this mod.

Locked

Return to “[3.0.x] Support Forum”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Sogou [Spider] and 88 guests