Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
6c592539
Commit
6c592539
authored
Jan 09, 2015
by
Lukas Reschke
Browse files
Merge pull request #13179 from owncloud/fix-fatal-php-error-for-not-existing-files
Verify whether type is correct
parents
6a5f12be
ceaaab62
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/ajax/preview.php
View file @
6c592539
...
@@ -29,21 +29,17 @@ if ($maxX === 0 || $maxY === 0) {
...
@@ -29,21 +29,17 @@ if ($maxX === 0 || $maxY === 0) {
exit
;
exit
;
}
}
try
{
$preview
=
new
\
OC\Preview
(
\
OC_User
::
getUser
(),
'files'
);
$preview
=
new
\
OC\Preview
(
\
OC_User
::
getUser
(),
'files'
);
$info
=
\
OC\Files\Filesystem
::
getFileInfo
(
$file
);
if
(
!
$always
and
!
$preview
->
isAvailable
(
$info
))
{
\
OC_Response
::
setStatus
(
404
);
}
else
{
$preview
->
setFile
(
$file
);
$preview
->
setMaxX
(
$maxX
);
$preview
->
setMaxY
(
$maxY
);
$preview
->
setScalingUp
(
$scalingUp
);
$preview
->
setKeepAspect
(
$keepAspect
);
$preview
->
showPreview
();
}
}
catch
(
\
Exception
$e
)
{
$info
=
\
OC\Files\Filesystem
::
getFileInfo
(
$file
);
\
OC_Response
::
setStatus
(
500
);
\
OC_Log
::
write
(
'core'
,
$e
->
getmessage
(),
\
OC_Log
::
DEBUG
);
if
(
!
$info
instanceof
OCP\Files\FileInfo
||
!
$always
&&
!
$preview
->
isAvailable
(
$info
))
{
\
OC_Response
::
setStatus
(
404
);
}
else
{
$preview
->
setFile
(
$file
);
$preview
->
setMaxX
(
$maxX
);
$preview
->
setMaxY
(
$maxY
);
$preview
->
setScalingUp
(
$scalingUp
);
$preview
->
setKeepAspect
(
$keepAspect
);
$preview
->
showPreview
();
}
}
lib/private/preview.php
View file @
6c592539
...
@@ -200,14 +200,15 @@ class Preview {
...
@@ -200,14 +200,15 @@ class Preview {
/**
/**
* set the path of the file you want a thumbnail from
* set the path of the file you want a thumbnail from
* @param string $file
* @param string $file
* @return
\OC\Preview
$this
* @return $this
*/
*/
public
function
setFile
(
$file
)
{
public
function
setFile
(
$file
)
{
$this
->
file
=
$file
;
$this
->
file
=
$file
;
$this
->
info
=
null
;
$this
->
info
=
null
;
if
(
$file
!==
''
)
{
if
(
$file
!==
''
)
{
$this
->
getFileInfo
();
$this
->
getFileInfo
();
if
(
$this
->
info
!==
null
&&
$this
->
info
!==
false
)
{
if
(
$this
->
info
instanceof
\
OCP\Files\FileInfo
)
{
$this
->
mimeType
=
$this
->
info
->
getMimetype
();
$this
->
mimeType
=
$this
->
info
->
getMimetype
();
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment