-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
// 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;
}
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
// 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);
$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
// 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>';
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;
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');
$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
}
}
- Logger::log('Update from \'' . $stored . '\' to \'' . $current . '\' - successful', Logger::DEBUG);
+ Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
if ($sendMail) {
self::updateSuccessfull($stored, $current);
}
{
$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.
$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 {
}
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());
// 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;
}
//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)
}
//try the logger
- Logger::log("Database structure update successful.", Logger::TRACE);
+ Logger::debug('Database structure update successful.');
}
}
$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'])) {
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
)*
)@';
}
'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
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