The file module uses bit-wise operators to query the {file_managed}.status. This is not, and will not be, supported by Drizzle.

Moreover, it doesn't even seem necessary, given that the only documented usage for this column is FILE_STATUS_PERMANENT vs. 0, which means temporary.

Could we simply act that this column only purpose is to store the permanent/temporary flag, and get rid of the bit-wise operators (like the one below)?

  $result = db_query('SELECT fid FROM {file_managed} WHERE status & :permanent1 <> :permanent2 AND timestamp < :timestamp', array(
    ':permanent1' => FILE_STATUS_PERMANENT,
    ':permanent2' => FILE_STATUS_PERMANENT,
    ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
  ));
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Active » Needs review
FileSize
3.1 KB

Yes. And it's definitely not ANSI. Note that this patch does not change the stored values in the database or anything. It just gets rid of needless bitwise ops.

moshe weitzman’s picture

Status: Needs review » Needs work

change description for this column in system.install. Might be more docs that need changing as well.

quicksketch’s picture

This sounds like a great idea to me. Most people (self included) thought it was always just a binary 1 or 0 already.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
8.7 KB

Here. Changed the description of the table, changed file_space_used(), refactor the test (it was using three different test methods - ie. three different setUp() / tearDown()) for something that is nothing more then a tiny unit test).

Save the polar bears :)

andypost’s picture

Status: Needs review » Needs work

Tested, this really fixes issue.

As I understand $status should be a kind of filter so maybe better use array and SQL IN()

The possible case - count a space used by remote files. OTOH the only FILE_STATUS_PERMANENT defined in core.

Current patch kills ability to use contrib-defined statuses so this leads to API change fo function file_space_used()

EDIT: As pointed in #3 schema description should be changed too. And documented.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
9.04 KB

Changes $status of file_space_used() to be an array, per andypost. There is a smallish API change here anyway, so we better make it clean.

Damien Tournoud’s picture

Forgot to fix the docblock (per andypost, again, thanks!).

Damien Tournoud’s picture

And fix grammar :)

Damien Tournoud’s picture

Ok, actually, let's simplify things here, and admit that there are only two statuses, 0 and FILE_STATUS_PERMANENT.

This new patch:

- simplifies the test
- simplifies file_space_used() signature
- fixes the schema to use a tinyint, as we do for all other status columns

andypost’s picture

Status: Needs review » Needs work

+1 RTBC, good optimization and simplified code.

andypost’s picture

Status: Needs work » Reviewed & tested by the community

I mean RTBC...

chx’s picture

Yay. I wonder why this is normal... but I let it be normal for now.

Damien Tournoud’s picture

Rerolled.

Dries’s picture

Project: Drupal core » HEAD to HEAD
Version: 7.x-dev »
Component: file system » Code
Status: Reviewed & tested by the community » Needs work

Committed to CVS HEAD in favor of having Drizzle support the next x years.

Moving this to HEAD to HEAD project.

chx’s picture

Project: HEAD to HEAD » Drupal core
Version: » 7.x-dev
Component: Code » file system
Status: Needs work » Fixed

No, core has a history and core work is done. HEAD2HEAD can file a separate issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.