WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#39767 closed enhancement (invalid)

wp-admin failures upon line breaks in functions.php

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

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
12 months ago

  • Component changed from Customize to General
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

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.

Last edited 12 months ago by swissspidy (previous) (diff)
Note: See TracTickets for help on using tickets.