Skip to:
Content

bbPress.org

Attachments (2)

3078.diff (900 bytes) - added by milindmore22 8 years ago.
Added closing tags
3078-1.diff (10.0 KB) - added by milindmore22 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.

Download all attachments as: .zip

Change History (11)

@milindmore22
8 years ago

Added closing tags

#1 @milindmore22
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 @Otto42
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 @johnjamesjacoby
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 @netweb
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"

Previously #1850 / r3964

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

@milindmore22
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 @milindmore22
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 @netweb
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:

  1. 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.
  1. 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 @johnjamesjacoby
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!

#8 @johnjamesjacoby
8 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 6366:

General: Remove end-of-file ?> tags from extra templates.

These templates are theme drop-ins, and apparently were missed in previous clean-up efforts.

Props milindmore22. Fixes #3078.

#9 @netweb
8 years ago

In 6371:

General: Following [6366] use a single blank line for end-of-file extras templates.

See #3078.

Note: See TracTickets for help on using tickets.