Drupal 7 File System Changes

On July 26 and 27 I participated on behalf of Acquia in a code sprint with a great group of other Drupal contributors at the Zivetch offices in Philadelphia. Aaron Winborn has already written a good summary of the event. I want to focus here on a big piece of the work that progressed but wasn't finished at the sprint: the File API Stream Wrapper Conversion patch (which weighs in at a big 230 kB and changes 54 files).
Jon Stacey and I reached an important milestone last night in that we got the conversion patch to pass all the core tests. This would be a great time to help review the code and manually test so we can get this ready to be committed soon!
For some background in why this matters, stream wrappers are an abstraction layer for PHP's file handling,. This allows me to reference a file attachment (for example) as a URI like "public://image.jpg" and PHP is able to load the correct class for the "public" scheme (which Drupal registered as an available stream wrapper) and then determine that the actual file location is on your local disk at "./sites/default/files/image.jpg".
One big benefit of this conversion is that we will now have a way to manage both public and private files for the same Drupal installation - and in fact every site will have both. This means that you can aggregate your CSS and JS files into the public directory but still use private files for file attachments.
Another, even more exciting, benefit is that it provides a consistent way to reference files or resources that might be remote as well as local. There already exist PHP stream wrapper implementations, for example, for referencing files in Amazon's S3. So your node could have a file attachment like "s3://mybucket/bigfile.mp3". Obviously, the http URL that you need to click to download this file has to be quite different from that for a local file, and the Drupal S3 stream wrapper class will implement $wrapper->getExternalUrl(); so that Drupal core can present the URL without needing to know any details about how S3 works.
A side note to this is that the sprint, and the ongoing work, is using git and github to allow simultaneous contributions from different people in the group to a single changed codebase. From that codebase we can generate patches to be applied to Drupal core. Jon Stacey's git clone of Mikkel Høgh's core mirror is where we are working. You can watch the commits there or get a copy of the code directly.
Related Content
AcquiaBlog

2010 has been an inflection point for the Acquia partner program. We are doing more business than ever with partners, including case studies with Palantir.net, Blink Reaction, and IBM Global Services.
Bryan House
It is that phase of my life! I'm just turning 30 in a month, working with Drupal for 7 years and just had my third Acquia anniversary a week ago. Time to look back and evaluate how things went, all the good and bad things; even better if the wisdom can be shared with others. This was part of my thinking when I submitted the session titled "Come for the software, stay for the community" for Drupalcon Copenhagen.
Gábor Hojtsy
It sounded like a really simple request: "Is it easy to add a search filter for 'My posts'?". In other words, add a search result facet for posts by the current (logged in) user through the Apache Solr Search Integration module APIs?
But then the wheels start turning - we want not just one blind link, but a real facet link that tells us how many results we'll get. Also, if we are filtering by 'My posts' then we probably have an equal use case for the opposite filter 'Posts not by me'. So we really need a facet block with two links and facets counts.
Peter Wolanin






