Skip to content

Commit

Permalink
Merge branch 'MDL-77102' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Feb 16, 2023
2 parents e6343d7 + 25a6675 commit 5557480
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
10 changes: 1 addition & 9 deletions mod/wiki/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,7 @@ public static function get_subwiki_pages($wikiid, $groupid = -1, $userid = 0, $o
$retpage['contentformat'] = $contentformat;
} else {
// Return the size of the content.
$retpage['contentsize'] = strlen($cachedcontent);
// TODO: Remove this block of code once PHP 8.0 is the min version supported.
// For PHP < 8.0, if strlen() was overloaded, calculate
// the bytes using mb_strlen(..., '8bit').
if (PHP_VERSION_ID < 80000) {
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
$retpage['contentsize'] = mb_strlen($cachedcontent, '8bit');
}
}
$retpage['contentsize'] = \core_text::strlen($cachedcontent);
}

$returnedpages[] = $retpage;
Expand Down
10 changes: 1 addition & 9 deletions mod/wiki/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,15 +647,7 @@ public function test_get_subwiki_pages_collaborative() {

// Check that WS doesn't return page content if includecontent is false, it returns the size instead.
foreach ($expectedpages as $i => $expectedpage) {
$expectedpages[$i]['contentsize'] = strlen($expectedpages[$i]['cachedcontent']);
// TODO: Remove this block of code once PHP 8.0 is the min version supported.
// For PHP < 8.0, if strlen() was overloaded, calculate
// the bytes using mb_strlen(..., '8bit').
if (PHP_VERSION_ID < 80000) {
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
$expectedpages[$i]['contentsize'] = mb_strlen($expectedpages[$i]['cachedcontent'], '8bit');
}
}
$expectedpages[$i]['contentsize'] = \core_text::strlen($expectedpages[$i]['cachedcontent']);
unset($expectedpages[$i]['cachedcontent']);
unset($expectedpages[$i]['contentformat']);
}
Expand Down

0 comments on commit 5557480

Please sign in to comment.