0

I realise this has been asked many times, and the answer is usually some whitespace before or after the PHP tags however I have checked all my files and not found any evidence of this.

I am using Wordpress and have debug mode switched on. My site works on one domain however I recently moved it to a new server (still running apache on linux - I did move from shared to a VPS) and gave it a new domain. All I have changed is the following in wp-config.php:

define('DB_NAME', 'new db name');
define('DB_USER', 'new db user');
define('DB_PASSWORD', 'new db password');
define('WP_HOME','new url');
define('WP_SITEURL','new url');

However I am now unable to log in, I have narrowed this down to the fact cookies are not being set. If I visit wp-login.php I get the following errors:

Warning: Cannot modify header information - headers already sent by (output started at /home/rcnhca/public_html/wp-includes/load.php:270) in /home/rcnhca/public_html/wp-login.php on line 368

Warning: Cannot modify header information - headers already sent by (output started at /home/rcnhca/public_html/wp-includes/load.php:270) in /home/rcnhca/public_html/wp-login.php on line 380

Note: Both wp-login.php and load.php are core Wordpress files.

line 368 of wp-login.php is:

header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));

and line 380:

setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);

line 270 of load.php is:

ini_set( 'display_errors', 1 );

However I also recieve the following warning:

Warning: ini_set() has been disabled for security reasons in /home/rcnhca/public_html/wp-includes/load.php on line 270

Which I believe is because I have the Suhosin PHP patch installed but I am not definite on this. I do not want to run a more vulnerable version of PHP.

I can't work out why this error is occurring, there is no trailing whitespace in any of my theme's PHP files.

Note: I also realise I can use output buffering to solve this, however I want to understand where the problem is occurring instead of applying a one-size fits all patch which will affect my debugging capabilities.

George Reith
  • 13,132
  • 18
  • 79
  • 148
  • I see you're denying whitespace causing this, I guess you've already checked if there's any whitespace above the DOCTYPE in your HTML? – kjetilh Feb 19 '13 at 15:38
  • @kjetih Yep, no whitespace there. – George Reith Feb 19 '13 at 15:39
  • But the `ini_set()` warning is printed above the the DOCTYPE no? That would count as whitespace/any output and will trigger the "cannot modify headers" messages. – kjetilh Feb 19 '13 at 15:40
  • @kjetilh ignore my previous comment it is above DOCTYPE - my source inspector repositioned it. – George Reith Feb 19 '13 at 15:43
  • Right, glad you figured it out – kjetilh Feb 19 '13 at 15:45
  • @GeorgeReith Hm if you've moved from Shared to a VPS I guess you should be able to have some more freedom when it comes to configuring your server, eg. allowing ini_set :) it's gonna get pretty tedious debugging without any error output or logs, I reckon. – kjetilh Feb 19 '13 at 15:49
  • @kjetilh Thanks, I just tested by suppressing `ini_set()` errors and running in debug mode and no modify headers warning. Sadly I am still unable to log in and cookies are still not being set :( – George Reith Feb 19 '13 at 15:49
  • @kjetilh Do you want to make an answer so I can accept it? – George Reith Feb 19 '13 at 15:53
  • @GeorgeReith this is a duplicate/localized question and as such should be closed as one. – kittycat Feb 19 '13 at 15:53
  • @GeorgeReith you really need to read the link I posted above. ANY output intentional or unintentional output before headers are sent will cause that error. So your case is not at all unique. – kittycat Feb 19 '13 at 15:58
  • @crypticツ It is easy to umbrella anything when you use the word ANY. However I did find a similar section about **Preceding error messages** which is why I removed the comment. So accept that this can be closed. – George Reith Feb 19 '13 at 16:07

1 Answers1

0

The ini_set() warning causes the headers to get sent which in turn triggers the "cannot modify headers" messages.

kjetilh
  • 4,821
  • 2
  • 18
  • 24