Opened 12 years ago
Closed 12 years ago
#21337 closed defect (bug) (fixed)
COMMENTS_TEMPLATE: cannot define a constant twice in PHP
Reported by: | kitchin | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | trivial | Version: | 3.4.1 |
Component: | Comments | Keywords: | commit |
Focuses: | Cc: |
Description
A minor PHP issue in wp-includes/comment-template.php in comments_template() :
if ( !defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE) define('COMMENTS_TEMPLATE', true);
PHP does not allow constants to be re-defined, so the clause "!COMMENTS_TEMPLATE" can have no effect other than raise a warning.
The patch removes the clause.
Normally this warning would happen if comments_template() is called twice by the theme, but the subsequent require() statement would raise an error anyway.
In one edge case it might not raise an error:
- Theme calls comments_template()
- Theme calls comments_template() again with a different parameter or after a different filter is in effect.
So the patch loses a warning in that case.
I grepped the codebase and did not find any similar clause before a define().
The conditional code around the define() was added in this changeset: http://core.trac.wordpress.org/changeset/10953
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
Agreed, the code decides to define a constant based on it's value, which makes 0 sense.