- - - - -

CRLF or LF only for ASO PHP?


  • Please log in to reply
10 replies to this topic

#1 Peter_Ingersoll

Peter_Ingersoll

    Tiny Orange

  • Members
  • Pip
  • 4 posts

Posted 03 March 2012 - 07:33 PM

I've run into a problem where my WordPress site migrated from another host provider doesn't work on ASO. The problem appears to be the required Unix LF at the end of lines and the problems caused by Windows CRLF at the end of lines. I've not encountered this on any other hosts I've used.

It seems that any text file I upload could potentially break my sites. Is this something specific to ASO, or am I missing something?

- Peter

#2 IBBoard

IBBoard

    Massive Orange

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 4,729 posts

Posted 04 March 2012 - 08:47 AM

Bash scripts are picky about which line endings they user, but PHP scripts shouldn't care. I only use Linux (and so only ever end up with LF at the end of lines), but my wife uses Windows and I've never had anything break just because she edited the file.

What errors are you actually getting, and in which files are they occurring?
The more information you provide, the better answer the community can give.

*** Sign up at ASO  with a 15% discount (coupon: saveme15%) or $5 discount (coupon: saveme$5) ***
(Valid on shared hosting and VPS)

#3 NyteOwl

NyteOwl

    36 Bits forever!

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 1,902 posts

Posted 04 March 2012 - 12:44 PM

Uncommon problem. I often edit files for my site in Linux, Windows, Solaris, etc and have no problems. PHP applications such as Wordpress commonly use the "newline" (\n) character to terminate a line which is basically the equivalent of a CR/LF pair; Though if this is in an article it should be parsed as written.
Obsolescence is just a lack of imagination.

Sign up at ASO and enjoy friendly, quality hosting services. Use coupon code no2512 and save 15% or coupon code 2152on and take $5 off. Valid on both Shared Hosting and VPS plans.

#4 Peter_Ingersoll

Peter_Ingersoll

    Tiny Orange

  • Members
  • Pip
  • 4 posts

Posted 04 March 2012 - 01:55 PM

Thanks for reading and responding.

This all started after I uploaded WordPress files that are successfully used on another host that I'm moving my site from. I was getting the following error on WordPress pages "Cannot modify header information - headers already sent by (output started at [file] ) in [my account]/public_html/wp-includes/pluggable.php on line 866" where [file] is various plugins and [my account] is my server directory. I discovered that this error occurs in some cases when there is extra white space at the beginning or end of PHP files and when output buffering is off (as it usually is).

I submitted a ticket to ASO and was told that my files all have CRLF but should just have LF. The support person ran a script against all my files to change them. These files were all originally uploaded by me from my PC.

I also ran into a problem where themes were getting fouled up in the WP admin pages. In trying to trouble shoot that problem, I was trying to determine if this CRLF thing could be part of the problem.

I've asked ASO for clarification if LF is required in the uploaded file rather than CRLF. I also asked if there was a specific FileZilla setting I should have in place to make this happen automatically between my PC and the ASO Unix server. I have received no response (actually, it was escalated on Friday night to a system manager who, I unhappily found out on Saturday morning, don't come in until Monday).

I've worked with a number of hosting companies previously and I've never run into this problem using all the same software (FileZilla and Notepad++), the same settings, and even the same files.

So my question remains: is the LF/CRLF problem I'm running into typical with ASO, and is there an easy way to remedy? My big concern going forward is that if I forget some conversion (that I've never previously had to do), am I at risk of breaking my site?

Thanks for any insights.

- Peter

#5 IBBoard

IBBoard

    Massive Orange

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 4,729 posts

Posted 04 March 2012 - 02:33 PM

The error you had is self explanatory (although occasionally hard to spot). Anything outside "<?php" and "?>" in a .php file is printed as-is. That includes white space. If you print something before you send a header (e.g. a cookie) then you'll get the error you got. If you looked at line 866 of ~/public_html/wp-includes/pluggable.php then you'd probably find that it had a blank line. Most likely it was right at the very end of the file. It happens, and if it happens in an include/library file then it'll mess up your whole script like that.

No matter what host you're with, rogue new lines can be a problem (I've seen it on the forums of all of the major web scripts that people edit and modify - phpBB, Wordpress, ZenCart, OpenCart, and the rest). It is possible that the fact it was a CRLF (which is another way of saying \r\n ;) ) rather than just an LF caused a problem in this one instance, but if it is then it is new to me and my ~12 years of PHP experience. The only thing I can think of is that you had a CRLF in just the wrong place, but that it was happy with them everywhere else.
The more information you provide, the better answer the community can give.

*** Sign up at ASO  with a 15% discount (coupon: saveme15%) or $5 discount (coupon: saveme$5) ***
(Valid on shared hosting and VPS)

#6 Peter_Ingersoll

Peter_Ingersoll

    Tiny Orange

  • Members
  • Pip
  • 4 posts

Posted 04 March 2012 - 03:33 PM

Thanks much, IBBoard,

I was definitely aware of the whitespace / rogue new line issue, but I couldn't see it. ASO support told me that all the CRs had to be stripped and ran a script to do so. It seemed to help one problem, but then my themes management issue cropped up. That's really the current issue, but I need to have a definitive answer regarding the LF issue so I can eliminate it as a variable.

I'm resigned to reinstall WP and everything else. My fear is that, even with SFTP transfer set to "binary" as suggested, my Windows PC will change a file to a CRLF and I'll be back with the same problem.

As you state, I've never encountered this before either - so all I'm left to do is start over and hope I never see this issue again.

Yay, and fingers crossed.

- Peter

#7 billzo

billzo

    Very Large Orange

  • Members
  • PipPipPipPipPip
  • 587 posts

Posted 04 March 2012 - 03:53 PM

View PostPeter_Ingersoll, on 04 March 2012 - 03:33 PM, said:

I'm resigned to reinstall WP and everything else. My fear is that, even with SFTP transfer set to "binary" as suggested, my Windows PC will change a file to a CRLF and I'll be back with the same problem.

Upload a zip archive and unzip it on the server.

I've written PHP code exclusively on a Windows machine with a development Apache/PHP server installed and have never had a problem like that with Wordpress or anything else.   I also use Filezilla to upload files.  No problems there either.

A quick search of Yahoo reveals a lot of people getting that "headers already sent" error around line 865 or 866 of pluggable.php.  You didn't put any additional white space in config.php when you were editing it for the new server?  No white space in your theme's functions.php file?  There seem to be a lot of places where additional white space can trigger an error with the output indicating that particular line number in pluggable.php due to its use in overriding Wordpress functions.  

It could be with a plugin you are using, too.
Posted Image
Click here to sign up with A Small Orange today!  

ASO servers are fast and they offer excellent support for a great price.  ASO is the BEST host around!

I have been with ASO since June 2007 and recommend this host highly.  ASO has only gotten better over time.  There is no better testimonial about the quality of service of a webhost than a long-term customer like me.  Don't make a frustrating and time-consuming mistake of signing up with any other webhost.  ASO is what you need.

Whether you are hosting a small hobby site like a Wordpress blog, a serious business website, or need a Dedicated Server, VPS or Cloud hosting, ASO has superior quality professional-level hosting packages for you.


View A Small Orange Hosting Plans


$$$ Coupon codes to save you money $$$

Code to save $5: saveme$5
Code to save 15%: saveme15%


Enter the coupon codes when ordering to get your discount. Save $5 or 15% off your initial order.

Sign up with A Small Orange today!  You will be glad you did.
Posted Image

#8 Peter_Ingersoll

Peter_Ingersoll

    Tiny Orange

  • Members
  • Pip
  • 4 posts

Posted 06 March 2012 - 06:22 PM

The bottom line is this: it shouldn't matter and this should be a non-issue. The problem that I originally ran into set me and tech services on what probably has been a bit of a wild goose chase due to a WP/PHP error that is often associated with white space at the beginning or end of PHP files. While my files did not have this white space, it did call attention to the CRLF / LF topic and off we went. Unfortunately, it became too much of a point of focus. There's really nothing different about ASO servers versus any other server I've used. Default upload/download of PHP files should work without a hitch. I've reloaded everything just to start clean and will proceed as usual. I don't anticipate additional problems.

Quite frankly, if this was a real problem the ASO wouldn't have nearly the number of happy customers they seem to have.

- Peter

#9 billzo

billzo

    Very Large Orange

  • Members
  • PipPipPipPipPip
  • 587 posts

Posted 07 March 2012 - 08:07 AM

I've never had any trouble with any Wordpress code or themes I've written with ASO.  I don't know why you had your troubles but I'm glad you got them resolved by installing fresh.

Good luck going forward. :)
Posted Image
Click here to sign up with A Small Orange today!  

ASO servers are fast and they offer excellent support for a great price.  ASO is the BEST host around!

I have been with ASO since June 2007 and recommend this host highly.  ASO has only gotten better over time.  There is no better testimonial about the quality of service of a webhost than a long-term customer like me.  Don't make a frustrating and time-consuming mistake of signing up with any other webhost.  ASO is what you need.

Whether you are hosting a small hobby site like a Wordpress blog, a serious business website, or need a Dedicated Server, VPS or Cloud hosting, ASO has superior quality professional-level hosting packages for you.


View A Small Orange Hosting Plans


$$$ Coupon codes to save you money $$$

Code to save $5: saveme$5
Code to save 15%: saveme15%


Enter the coupon codes when ordering to get your discount. Save $5 or 15% off your initial order.

Sign up with A Small Orange today!  You will be glad you did.
Posted Image

#10 Chris Black

Chris Black

    Small Orange

  • Members
  • PipPip
  • 12 posts

Posted 12 March 2012 - 05:15 PM

I've not had any issues uploading files edited on a Windows machine to a WordPress install here either.

If you have shell access you could always log in and run dos2unix on the file if the issue is the Windows encoding.

#11 ASOAyron

ASOAyron

    ASO Ninja

  • Support
  • 44 posts

Posted 17 March 2013 - 02:59 AM

View PostChris Black, on 12 March 2012 - 05:15 PM, said:

If you have shell access you could always log in and run dos2unix on the file if the issue is the Windows encoding.

Also, since dos2unix doesn't have an option to work recursively, you can do this instead to process all files in a folder recursively:

find /path/to/folder -type f | xargs dos2unix

Replace /path/to/folder with, you know, the path to the folder. :P
Ayron
Your Friendly Neighborhood Technical Support Ninja Posted Image

Disclaimer: While I do indeed work for A Small Orange, my posts here do not necessarily represent the views of my employer. As such, my posts here are not official support from A Small Orange. If you need official support, please go to the official support portal.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users