Commit fc412e8f authored by quicksketch's avatar quicksketch

#846598: Code cleanup, moving devel_shutdown turn-off to top of filefield_js().

parent b086fcaa
......@@ -355,7 +355,7 @@ function filefield_widget_upload_validators($field) {
// associate the field to the file on validation.
'filefield_validate_associate_field' => array($field),
'filefield_validate_size' => array($max_filesize),
// Override core since it excludes uid 1 on the extension check.
// Override core since it excludes uid 1 on the extension check.
// Filefield only excuses uid 1 of quota requirements.
'filefield_validate_extensions' => array($field['widget']['file_extensions']),
);
......@@ -525,6 +525,10 @@ function filefield_view_access($field_name) {
function filefield_js($type_name, $field_name, $delta) {
$field = content_fields($field_name, $type_name);
// Immediately disable devel shutdown functions so that it doesn't botch our
// JSON output.
$GLOBALS['devel_shutdown'] = FALSE;
if (empty($field) || empty($_POST['form_build_id'])) {
// Invalid request.
drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
......@@ -600,7 +604,6 @@ function filefield_js($type_name, $field_name, $delta) {
// For some reason, file uploads don't like drupal_json() with its manual
// setting of the text/javascript HTTP header. So use this one instead.
$GLOBALS['devel_shutdown'] = FALSE;
print drupal_to_js(array('status' => TRUE, 'data' => $output));
exit;
}
......@@ -878,7 +881,7 @@ function filefield_validate_is_image(&$file) {
/**
* An #upload_validators callback. Add the field to the file object.
*
* This validation function adds the field to the file object for later
* This validation function adds the field to the file object for later
* use in field aware modules implementing hook_file. It's not truly a
* validation at all, rather a convient way to add properties to the uploaded
* file.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment