[wp-trac] [WordPress Trac] #21337: COMMENTS_TEMPLATE: cannot define a constant twice in PHP

WordPress Trac wp-trac at lists.automattic.com
Sat Jul 21 16:26:46 UTC 2012


#21337: COMMENTS_TEMPLATE: cannot define a constant twice in PHP
--------------------------+-----------------------------
 Reporter:  kitchin       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  3.4.1
 Severity:  trivial       |   Keywords:
--------------------------+-----------------------------
 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:
 1. Theme calls comments_template()
 2. 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

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21337>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list