API Stream Wrappers – Week 3

This week has been significantly more productive that the last two. I’ve broken my status update into the different efforts that are currently ongoing.


The core of the WP stream wrapper registry has been implemented. This registry keeps track of the scheme and implementation class of each registered wrapper. The WP registry provides supplemental functionality that PHP’s native registry does not provide. An example of the new functionality added is the ability to ask “what wrapper class is responsible for handling this URI or scheme?” The File API will depend on this kind of information to work around current limitations (i.e. bugs) in PHP’s stream wrapper support. Further work on the registry is blocked until WP_Stream_Wrapper_Interface is completed.


This interface will lay the ground work for what all WordPress wrappers must implement in order to be registered.


Most stream wrapper functionality will work out of the box. For example, PHP will know what to do if you call fread() with a stream URI. Unfortunately, a handful of standard PHP functions have bugs with stream wrappers and do not work as intended. These limitations are easily overcome by providing replacement functions. These functions will become a part of a File API that is WordPress specific. Next week I will detail how this API and WP_Filesystem_* relate.

Code repositories

I setup GitHub mirrors of the Subversion code repositories incase I need to leverage Git’s superior merge capabilities.
GitHub: wp-stream-wrappers
GitHub: wp-stream-wrapper-test