Breaking this off from #1191236: Correct file_copy, file_move, file_save_data, and drupal_realpath to match documentation and their unmanaged counterparts.

The documentation for the $destination parameter to file_copy() say, in part:

If this value is omitted, Drupal's default files scheme will be used, usually "public://".

However, this claim is untrue. Omitting the $destination parameter will actually result in the following code being executed:

    watchdog('file', 'File %file (%realpath) could not be copied, because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => drupal_realpath($source->uri), '%destination' => $destination));
    drupal_set_message(t('The specified file %file could not be copied, because the destination is invalid. More information is available in the system log.', array('%file' => $source->uri)), 'error');
    return FALSE;

Comments

pillarsdotnet’s picture

Status: Active » Needs review
StatusFileSize
new1.42 KB

The following patch corrects the code to match the docs.

Status: Needs review » Needs work

The last submitted patch, file_copy-make_code_match_docs-1192446-1.patch, failed testing.

pillarsdotnet’s picture

Status: Needs work » Needs review
pillarsdotnet’s picture

Title: Fix code of file_copy() to match docs. » Make code of file_copy() match docs.
Issue tags: +Needs backport to D7
pillarsdotnet’s picture

Issue tags: +API clean-up
pillarsdotnet’s picture

Status: Needs review » Closed (duplicate)