Trying to debug some stuff regarding oEmbed
This commit is contained in:
parent
a45d9471ed
commit
96ce758c05
@ -332,6 +332,7 @@ class OembedPlugin extends Plugin
|
|||||||
|
|
||||||
// All our remote Oembed images lack a local filename property in the File object
|
// All our remote Oembed images lack a local filename property in the File object
|
||||||
if (!is_null($file->filename)) {
|
if (!is_null($file->filename)) {
|
||||||
|
common_debug(sprintf('Filename of file id==%d is not null (%s), so nothing oEmbed should handle.', $file->getID(), _ve($file->filename)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,6 +343,7 @@ class OembedPlugin extends Plugin
|
|||||||
$thumbnail = File_thumbnail::byFile($file);
|
$thumbnail = File_thumbnail::byFile($file);
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
// Not Oembed data, or at least nothing we either can or want to use.
|
// Not Oembed data, or at least nothing we either can or want to use.
|
||||||
|
common_debug('No oEmbed data found for file id=='.$file->getID());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,6 +351,9 @@ class OembedPlugin extends Plugin
|
|||||||
$this->storeRemoteFileThumbnail($thumbnail);
|
$this->storeRemoteFileThumbnail($thumbnail);
|
||||||
} catch (AlreadyFulfilledException $e) {
|
} catch (AlreadyFulfilledException $e) {
|
||||||
// aw yiss!
|
// aw yiss!
|
||||||
|
} catch (Exception $e) {
|
||||||
|
common_debug(sprintf('oEmbed encountered an exception (%s) for file id==%d: %s', get_class($e), $file->getID(), _ve($e->getMessage())));
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$imgPath = $thumbnail->getPath();
|
$imgPath = $thumbnail->getPath();
|
||||||
@ -425,8 +430,7 @@ class OembedPlugin extends Plugin
|
|||||||
|
|
||||||
$ext = File::guessMimeExtension($info['mime']);
|
$ext = File::guessMimeExtension($info['mime']);
|
||||||
|
|
||||||
// We'll trust sha256 (File::FILEHASH_ALG) not to have collision issues any time soon :)
|
$filename = sprintf('oembed-%d.%s', $thumbnail->getFileId(), $ext);
|
||||||
$filename = 'oembed-'.hash(File::FILEHASH_ALG, $imgData) . ".{$ext}";
|
|
||||||
$fullpath = File_thumbnail::path($filename);
|
$fullpath = File_thumbnail::path($filename);
|
||||||
// Write the file to disk. Throw Exception on failure
|
// Write the file to disk. Throw Exception on failure
|
||||||
if (!file_exists($fullpath) && file_put_contents($fullpath, $imgData) === false) {
|
if (!file_exists($fullpath) && file_put_contents($fullpath, $imgData) === false) {
|
||||||
|
Loading…
Reference in New Issue
Block a user