Do not overwrite existing favicons
This commit is contained in:
parent
97bab4aaad
commit
d6d9368ab3
@ -31,6 +31,15 @@ function store_favicon($mime_type, $blob)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hash = sha1($blob);
|
$hash = sha1($blob);
|
||||||
|
$favicon_id = Database::getInstance('db')
|
||||||
|
->table(TABLE)
|
||||||
|
->eq('hash', $hash)
|
||||||
|
->findOneColumn('id');
|
||||||
|
|
||||||
|
if ($favicon_id) {
|
||||||
|
return $favicon_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_put_contents(get_favicon_filename($hash, $mime_type), $blob) === false) {
|
if (file_put_contents(get_favicon_filename($hash, $mime_type), $blob) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ class FaviconModelTest extends BaseTest
|
|||||||
$this->assertCreateFeed($this->buildFeed());
|
$this->assertCreateFeed($this->buildFeed());
|
||||||
|
|
||||||
self::$functions
|
self::$functions
|
||||||
->expects($this->any())
|
->expects($this->once())
|
||||||
->method('file_put_contents')
|
->method('file_put_contents')
|
||||||
->with(
|
->with(
|
||||||
$this->stringEndsWith('data/favicons/57978a20204f7af6967571041c79d907a8a8072c.png'),
|
$this->stringEndsWith('data/favicons/57978a20204f7af6967571041c79d907a8a8072c.png'),
|
||||||
|
Loading…
Reference in New Issue
Block a user