]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #6882 from annando/follow-peertube
authorPhilipp <admin+Github@philipp.info>
Thu, 14 Mar 2019 22:39:04 +0000 (23:39 +0100)
committerGitHub <noreply@github.com>
Thu, 14 Mar 2019 22:39:04 +0000 (23:39 +0100)
Issue 6874: Follow peertube

.codecov.yml
include/enotify.php
src/Content/Text/BBCode.php
src/Core/Update.php
src/Network/Probe.php
src/Util/Strings.php
tests/src/Content/Text/BBCodeTest.php

index 4592266d815ae9a883d06858d38cc14befd54bfc..35509a879e44cf6727aac171a52f2ceffb44960b 100644 (file)
@@ -1,36 +1,10 @@
-codecov:
-  branch: develop
-
-comment: off
 
 coverage:
   status:
-    patch:
-      default: off
-      source:
-        target: 80%
-        flags: source
-      backend:
-        target: 80%
-        flags: backend
     project:
-      default: off
-      source:
-        flags: source
-      backend:
-        flags: backend
+      default:
+        target: auto
+        threshold: null
+        base: auto
 
-flags:
-  source:
-    paths:
-      - src/
-  backend:
-    paths:
-      - mod/
-      - include/
-  binary:
-    paths:
-      - bin/
-  tests:
-    paths:
-      - tests/
+comment: off
index db44b464deb79b44ae9535163e905786e69bbf87..f9295d5e18df09b91959dc3953a4241290478fa3 100644 (file)
@@ -453,11 +453,20 @@ function notification($params)
                // It will be used by the system to send emails to users (like
                // password reset, invitations and so) using one look (but without
                // add a notification to the user, with could be inexistent)
-               $subject = $params['subject'];
+               if (!isset($params['subject'])) {
+                       Logger::warning('subject isn\'t set.', ['type' => $params['type']]);
+               }
+               $subject = defaults($params, 'subject', '');
 
-               $preamble = $params['preamble'];
+               if (!isset($params['preamble'])) {
+                       Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]);
+               }
+               $preamble = defaults($params, 'preamble', '');
 
-               $body =  $params['body'];
+               if (!isset($params['body'])) {
+                       Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]);
+               }
+               $body = defaults($params, 'body', '');
 
                $show_in_notification_page = false;
        }
index 2d1c681f4f204fb17038501808c1a51e0f1ca36b..e417b38a467b8cbb8ed096a8f9d153e3cb5ce10a 100644 (file)
@@ -1180,17 +1180,18 @@ class BBCode extends BaseObject
                        return $return;
                };
 
-               // Extracting multi-line code blocks before the whitespace processing
+               // Extracting code blocks before the whitespace processing and the autolinker
                $codeblocks = [];
 
                $text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#ism",
                        function ($matches) use (&$codeblocks) {
-                               $return = $matches[0];
+                               $return = '#codeblock-' . count($codeblocks) . '#';
                                if (strpos($matches[2], "\n") !== false) {
-                                       $return = '#codeblock-' . count($codeblocks) . '#';
-
-                                       $codeblocks[] =  '<pre><code class="language-' . trim($matches[1]) . '">' . trim($matches[2], "\n\r") . '</code></pre>';
+                                       $codeblocks[] = '<pre><code class="language-' . trim($matches[1]) . '">' . trim($matches[2], "\n\r") . '</code></pre>';
+                               } else {
+                                       $codeblocks[] = '<code>' . $matches[2] . '</code>';
                                }
+
                                return $return;
                        },
                        $text
@@ -1266,6 +1267,9 @@ class BBCode extends BaseObject
                // Set up the parameters for a MAIL search string
                $MAILSearchString = $URLSearchString;
 
+               // Handle attached links or videos
+               $text = self::convertAttachment($text, $simple_html, $try_oembed);
+
                // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
                if (!$for_plaintext) {
                        $text = preg_replace(Strings::autoLinkRegEx(), '[url]$1[/url]', $text);
@@ -1278,10 +1282,6 @@ class BBCode extends BaseObject
                        $text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::removePictureLinksCallback', $text);
                }
 
-
-               // Handle attached links or videos
-               $text = self::convertAttachment($text, $simple_html, $try_oembed);
-
                $text = str_replace(["\r","\n"], ['<br />', '<br />'], $text);
 
                // Remove all hashtag addresses
@@ -1503,12 +1503,6 @@ class BBCode extends BaseObject
                // Check for font change text
                $text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $text);
 
-               // Declare the format for [code] layout
-
-               $CodeLayout = '<code>$1</code>';
-               // Check for [code] text
-               $text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $text);
-
                // Declare the format for [spoiler] layout
                $SpoilerLayout = '<blockquote class="spoiler">$1</blockquote>';
 
index e0a7c4a266be545dd1b745a0c610ee17c4c957b1..bb2513d38858741ac6de779edca7058c5d19746a 100644 (file)
@@ -68,7 +68,7 @@ class Update
                        Lock::release('dbupdate', true);
                }
 
-               $build = Config::get('system', 'build');
+               $build = Config::get('system', 'build', null, true);
 
                if (empty($build) || ($build > DB_UPDATE_VERSION)) {
                        $build = DB_UPDATE_VERSION - 1;
@@ -83,12 +83,20 @@ class Update
                        if ($stored < $current || $force) {
                                Config::load('database');
 
-                               Logger::log('Update from \'' . $stored . '\'  to \'' . $current . '\' - starting', Logger::DEBUG);
+                               Logger::info('Update starting.', ['from' => $stored, 'to' => $current]);
 
                                // Compare the current structure with the defined structure
                                // If the Lock is acquired, never release it automatically to avoid double updates
                                if (Lock::acquire('dbupdate', 120, Cache::INFINITE)) {
 
+                                       // Checks if the build changed during Lock acquiring (so no double update occurs)
+                                       $retryBuild = Config::get('system', 'build', null, true);
+                                       if ($retryBuild !== $build) {
+                                               Logger::info('Update already done.', ['from' => $stored, 'to' => $current]);
+                                               Lock::release('dbupdate');
+                                               return '';
+                                       }
+
                                        // run the pre_update_nnnn functions in update.php
                                        for ($x = $stored + 1; $x <= $current; $x++) {
                                                $r = self::runUpdateFunction($x, 'pre_update');
@@ -106,13 +114,13 @@ class Update
                                                                $retval
                                                        );
                                                }
-                                               Logger::log('ERROR: Update from \'' . $stored . '\'  to \'' . $current . '\' - failed:  ' - $retval, Logger::ALL);
+                                               Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
                                                Lock::release('dbupdate');
                                                return $retval;
                                        } else {
                                                Config::set('database', 'last_successful_update', $current);
                                                Config::set('database', 'last_successful_update_time', time());
-                                               Logger::log('Update from \'' . $stored . '\'  to \'' . $current . '\' - finished', Logger::DEBUG);
+                                               Logger::info('Update finished.', ['from' => $stored, 'to' => $current]);
                                        }
 
                                        // run the update_nnnn functions in update.php
@@ -123,7 +131,7 @@ class Update
                                                }
                                        }
 
-                                       Logger::log('Update from \'' . $stored . '\'  to \'' . $current . '\' - successful', Logger::DEBUG);
+                                       Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
                                        if ($sendMail) {
                                                self::updateSuccessfull($stored, $current);
                                        }
@@ -149,7 +157,7 @@ class Update
        {
                $funcname = $prefix . '_' . $x;
 
-               Logger::log('Update function \'' . $funcname . '\' - start', Logger::DEBUG);
+               Logger::info('Update function start.', ['function' => $funcname]);
 
                if (function_exists($funcname)) {
                        // There could be a lot of processes running or about to run.
@@ -170,7 +178,7 @@ class Update
                                                $x,
                                                L10n::t('Update %s failed. See error logs.', $x)
                                        );
-                                       Logger::log('ERROR: Update function \'' . $funcname . '\' - failed: ' . $retval, Logger::ALL);
+                                       Logger::error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
                                        Lock::release('dbupdate_function');
                                        return false;
                                } else {
@@ -182,12 +190,12 @@ class Update
                                        }
 
                                        Lock::release('dbupdate_function');
-                                       Logger::log('Update function \'' . $funcname . '\' - finished', Logger::DEBUG);
+                                       Logger::info('Update function finished.', ['function' => $funcname]);
                                        return true;
                                }
                        }
                } else {
-                        Logger::log('Skipping \'' . $funcname . '\' without executing', Logger::DEBUG);
+                       Logger::info('Update function skipped.', ['function' => $funcname]);
 
                        Config::set('database', 'last_successful_update_function', $funcname);
                        Config::set('database', 'last_successful_update_function_time', time());
@@ -214,7 +222,7 @@ class Update
 
                // No valid result?
                if (!DBA::isResult($adminlist)) {
-                       Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), Logger::INFO);
+                       Logger::warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
 
                        // Don't continue
                        return;
@@ -252,7 +260,7 @@ class Update
                }
 
                //try the logger
-               Logger::log("CRITICAL: Database structure update failed: " . $error_message);
+               Logger::alert('Database structure update FAILED.', ['error' => $error_message]);
        }
 
        private static function updateSuccessfull($from_build, $to_build)
@@ -291,6 +299,6 @@ class Update
                }
 
                //try the logger
-               Logger::log("Database structure update successful.", Logger::TRACE);
+               Logger::debug('Database structure update successful.');
        }
 }
index 3dceb81bc77b49db8c6c92b42664917e1749e712..008106ec3f41f6f60fd2b56d23286219465c803b 100644 (file)
@@ -353,7 +353,7 @@ class Probe
                                $data = $ap_profile;
                        }
                } else {
-                       Logger::notice('Time out detected. AP will not be probed.', ['url' => $url]);
+                       Logger::notice('Time out detected. AP will not be probed.', ['uri' => $uri]);
                }
 
                if (!isset($data['url'])) {
index 3edc9ba90683959fcd685208a62b24b6c18bdfab..681edb1c87711d8ae6d6f9cb84e4e076f86a7c9c 100644 (file)
@@ -358,17 +358,17 @@ class Strings
                return '@(?xi)
 (?<![=\'\]"/])          # Not preceded by [, =, \', ], ", /
 \b
-(                       # Capture 1: entire matched URL
-  https?://                 # http or https protocol
+(                              # Capture 1: entire matched URL
+  https?://                            # http or https protocol
   (?:
-    [^/.][^/]+[.][^/]+/?    # looks like domain name followed by a slash
+    [^/\s.][^/\s]+[.][^\s/]+/?         # looks like domain name followed by a slash
   )
-  (?:                       # One or more:
-    [^\s()<>]+                  # Run of non-space, non-()<>
-    |                           #   or
-    \(([^\s()<>]+|(\([^\s()<>]+\)))*\)  # balanced parens, up to 2 levels
-    |                               #   or
-    [^\s`!()\[\]{};:\'".,<>?«»“”‘’]        # not a space or one of these punct chars
+  (?:                                  # One or more:
+    [^\s()<>]+                         # Run of non-space, non-()<>
+    |                                  #   or
+    \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
+    |                                  #   or
+    [^\s`!()\[\]{};:\'".,<>?«»“”‘’]    # not a space or one of these punct chars
   )*
 )@';
        }
index f155eeee3d99a57cff3bcdf0034094f2981377aa..2f9a244ccc1466fb519f05025ede94b3cbcc1f5d 100644 (file)
@@ -86,6 +86,22 @@ class BBCodeTest extends MockedTest
                                'data' => 'http://example/path',\r
                                'assertHTML' => false\r
                        ],\r
+                       'bug-6857-domain-start' => [\r
+                               'data' => "http://\nexample.com",\r
+                               'assertHTML' => false\r
+                       ],\r
+                       'bug-6857-domain-end' => [\r
+                               'data' => "http://example\n.com",\r
+                               'assertHTML' => false\r
+                       ],\r
+                       'bug-6857-tld' => [\r
+                               'data' => "http://example.\ncom",\r
+                               'assertHTML' => false\r
+                       ],\r
+                       'bug-6857-end' => [\r
+                               'data' => "http://example.com\ntest",\r
+                               'assertHTML' => false\r
+                       ],\r
                ];\r
        }\r
 \r
@@ -100,12 +116,11 @@ class BBCodeTest extends MockedTest
        public function testAutoLinking($data, $assertHTML)\r
        {\r
                $output = BBCode::convert($data);\r
+               $assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';\r
                if ($assertHTML) {\r
-                       $assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';\r
+                       $this->assertEquals($assert, $output);\r
                } else {\r
-                       $assert = $data;\r
+                       $this->assertNotEquals($assert, $output);\r
                }\r
-\r
-               $this->assertEquals($assert, $output);\r
        }\r
-}
\ No newline at end of file
+}\r