Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#39767 closed enhancement (invalid)

wp-admin failures upon line breaks in functions.php

Reported by: gregvie Owned by:
Priority: normal Milestone:
Component: General Version: 4.7.2
Severity: normal Keywords:
Cc: Focuses:

Description

Building a child theme I came accross something I'd consider a bug:

In wp-admin the media editor for image resizing & cropping didn't load preview images and failed to edit uploaded images. I did some research on the web and found a forum posting (on some site) pointing out an issue that occures when there are line breaks or spaces between closing and opening PHP tags ("...?> \n <?php...") in functions.php or any required / included php-files (in my case a file called classes.php which is required in functions.php ending with two line breaks after the final closing ?>). Only after eliminating those line breaks / spaces my child theme's media editor (for resizing & cropping) worked again.

It would be some enhancement fixing this bug and saving developers who are not aware of that issue lots and lots of time researching and finding the solution.

Change History (1)

#1 @swissspidy
10 years ago

  • Component CustomizeGeneral
  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

Hey there,

Welcome to WordPress Trac!

Whitespace after closing PHP tags causing all sorts of weirdness is not a bug in WordPress, but simply how PHP works. From the PHP website:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.

If your theme or plugin has line breaks after ?>, you need to inform the developer to fix this (ideally by omitting the closing tag at the end of the file). Again, since this is how PHP is designed, WordPress cannot account for this.

Version 0, edited 10 years ago by swissspidy (next)
Note: See TracTickets for help on using tickets.