mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°2945 - Fix fatal error when adding empty attachment
alert when empty attachment is detected
This commit is contained in:
@@ -7706,10 +7706,17 @@ class AttributeBlob extends AttributeDefinition
|
|||||||
// (temporary tables created on disk)
|
// (temporary tables created on disk)
|
||||||
// We will have to remove the blobs from the list of attributes when doing the select
|
// We will have to remove the blobs from the list of attributes when doing the select
|
||||||
// then the use of Get() should finalize the load
|
// then the use of Get() should finalize the load
|
||||||
if ($value instanceOf ormDocument && !$value->IsEmpty())
|
if ($value instanceOf ormDocument)
|
||||||
{
|
{
|
||||||
$aValues = array();
|
$aValues = array();
|
||||||
$aValues[$this->GetCode().'_data'] = $value->GetData();
|
if (!$value->IsEmpty())
|
||||||
|
{
|
||||||
|
$aValues[$this->GetCode().'_data'] = $value->GetData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$aValues[$this->GetCode().'_data'] = '';
|
||||||
|
}
|
||||||
$aValues[$this->GetCode().'_mimetype'] = $value->GetMimeType();
|
$aValues[$this->GetCode().'_mimetype'] = $value->GetMimeType();
|
||||||
$aValues[$this->GetCode().'_filename'] = $value->GetFileName();
|
$aValues[$this->GetCode().'_filename'] = $value->GetFileName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ try
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$oDoc = utils::ReadPostedDocument('file');
|
$oDoc = utils::ReadPostedDocument('file');
|
||||||
|
if ($oDoc->IsEmpty())
|
||||||
|
{
|
||||||
|
throw new FileUploadException(Dict::S('Attachments:Error:UploadedFileEmpty'));
|
||||||
|
}
|
||||||
/** @var Attachment $oAttachment */
|
/** @var Attachment $oAttachment */
|
||||||
$oAttachment = MetaModel::NewObject('Attachment');
|
$oAttachment = MetaModel::NewObject('Attachment');
|
||||||
$oAttachment->Set('expire', time() + MetaModel::GetConfig()->Get('draft_attachments_lifetime'));
|
$oAttachment->Set('expire', time() + MetaModel::GetConfig()->Get('draft_attachments_lifetime'));
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ Dict::Add('EN US', 'English', 'English', array(
|
|||||||
'Attachments:NoAttachment' => 'No attachment. ',
|
'Attachments:NoAttachment' => 'No attachment. ',
|
||||||
'Attachments:PreviewNotAvailable' => 'Preview not available for this type of attachment.',
|
'Attachments:PreviewNotAvailable' => 'Preview not available for this type of attachment.',
|
||||||
'Attachments:Error:FileTooLarge' => 'File is too large to be uploaded. %1$s',
|
'Attachments:Error:FileTooLarge' => 'File is too large to be uploaded. %1$s',
|
||||||
|
'Attachments:Error:UploadedFileEmpty' => 'The received file is empty. Check that your server disk is not full.',
|
||||||
'Attachments:Render:Icons' => 'Display as icons',
|
'Attachments:Render:Icons' => 'Display as icons',
|
||||||
'Attachments:Render:Table' => 'Display as list',
|
'Attachments:Render:Table' => 'Display as list',
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
|||||||
'Attachments:NoAttachment' => 'Aucune pièce jointe.',
|
'Attachments:NoAttachment' => 'Aucune pièce jointe.',
|
||||||
'Attachments:PreviewNotAvailable' => 'Pas d\'aperçu pour ce type de pièce jointe.',
|
'Attachments:PreviewNotAvailable' => 'Pas d\'aperçu pour ce type de pièce jointe.',
|
||||||
'Attachments:Error:FileTooLarge' => 'Le fichier est trop gros pour être chargé. %1$s',
|
'Attachments:Error:FileTooLarge' => 'Le fichier est trop gros pour être chargé. %1$s',
|
||||||
|
'Attachments:Error:UploadedFileEmpty' => 'Le fichier téléchargé est vide. Vérifiez qu\'il reste de la place disque disponible sur le serveur',
|
||||||
'Attachments:Render:Icons' => 'Affichage en icônes',
|
'Attachments:Render:Icons' => 'Affichage en icônes',
|
||||||
'Attachments:Render:Table' => 'Affichage en liste',
|
'Attachments:Render:Table' => 'Affichage en liste',
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ abstract class AbstractAttachmentsRenderer
|
|||||||
$(sContentNode).html(data);
|
$(sContentNode).html(data);
|
||||||
$(sContentNode).unblock();
|
$(sContentNode).unblock();
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#file').fileupload({
|
$('#file').fileupload({
|
||||||
@@ -181,8 +181,20 @@ abstract class AbstractAttachmentsRenderer
|
|||||||
formData: { operation: 'add', temp_id: '$this->sTransactionId', obj_class: '$sClass' },
|
formData: { operation: 'add', temp_id: '$this->sTransactionId', obj_class: '$sClass' },
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
pasteZone: null, // Don't accept files via Chrome's copy/paste
|
pasteZone: null, // Don't accept files via Chrome's copy/paste
|
||||||
done: RefreshAttachmentsDisplay,
|
done: function (e, data) {
|
||||||
send: function(e, data){
|
if(typeof(data.result.error) != 'undefined')
|
||||||
|
{
|
||||||
|
if(data.result.error !== '')
|
||||||
|
{
|
||||||
|
alert(data.result.error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RefreshAttachmentsDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
send: function(e, data){
|
||||||
// Don't send attachment if size is greater than PHP post_max_size, otherwise it will break the request and all its parameters (\$_REQUEST, \$_POST, ...)
|
// Don't send attachment if size is greater than PHP post_max_size, otherwise it will break the request and all its parameters (\$_REQUEST, \$_POST, ...)
|
||||||
// Note: We loop on the files as the data structures is an array but in this case, we only upload 1 file at a time.
|
// Note: We loop on the files as the data structures is an array but in this case, we only upload 1 file at a time.
|
||||||
var iTotalSizeInBytes = 0;
|
var iTotalSizeInBytes = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user