file_set_status() was added in Drupal 6 as a way of changing a temporary file to a permanent file back before file_save() was added. In it's current implementation the function has an annoying overlap with the functionality provided by file_save().

All file_set_status() does is changes the status field of a row in the {files} table and call hook_file_status. But there's nothing to stop you from assigning the file's status and then calling file_save() which would circumvent the call to hook_file_status.

It also diverges from the patterns established else where in core. We don't have a node_set_status() function, you just do a $node->status = 1; node_save($node); and I think the same should be true for files.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drewish’s picture

FileSize
9.63 KB

re-rolled

Dries’s picture

Status: Needs review » Needs work

Makes sense, and the patch works as advertised. I committed this to CVS HEAD. Please mark as 'fixed' once the module upgrade guide has been updated. Thanks drewish.

drewish’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

CitizenKane’s picture

Status: Closed (fixed) » Fixed
drewish’s picture

any reason you bumped this back to fixed?

CitizenKane’s picture

Status: Fixed » Closed (fixed)

Accidental click on my part. Sorry about that.

drewish’s picture

Status: Closed (fixed) » Reviewed & tested by the community
FileSize
916 bytes

Realized we forgot to remove the hook from the docs.

Status: Reviewed & tested by the community » Needs work

The last submitted patch failed testing.

drewish’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
908 bytes

whoops, had the prefix in that patch.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks! :)

Status: Fixed » Closed (fixed)

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