]> git.mxchange.org Git - friendica.git/commitdiff
Add maxwidth column to oembed table
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 9 Jan 2018 04:40:10 +0000 (23:40 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Thu, 11 Jan 2018 00:25:08 +0000 (19:25 -0500)
- Match Caching key for OEmbed queries

boot.php
src/Content/OEmbed.php
src/Database/DBStructure.php

index 48eaeb6f3b5708e575aeb6794cbbc29717ee058b..b10ba7a63f178b5d4726678c71fbd215d0eaf3f3 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -43,7 +43,7 @@ define('FRIENDICA_PLATFORM',     'Friendica');
 define('FRIENDICA_CODENAME',     'Asparagus');
 define('FRIENDICA_VERSION',      '3.6-dev');
 define('DFRN_PROTOCOL_VERSION',  '2.23');
-define('DB_UPDATE_VERSION',      1239);
+define('DB_UPDATE_VERSION',      1240);
 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
 
 /**
index 5a3f07b536382be6bc501cac72b4b4aa387aeac0..364648d071fa42776e0b160821f968e4a6da1510 100644 (file)
@@ -47,8 +47,8 @@ class OEmbed
         * @param string $embedurl The URL from which the data should be fetched.
         * @param bool $no_rich_type If set to true rich type content won't be fetched.
         *
-        * @return bool|object Returns object with embed content or false if no embedable
-        *       content exists
+        * @return bool|object Returns object with embed content or false if no embeddable
+        *                         content exists
         */
        public static function fetchURL($embedurl, $no_rich_type = false)
        {
@@ -57,7 +57,7 @@ class OEmbed
 
                $a = get_app();
 
-               $condition = ['url' => normalise_link($embedurl)];
+               $condition = ['url' => normalise_link($embedurl), 'maxwidth' => $a->videowidth];
                $r = dba::selectFirst('oembed', ['content'], $condition);
                if (DBM::is_result($r)) {
                        $txt = $r["content"];
@@ -105,8 +105,12 @@ class OEmbed
                        } else { //save in cache
                                $j = json_decode($txt);
                                if ($j->type != "error") {
-                                       dba::insert('oembed', array('url' => normalise_link($embedurl),
-                                               'content' => $txt, 'created' => datetime_convert()), true);
+                                       dba::insert('oembed', [
+                                               'url' => normalise_link($embedurl),
+                                               'maxwidth' => $a->videowidth,
+                                               'content' => $txt,
+                                               'created' => datetime_convert()
+                                       ], true);
                                }
 
                                Cache::set($a->videowidth . $embedurl, $txt, CACHE_DAY);
@@ -306,7 +310,7 @@ class OEmbed
                if (!x($str_allowed)) {
                        return false;
                }
-               
+
                $allowed = explode(',', $str_allowed);
 
                return allowed_domain($domain, $allowed);
index b33f02345081c8b7a527f557c643f7ea864bcdb8..11bf40aec4acf9fcf0fbf8d84f1c35f9bba91560 100644 (file)
@@ -1277,11 +1277,12 @@ class DBStructure {
                $database["oembed"] = array(
                                "fields" => array(
                                                "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
+                                               "maxwidth" => array("type" => "int(11)", "not null" => "1", "primary" => "1"),
                                                "content" => array("type" => "mediumtext"),
                                                "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
                                                ),
                                "indexes" => array(
-                                               "PRIMARY" => array("url"),
+                                               "PRIMARY" => array("url", "maxwidth"),
                                                "created" => array("created"),
                                                )
                                );