diff options
author | zotlabs <mike@macgirvin.com> | 2017-04-18 18:31:10 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-04-18 18:31:10 -0700 |
commit | 53bd0146bb9a924a103646db0b628ede28d294a1 (patch) | |
tree | 5764005eb2f2219f94fcaac240c65f83eb62557d | |
parent | a037758245b2846b3b8fa3bb6425dce547832c09 (diff) | |
download | volse-hubzilla-53bd0146bb9a924a103646db0b628ede28d294a1.tar.gz volse-hubzilla-53bd0146bb9a924a103646db0b628ede28d294a1.tar.bz2 volse-hubzilla-53bd0146bb9a924a103646db0b628ede28d294a1.zip |
oembed cache: don't store the url (which may need to be truncated), store a hash instead. This will allow us to convert the table to utf8mb4 without running into mysql key length restrictions as well as dealing with the potential ambiguity of truncated urls.
-rw-r--r-- | Zotlabs/Lib/Cache.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index f211269be..cea075659 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -9,10 +9,10 @@ namespace Zotlabs\Lib; class Cache { public static function get($key) { - $key = substr($key,0,254); + $hash = hash('whirlpool',$key); $r = q("SELECT v FROM cache WHERE k = '%s' limit 1", - dbesc($key) + dbesc($hash) ); if ($r) @@ -22,20 +22,20 @@ class Cache { public static function set($key,$value) { - $key = substr($key,0,254); + $hash = hash('whirlpool',$key); $r = q("SELECT * FROM cache WHERE k = '%s' limit 1", - dbesc($key) + dbesc($hash) ); if($r) { q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'", dbesc($value), dbesc(datetime_convert()), - dbesc($key)); + dbesc($hash)); } else { q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')", - dbesc($key), + dbesc($hash), dbesc($value), dbesc(datetime_convert())); } |