1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/15286] Update tests

PHPBB3-15286
This commit is contained in:
Rubén Calvo
2017-08-09 22:23:23 +02:00
parent a176fa56ef
commit 5111d8a339
9 changed files with 81 additions and 25 deletions

View File

@@ -1086,6 +1086,9 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
global $template, $cache, $user, $phpbb_dispatcher;
global $extensions, $config, $phpbb_root_path, $phpEx;
global $phpbb_container;
$attachment_storage = $phpbb_container->get('storage.attachment');
//
$compiled_attachments = array();
@@ -1219,18 +1222,16 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
{
if ($config['img_link_width'] || $config['img_link_height'])
{
//
$dimension = @getimagesize($filename);
try
{
$file_info = $storage_attachment->file_info($filename);
// If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
if ($dimension === false || empty($dimension[0]) || empty($dimension[1]))
$display_cat = ($file_info->image_width <= $config['img_link_width'] && $file_info->image_height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
}
catch (\Exception $e)
{
$display_cat = ATTACHMENT_CATEGORY_NONE;
}
else
{
$display_cat = ($dimension[0] <= $config['img_link_width'] && $dimension[1] <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
}
}
}
else
@@ -1284,8 +1285,18 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
// Macromedia Flash Files
case ATTACHMENT_CATEGORY_FLASH:
//
list($width, $height) = @getimagesize($filename);
try
{
$file_info = $storage_attachment->file_info($filename);
$width = $file_info->image_width;
$height = $file_info->image_height;
}
catch (\Exception $e)
{
$width = 0;
$height = 0;
}
$block_array += array(
'S_FLASH_FILE' => true,

View File

@@ -1442,7 +1442,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
{
global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request;
$attachment_storage = $phpbb_container->get('storage.avatar');
$attachment_storage = $phpbb_container->get('storage.attachment');
$poll = $poll_ary;
$data = $data_ary;

View File

@@ -161,6 +161,15 @@ class upload
// Make sure the image category only holds valid images...
$this->check_image($is_image);
if (count($this->file->error))
{
$this->file->remove($this->storage);
$this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error);
$this->file_data['post_attach'] = false;
return $this->file_data;
}
$this->fill_file_data();
$filedata = $this->file_data;
@@ -194,15 +203,6 @@ class upload
// Only then perform additional image checks.
$this->file->move_file($this->storage, false, !$is_image);
if (count($this->file->error))
{
$this->file->remove($this->storage);
$this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error);
$this->file_data['post_attach'] = false;
return $this->file_data;
}
return $this->file_data;
}