Hello,
Thanks for this module. I like it :P ... I have a question about usage though. Say you have an asynchronous upload using the httprl_queue_background_callback() function. How would you detect errors that occur in that upload process? Errors that could include timeout, memory allocation, unable to write file? I've got my code in try / catch but sometimes it will just stop processing the files to upload and I don't see any reason why. An example of my code is below, I think I have as much error checking as I can. I've looked through your issues and examples of code usage and didn't see anything related to this. Your help is appreciated. Thank you.
<?php
if (!httprl_is_background_callback_capable()) {
return FALSE;
}
// Example of background process
$callback_options = array(
array(
'function' => 'example_upload_asynchronous',
'options' => array(
'timeout' => 1200,
'global_timeout' => 1200,
),
),
$file_attributes,
);
// Queue up the request.
httprl_queue_background_callback($callback_options);
// Execute request.
$response = httprl_send_request();
if ($response === FALSE) {
return FALSE;
}
/**
* Process the folder contents in the background.
* @param $file_attributes
*/
function example_upload_asynchronous($file_attributes) {
try {
$error_uploading = FALSE;
$dir = new RecursiveDirectoryIterator($file_attributes['full_path'], FilesystemIterator::SKIP_DOTS);
// Flatten the recursive iterator, folders come before their files
$it = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
// Basic loop displaying different messages based on file or folder
foreach ($it as $fileinfo) {
if (!$fileinfo->isDir()) {
$full_path = $fileinfo->getPathname();
if (strpos($full_path, 'Thumbs.db') !== FALSE || strpos($full_path, '.DS_Store') !== FALSE) {
continue;
}
$path = str_replace($temp_path, '', $full_path);
$bytes_written = file_put_contents($filename, $data);
if ($bytes_written == NULL || $bytes_written == FALSE) {
$error_uploading = TRUE;
break;
}
}
}
}
catch (Exception $e) {
error_log("BAD UPLOAD EXCEPTION");
}
}
?>