#3078 closed defect (bug) (fixed)
Remove EOF closing ?> tags
Reported by: | ellipszist | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.6 | Priority: | lowest |
Severity: | trivial | Version: | trunk |
Component: | General | Keywords: | good-first-bug has-patch commit |
Cc: |
Description
page-forum-statistics.php Line 58
https://bbpress.trac.wordpress.org/browser/trunk/src/templates/default/extras/page-forum-statistics.php#L58
single-reply-move.php Line 32
https://bbpress.trac.wordpress.org/browser/trunk/src/templates/default/extras/single-reply-move.php#L32
Attachments (2)
Change History (11)
#1
@
8 years ago
- Keywords has-patch added
- Priority changed from normal to lowest
- Severity changed from normal to trivial
Although It's unnecessary but all other templates have a closing tag at the end, submitted a patch to cover both files.
#2
@
8 years ago
Actually, end of PHP files should not have closing tags, because of spaces after then potentially creating header already sent errors.
#3
@
8 years ago
Otto is correct. The correct thing to do here is remove all of the very last closing PHP tags, preferably with an empty line at the end to prevent Subversion from showing the "No new line at end of file" output.
#4
@
8 years ago
- Keywords good-first-bug needs-patch added; has-patch removed
- Summary changed from Add missing ?> tag to Remove EOF closing ?> tags
I've renamed the ticket "Remove EOF closing ?> tags"
A quick search reveals he following "extras" templates all include closing EOF ?>
PHP tags that we should remove:
src/templates/default/extras/archive-forum.php src/templates/default/extras/archive-forum.php src/templates/default/extras/page-create-topic.php src/templates/default/extras/page-front-forums.php src/templates/default/extras/page-front-topics.php src/templates/default/extras/page-topic-tags.php src/templates/default/extras/page-user-login.php src/templates/default/extras/page-user-lost-pass.php src/templates/default/extras/page-user-register.php src/templates/default/extras/page-user-register.php src/templates/default/extras/single-forum-edit.php src/templates/default/extras/single-forum.php src/templates/default/extras/single-reply-edit.php src/templates/default/extras/single-reply.php src/templates/default/extras/single-topic-edit.php src/templates/default/extras/single-topic-merge.php src/templates/default/extras/single-topic-split.php src/templates/default/extras/single-topic.php src/templates/default/extras/single-user-edit.php src/templates/default/extras/single-user.php src/templates/default/extras/single-view.php src/templates/default/extras/taxonomy-topic-tag-edit.php src/templates/default/extras/taxonomy-topic-tag.php
@
8 years ago
Patch will remove all closing tags from extra templates added new line to prevent Subversion from showing the "No new line at end of file" output.
#5
@
8 years ago
- Keywords has-patch added; needs-patch removed
Submitted patch with removing all closing tag listed.
but PHP is an embeddable scripting language designed to allow you to embed logic in the form of PHP scripting into content, which is typically HTML. In that context, the opening and closing tags make sense, such as in WordPress' theme template files and all template files are having closing tags.
eg: https://core.trac.wordpress.org/browser/trunk/src/wp-content/themes/twentyfifteen/single.php
any thoughts on this?
#6
@
8 years ago
I've just read #WP12307 / core:changeset:19712, see also #WP23505 core:changeset:28678 #WP30534 core:changeset:34887
And my take away summaries from that are:
- It is now (previously before the above WP ticket it was not) WordPress coding standard to exclude closing PHP tags on files that are not expected to be edited. That includes a theme's functions.php and wp-config.php.
- Omitting from the r19712 commit is any changes to themes, i.e
wp-content/themes/*
, as such at the time, and still till today twenty ten and eleven still contain closing tags
The PHP coding standards state:
"Omitting the closing PHP tag at the end of a file is preferred. If you use the tag, make sure you remove trailing whitespace."
And from the PHP manual: https://secure.php.net/manual/en/language.basic-syntax.phptags.php
"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."
I've created a new core ticket #WP40039 to discuss the removal of closing PHP tags from the bundled themes
#7
@
8 years ago
- Keywords commit added
Seems a-OK to commit -1.diff.
Should double check that it covers all of our template parts.
Thanks @milindmore22 for helping!
Added closing tags