how can white space enter a text file?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

This is one of the more bizarre things I've seen in a while.

We've a function called getListOfAllDatabaseTables that does about what
you'd expect. It lives in a file called getListOfAllDatabaseTables.php.
The file is included when the function needs to be called. The function
is called when users are adding in new information. Most of the time, if
a user fills in a form to (say for instance) create a new weblog post,
the user would hit "Submit" and then the action of adding that
information to the database would occur before the next page loads
(before any HTML is sent to the user's browser).

Suddenly, yesterday, when testing the development site, I started
getting errors when adding new material "Cannot send headers, output
already started in getListOfAllDatabaseTables.php". So I open up
getListOfAllDatabaseTables.php and, sure enough, there is a single white
space that has suddenly been added to the end of the file, outside of
the closing ?> tag. I delete the white space and thus fix the problem.

I want to know who is to blame for this so I look at the files history
in Subversion. Turns out, no one has edited this file since it was first
checked in back in November.

The whole site is under Subversion. We use which has a
nice auto-deploy feature. No one has FTP access to the site. No one has
SSH access to the site, except root. Really, the only way a white space
could appear in that file is if someone ssh to the server, logged in as
root, opened that file, added a white space, and then closed it without
making any other change.

Which does not seem likely. There are only two people with the root
password to the server, myself, and one other programmer. Neither of us
had any reason to touch that file, nor do either of us have any memory
of touching that file yesterday.

Any other way a white space can suddenly appear at the end of a file?

Re: how can white space enter a text file?

On Fri, 06 Jun 2008 00:02:28 +0200, Lawrence Krubner  

Quoted text here. Click to load it

That's no PHP question, but at least some process has had to do something  
to the file, or the servers configuration. Usually, in these cases, it WAS  
a user, just not someone willing to own up to it. I'd check the time the  
file was last changed (which you probably can't get as you changed it  
back), and compare them to other logs. Then again, it could just be a  
simple configuration change on the server, making the problem only visible  
now (output buffering and the like).

The answer to the question 'what could do that?' is actually: almost  
anything. There is no way for use to tell you without full logs & root  
access to your server, and even then it's probably untracable.
Rik Wasmus
...spamrun finished

Re: how can white space enter a text file?

Rik Wasmus wrote:
Quoted text here. Click to load it

Like the time all my carefully spaced output blocks - space padded to
get everything to line up - suddenly blew up.

The 'Hairy Programmer' eventually admitted that he had run a 'replace
every three spaces by tabs' on the source code to make it small enough
as the PDP-11 was running out of disk space..

Re: how can white space enter a text file?

Quoted text here. Click to load it
Quoted text here. Click to load it

Conjecturing about what caused this is futile - it could be lots of
different things - and there's nothing substantial in your post to
base a hypothesis on.

But you can prevent the same thing from recurring **regardles of the
cause** by employing a style requirement that the closing '?>' is
omitted from include files.


Site Timeline