Merge pull request #12310 from MrPetovan/bug/deprecated
Address a couple PHP 8.1 deprecation notices
This commit is contained in:
commit
684fceada9
|
@ -21,6 +21,8 @@
|
|||
|
||||
namespace Friendica\Content\Text;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
||||
|
@ -106,8 +108,18 @@ class Markdown
|
|||
* So we'll use that to convert to HTML, then convert the HTML back to bbcode,
|
||||
* and then clean up a few Diaspora specific constructs.
|
||||
*/
|
||||
public static function toBBCode($s)
|
||||
public static function toBBCode($s): string
|
||||
{
|
||||
// @TODO Temporary until we find the source of the null value to finally set the correct type-hint
|
||||
if (is_null($s)) {
|
||||
Logger::warning('Received null value', ['callstack' => System::callstack()]);
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$s) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
DI::profiler()->startRecording('rendering');
|
||||
|
||||
// The parser cannot handle paragraphs correctly
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Util;
|
|||
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
|
||||
/**
|
||||
|
@ -480,7 +481,7 @@ class Strings
|
|||
|
||||
$blocks = [];
|
||||
|
||||
$text = preg_replace_callback($regex,
|
||||
$return = preg_replace_callback($regex,
|
||||
function ($matches) use ($executionId, &$blocks) {
|
||||
$return = '«block-' . $executionId . '-' . count($blocks) . '»';
|
||||
|
||||
|
@ -491,7 +492,11 @@ class Strings
|
|||
$text
|
||||
);
|
||||
|
||||
$text = $callback($text) ?? '';
|
||||
if (is_null($return)) {
|
||||
Logger::warning('Received null value from preg_replace_callback', ['text' => $text, 'regex' => $regex, 'blocks' => $blocks, 'executionId' => $executionId, 'callstack' => System::callstack(10)]);
|
||||
}
|
||||
|
||||
$text = $callback($return ?? $text) ?? '';
|
||||
|
||||
// Restore code blocks
|
||||
$text = preg_replace_callback('/«block-' . $executionId . '-([0-9]+)»/iU',
|
||||
|
|
Loading…
Reference in a new issue