[wp-trac] [WordPress Trac] #37699: Death to Globals Episode #1: A Registry, A Pattern

WordPress Trac noreply at wordpress.org
Thu Aug 18 07:50:13 UTC 2016


#37699: Death to Globals Episode #1: A Registry, A Pattern
----------------------------+------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  4.7
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------

Comment (by dnaber-de):

 Interesting ticket and I agree with the explanation of @schlessera.
 However these considerations touches another aspect of WordPress' code
 design.

   Training people to assume that globals will always be set to the value
 they expect is ... bad.

 That can't be solved by just providing a Repository or implementing
 dependency injection when using mutable objects. In case of `$wpdb` all
 relevant attributes are public writable so you can't trust its state. I
 know, that can't be solved due to backward compatibility but it should be
 considered for ongoing development of new components. Otherwise the issue
 of an unreliable system state can't be solved IMO.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37699#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list