Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When trying to setup automated resets, kept receiving an error "The snapshot directory demo could not be created."
Did some digging and the offender was the call to file_prepare_directory in demo_admin_settings_validate [demo.admin.inc]. As the "private://" stream identifier was not passed, the file_prepare_directory function would fail as there would be no directory to find. Adding in the stream identifier so there was a full URI to parse fixed the issue.
Before Fix
function demo_admin_settings_validate($form, &$form_state) {
if (!file_prepare_directory($form_state['values']['demo_dump_path'], FILE_CREATE_DIRECTORY)) {
form_set_error('demo_dump_path', t('The snapshot directory %directory could not be created.', array('%directory' => $form_state['values']['demo_dump_path'])));
}
}
After Fix
function demo_admin_settings_validate($form, &$form_state) {
$fullpath = 'private://'.$form_state['values']['demo_dump_path'];
$dirprep = file_prepare_directory($fullpath, FILE_CREATE_DIRECTORY);
if (!$dirprep) {
form_set_error('demo_dump_path', t('The snapshot directory %directory could not be created.', array('%directory' => $form_state['values']['demo_dump_path'])));
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | addprivateprefix-1153206-2.patch | 859 bytes | ZeiP |
Comments
Comment #1
BarisW CreditAttribution: BarisW commentedI can confirm this. It only goes wrong when the default file system settings are set to public. I changed the code to this:
Comment #2
ZeiP CreditAttribution: ZeiP commentedI had the same problem, the change in #1 worked. Attached is a patch to fix this.
Comment #3
davidtrainer CreditAttribution: davidtrainer commentedI can confirm this patch works.
Comment #4
izmeez CreditAttribution: izmeez commentedI can also confirm this patch applies to 7.x-1.x-dev and works. It resolves #2072229: Demo settings should return ok message if path already exists that i shall close as a duplicate of this issue.
Thanks.
Comment #5
cecrs CreditAttribution: cecrs at roomify - online and open source reservation solutions commentedAlso can confirm the patch works.
Comment #6
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedLil documentation would improve the patch. Will add that while commit.
Comment #7
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #8
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commented