Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/40945
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: fix usort callback functions to return integers

Calls to the PHP usort function have been refactored so that the callback
function used always correctly returns an integer.

https://github.com/owncloud/core/pull/40945
2 changes: 1 addition & 1 deletion core/Command/App/CheckCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(" {$count} errors");
}
\usort($errors, function ($a, $b) {
return $a['line'] >$b['line'];
return $a['line'] - $b['line'];
});

foreach ($errors as $p) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function findMigrations() {

$files = \array_keys(\iterator_to_array($iterator));
\uasort($files, function ($a, $b) {
return (\basename($a) < \basename($b)) ? -1 : 1;
return \strcmp(\basename($a), \basename($b));
});

$migrations = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Preview/TXT.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function getFontFile(array $info): string {
if ($a === $b) {
return 0;
}
return ($a < $b) ? 1 : -1;
return ($b - $a);
});
// Information is ordered by counted chars, from highest number of counted chars to lowest.
foreach ($countInfo as $key => $value) {
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Settings/SettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,15 @@ protected function loadSection($type, $sectionID) {

/**
* Sort the array of ISettings or ISections by their priority attribute
* @param array $objects (ISections of ISettings)
* A lower priority number means that the item should appear first.
* @param array $objects (ISections or ISettings)
* @return array
*/
protected function sortOrder($objects) {
\usort($objects, function ($a, $b) {
/** @var ISection | ISettings $a */
/** @var ISection | ISettings $b */
return $a->getPriority() < $b->getPriority();
return $b->getPriority() - $a->getPriority();
});
return $objects;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Files/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function testSearchByTag() {
$this->assertCount(2, $results);

\usort($results, function ($value1, $value2) {
return $value1['name'] >= $value2['name'];
return \strcmp($value1['name'], $value2['name']);
});

$this->assertEquals('folder', $results[0]['name']);
Expand All @@ -382,7 +382,7 @@ public function testSearchByTag() {
$this->assertCount(3, $results);

\usort($results, function ($value1, $value2) {
return $value1['name'] >= $value2['name'];
return \strcmp($value1['name'], $value2['name']);
});

$this->assertEquals('folder', $results[0]['name']);
Expand Down