﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 37699,"Death to Globals Episode #1: A Registry, A Pattern",wonderboymusic,,"Storing application state in globals is ... bad. Using global state to store objects is ... bad. Using globals to avoid writing classes is ... bad. Using globals to pass data between functions is ... bad. Training people to assume that globals will always be set to the value they expect is ... bad. Globals are an artifact of a #dark-er time, think PHP 3. It would be nice if we didn't use globals. We have a backward compatibility strait jacket, but that shouldn't stop us from exploring ways to eradicate them. We can start with class instances, because variables hold a reference to the actual instance when set. We can also start with a simple registry that allows us to create a data that can get / set globals for us (or not!). We can also add a few static methods onto `WP` to hide all of this away. Attached is a POC that removes (every instance of?) `$wpdb` as a global, and instead uses the registry. Take a glance. All unit tests (seem to) pass. This will evolve before it becomes a reality, but I encourage you to unleash your imagination unto a world where WordPress' codecase resembles something globallessly lovely. ",enhancement,new,normal,Awaiting Review,General,,normal,,,,