From bcb1cd71e8c97ddddb5737915a9c8232ef81f190 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Sun, 7 Feb 2021 20:33:47 -0600 Subject: [PATCH 1/8] add current known foriegn key fixes possibly required post upgrading --- doc/Update.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/Update.md b/doc/Update.md index c4fe161863..db986126ca 100644 --- a/doc/Update.md +++ b/doc/Update.md @@ -77,3 +77,32 @@ RENAME TABLE _new TO ; ``` This method is slower overall, but it is better suited for large numbers of duplicates. + +### Resolving Possible Database Issues Post Upgrading + +#### Foriegn Keys + +Some of the updates include the use of foreign keys now that will bump +into issues with previous versions, which would sometimes shove bad +data into tables, preventing, causing errors such as below. + +``` +Error 1452 occurred during database update: +Cannot add or update a child row: a foreign key constraint fails (`friendica`.`#sql-10ea6_5a6d`, CONSTRAINT `#sql-10ea6_5a6d_ibfk_1` FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`)) +ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE; +``` + +All current known fixes for possible items that can go wrong are as below. + +```SQL +delete from item where `owner-id` not in (select id from contact); +delete from item where `contact-id` not in (select id from contact); +delete from notify where `uri-id` not in (select id from `item-uri`); +delete from photo where `contact-id` not in (select id from contact); +delete from thread where iid not in (select id from item); +delete from item where `author-id` not in (select id from contact); +delete from diaspora-interaction where uri-id not in (select id from item-uri); +``` + +This all has been compiled as of currently from issue #9746, #9753, +and #9878. From 48ebb4b731fc4fcc05eae62c3855a4f37f296515 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 7 Feb 2021 22:00:47 -0500 Subject: [PATCH 2/8] Improve formatting in doc/Update.md - Fix typo - Enforce Markdown convention of a sentence per line - Improve SQL formatting regarding language keywords and escaped identifiers --- doc/Update.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/doc/Update.md b/doc/Update.md index db986126ca..d019d03b03 100644 --- a/doc/Update.md +++ b/doc/Update.md @@ -80,11 +80,9 @@ This method is slower overall, but it is better suited for large numbers of dupl ### Resolving Possible Database Issues Post Upgrading -#### Foriegn Keys +#### Foreign Keys -Some of the updates include the use of foreign keys now that will bump -into issues with previous versions, which would sometimes shove bad -data into tables, preventing, causing errors such as below. +Some of the updates include the use of foreign keys now that will bump into issues with previous versions, which would sometimes shove bad data into tables, preventing, causing errors such as below. ``` Error 1452 occurred during database update: @@ -95,14 +93,13 @@ ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE All current known fixes for possible items that can go wrong are as below. ```SQL -delete from item where `owner-id` not in (select id from contact); -delete from item where `contact-id` not in (select id from contact); -delete from notify where `uri-id` not in (select id from `item-uri`); -delete from photo where `contact-id` not in (select id from contact); -delete from thread where iid not in (select id from item); -delete from item where `author-id` not in (select id from contact); -delete from diaspora-interaction where uri-id not in (select id from item-uri); +DELETE FROM `item` WHERE `owner-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `item` WHERE `contact-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`); +DELETE FROM `photo` WHERE `contact-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `thread` WHERE `iid` NOT IN (SELECT `id` FROM `item`); +DELETE FROM `item` WHERE `author-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`); ``` -This all has been compiled as of currently from issue #9746, #9753, -and #9878. +This all has been compiled as of currently from issue #9746, #9753, and #9878. From 7653bc00dfc8334d833ca6989758bc74fcca9023 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 9 Feb 2021 23:20:28 -0500 Subject: [PATCH 3/8] Try OEmbed first for [audio] and [video] tags --- src/Content/Text/BBCode.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 66c180052d..29b8d2525f 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1616,12 +1616,13 @@ class BBCode // html5 video and audio $text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4).*?)\[\/video\]/ism", '', $text); - $text = preg_replace("/\[video\](.*?)\[\/video\]/ism", - '$1', $text); - $text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '', $text); $text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", $try_oembed_callback, $text); $text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", $try_oembed_callback, $text); + + $text = preg_replace("/\[video\](.*?)\[\/video\]/ism", + '$1', $text); + $text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '', $text); } else { $text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '$1', $text); From 0927bb5f2c50a8927d774df94c44a1bc8acac7a9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 8 Feb 2021 02:03:48 -0500 Subject: [PATCH 4/8] Harden OEmbed link discovery - Check OEmbed call return code before storing response - Stop at first successful OEmbed response --- src/Content/OEmbed.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 355dda3fc1..3afa36904a 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -98,21 +98,19 @@ class OEmbed // try oembed autodiscovery $html_text = DI::httpRequest()->fetch($embedurl, 15, 'text/*'); if ($html_text) { - $dom = @DOMDocument::loadHTML($html_text); - if ($dom) { + $dom = new DOMDocument(); + if ($dom->loadHTML($html_text)) { $xpath = new DOMXPath($dom); - $entries = $xpath->query("//link[@type='application/json+oembed']"); - foreach ($entries as $e) { - $href = $e->getAttributeNode('href')->nodeValue; - $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth); - break; - } - - $entries = $xpath->query("//link[@type='text/json+oembed']"); - foreach ($entries as $e) { - $href = $e->getAttributeNode('href')->nodeValue; - $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth); - break; + foreach ( + $xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']") + as $link) + { + $href = $link->getAttributeNode('href')->nodeValue; + $result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->videowidth); + if ($result->getReturnCode() === 200) { + $json_string = $result->getBody(); + break; + } } } } From 4a57ed1a31eb96d55f70aaa6ed7ed7d8e6acc362 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 8 Feb 2021 02:06:24 -0500 Subject: [PATCH 5/8] Move HTTPS exception for YouTube and Vimeo to OEmbed::fetchUrl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Both Youtube and Vimeo output OEmbed endpoint URL with HTTP but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ --- src/Content/OEmbed.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 3afa36904a..1a5d1d9042 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -106,6 +106,10 @@ class OEmbed as $link) { $href = $link->getAttributeNode('href')->nodeValue; + // Both Youtube and Vimeo output OEmbed endpoint URL with HTTP + // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ + $href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'], + ['https://www.youtube.com/', 'https://player.vimeo.com/'], $href); $result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->videowidth); if ($result->getReturnCode() === 200) { $json_string = $result->getBody(); @@ -335,10 +339,6 @@ class OEmbed public static function getHTML($url, $title = null) { - // Always embed the SSL version - $url = str_replace(["http://www.youtube.com/", "http://player.vimeo.com/"], - ["https://www.youtube.com/", "https://player.vimeo.com/"], $url); - $o = self::fetchURL($url, !self::isAllowedURL($url)); if (!is_object($o) || property_exists($o, 'type') && $o->type == 'error') { From 004419de4668bb538b1c2acd266202cab6b37160 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 8 Feb 2021 11:04:59 -0500 Subject: [PATCH 6/8] Remove references to removed frost theme --- bin/dev/minifyjs.sh | 7 ------- doc/Text_comment.md | 2 -- doc/Text_editor.md | 5 ----- doc/de/Text_comment.md | 2 -- doc/de/Text_editor.md | 2 -- doc/img/editor_frost.png | Bin 1881 -> 0 bytes doc/img/frost.png | Bin 1032 -> 0 bytes 7 files changed, 18 deletions(-) delete mode 100644 doc/img/editor_frost.png delete mode 100644 doc/img/frost.png diff --git a/bin/dev/minifyjs.sh b/bin/dev/minifyjs.sh index caa2b3846a..2c38cf8801 100755 --- a/bin/dev/minifyjs.sh +++ b/bin/dev/minifyjs.sh @@ -9,13 +9,6 @@ JSFILES=( "view/js/country.js" "view/js/main.js" "vendor/asset/base64/base64.min.js" - "view/theme/frost/js/jquery.divgrow-1.3.1.f1.js" - "view/theme/frost/js/main.js" - "view/theme/frost/js/theme.js" - "view/theme/frost-mobile/js/jquery.divgrow-1.3.1.f1.js" - "view/theme/frost-mobile/js/main.js" - "view/theme/frost-mobile/js/theme.js" - "view/theme/decaf-mobile/js/theme.js" ) JSFILES2=( "library/colorbox/jquery.colorbox.js" diff --git a/doc/Text_comment.md b/doc/Text_comment.md index 2aac568378..7cd26d55f6 100644 --- a/doc/Text_comment.md +++ b/doc/Text_comment.md @@ -40,5 +40,3 @@ Darkzero darkzero.png(incl. more "zero"-themes, slackr, comix, easterbunny, facepark) Dispy dispy.png (incl. smoothly, testbubble) - -Frost Mobile frost.png diff --git a/doc/Text_editor.md b/doc/Text_editor.md index 07e1fa929e..ebbaf22549 100644 --- a/doc/Text_editor.md +++ b/doc/Text_editor.md @@ -78,11 +78,6 @@ These icons can change depending on the theme. Some examples: darkbubble.png   - - Frost: - frost.png -   - * how to [upload](help/FAQ#upload) files

 

diff --git a/doc/de/Text_comment.md b/doc/de/Text_comment.md index 88e5e0b119..6dc47a524d 100644 --- a/doc/de/Text_comment.md +++ b/doc/de/Text_comment.md @@ -57,5 +57,3 @@ Darkzero darkzero.png(inkl. weiterer "zero"-Themen, slackr, comix, easterbunny, facepark) Dispy dispy.png (inkl. smoothly, testbubble) - -Frost Mobile frost.png diff --git a/doc/de/Text_editor.md b/doc/de/Text_editor.md index 33fc104dff..5f90f3b91a 100644 --- a/doc/de/Text_editor.md +++ b/doc/de/Text_editor.md @@ -54,6 +54,4 @@ Darkbubble darkbubble.png -Frost frost.png - Vier vier.png (inkl. dispy) diff --git a/doc/img/editor_frost.png b/doc/img/editor_frost.png deleted file mode 100644 index d0ac5a41271eaded59e5dca0ab6941e44c389fe6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1881 zcmZ`)c{mjO7XF2doyiudP?qScvCWJvh7qGIgU^zW7<;bI(io9SN=Ag@L$cg37@|n_ zy(VR87)By9nVV(QShH_;`s@C6-{(2!ea?BG^PKF4 z0^9}=MJsqN@dco4Pyp1V3GaFz=FW;fRt`1*#Ha!gcOQUl?ka8$fJhhs^IiZLXb+GxfB<&2U0~_rJH>Bj4XWVwYh~)oDj7^E@MdZ|L?w7JZ-KA8{PI zPSTc>5omvQ!}q!{hw57zH$5-wNPFpIw9b>In5~<$|7xvRT>mGX1DU-n@w8&}!p6du zQa*mu+^j3>e&HX2y;YMzcb{gf97NFK9nA-rL4aR`XY?7w40j!PE5T%UNc zbz0b8MI`0&2kk`i=LlItCg<9Zj^-o4G>2rzY*x^PE@kgu5KAej0xl1OQDwu_rBD#b6cf8&0wZ zy&53U28yR-IzO$$uqVW|HAWgrF1T=I*Cy)dNCqlPmfoUdTWUD2cAYjX4{aH*QJ-H! z8NC|)$o^%#la16ju=NRAI~#0iskV5&Megrk@Wq&J2R)W!vL-gTr^4}8%X=o1X|mn; za33lD01~X0v`1c;!Z%S;U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^s#f$cRIK0-$MSqmFI|71>kBQbyVujS7CpF^diSsIqr zYgCGFPZcObFv$1qSP1F zy*1n?a##4neVy{oj-pe(*Y8b=sZxA-!0v30g0b%Yof~!g-$(>b+Zd-ab=}HcktbBP ztz-GaUv+y=jmB;94f?NJ_dIT&f3m?w_y4|yW-344te?;3WBIAdW?~!@gH!IsfAYuD zuBgTFYlnK|IB5Bu&d(ByfB0<6^jBp(2Wl?!9+>+0`}sqkHD=7M|FZJ!qzes_|7-uu zo3=3P$DzfmTU9+Tz2Z`t{!7Phf19A}e!de+xg|L!ooHa4&lL9O!R$ZJvJ7PkKN_uC zb?oJZ#aXKV);_!?v#og>SBCGRWo%bi*w*|IexIK?twyUZnp<1%#KktxzmhvDlJo2> zuU_4`a7mSm%U<31?%xjAeqaA_?!SKf{fFg0Wb4}hJ0Hux(y~xDGXMS-V3trVag8WR zNi0dVN-jzTQVd20h8DU8=DLQ)A%-Sa#->)r7TN{|Rt5$;${&fKXvob^$xN%nt>L6r q)C!;m0gw&B`DrEPiAAXl!5O6`C82 From 07c938a95031e1a769d4c610444ae58317f3785b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 8 Feb 2021 11:05:18 -0500 Subject: [PATCH 7/8] Move vier-specific smileybutton styles to addon --- view/theme/vier/style.css | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 0ef69f2caa..8bf982018e 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -2073,22 +2073,6 @@ section.minimal { margin-left: 15px; cursor: pointer; } -#profile-smiley-wrapper { - float: left; - margin-left: 15px; - cursor: pointer; - margin-top: 3px; - height: 10px; - display: inline-block; -} -#smileybutton { - position: absolute; - z-index: 99; -} -table.smiley-preview { - background-color: #FFF; - box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); -} #jot-perms-icon { float: right; margin-left: 15px; From b2680bffb05a7ead190fd57a7174acfd8c7c5073 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 8 Feb 2021 02:21:56 -0500 Subject: [PATCH 8/8] Babel: Support tweet URL --- src/Module/Debug/Babel.php | 49 +++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index e33f03214f..f4a0fa1d95 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -246,30 +246,35 @@ class Babel extends BaseModule case 'twitter': $json = trim($_REQUEST['text']); - $status = json_decode($json); - - $results[] = [ - 'title' => DI::l10n()->t('Decoded post'), - 'content' => visible_whitespace(var_export($status, true)), - ]; - - $postarray = []; - $postarray['object-type'] = Activity\ObjectType::NOTE; - - if (!empty($status->full_text)) { - $postarray['body'] = $status->full_text; - } else { - $postarray['body'] = $status->text; - } - - // When the post contains links then use the correct object type - if (count($status->entities->urls) > 0) { - $postarray['object-type'] = Activity\ObjectType::BOOKMARK; - } - if (file_exists('addon/twitter/twitter.php')) { require_once 'addon/twitter/twitter.php'; + if (parse_url($json) !== false) { + preg_match('#^https?://(?:mobile\.|www\.)?twitter.com/[^/]+/status/(\d+).*#', $json, $matches); + $status = twitter_statuses_show($matches[1]); + } else { + $status = json_decode($json); + } + + $results[] = [ + 'title' => DI::l10n()->t('Decoded post'), + 'content' => visible_whitespace(var_export($status, true)), + ]; + + $postarray = []; + $postarray['object-type'] = Activity\ObjectType::NOTE; + + if (!empty($status->full_text)) { + $postarray['body'] = $status->full_text; + } else { + $postarray['body'] = $status->text; + } + + // When the post contains links then use the correct object type + if (count($status->entities->urls) > 0) { + $postarray['object-type'] = Activity\ObjectType::BOOKMARK; + } + $picture = \twitter_media_entities($status, $postarray); $results[] = [ @@ -307,7 +312,7 @@ class Babel extends BaseModule '$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'], '$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'], '$flag_twitter' => file_exists('addon/twitter/twitter.php'), - '$type_twitter' => ['type', DI::l10n()->t('Twitter Source'), 'twitter', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'twitter'], + '$type_twitter' => ['type', DI::l10n()->t('Twitter Source / Tweet URL (requires API key)'), 'twitter', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'twitter'], '$results' => $results ]);