diff --git a/libraries/classes/ErrorHandler.php b/libraries/classes/ErrorHandler.php index 3bfe02b748..d1363f2f30 100644 --- a/libraries/classes/ErrorHandler.php +++ b/libraries/classes/ErrorHandler.php @@ -160,7 +160,7 @@ class ErrorHandler $errors = $this->getErrors(false); $this->errors = array_splice($errors, 0, $count); - return array_splice($errors, $count); + return $errors; } /** diff --git a/test/classes/ErrorHandlerTest.php b/test/classes/ErrorHandlerTest.php index 6ccef68668..867c117743 100644 --- a/test/classes/ErrorHandlerTest.php +++ b/test/classes/ErrorHandlerTest.php @@ -181,6 +181,12 @@ class ErrorHandlerTest extends AbstractTestCase */ public function testSliceErrors(): void { + $this->object->addError( + 'Compile Error', + E_WARNING, + 'error.txt', + 15 + ); $this->object->addError( 'Compile Error', E_WARNING, @@ -188,23 +194,23 @@ class ErrorHandlerTest extends AbstractTestCase 15 ); $this->assertEquals( - 1, + 2, $this->object->countErrors() ); $this->assertEquals( [], - $this->object->sliceErrors(1) + $this->object->sliceErrors(2) ); $this->assertEquals( - 1, + 2, $this->object->countErrors() ); $this->assertCount( 1, - $this->object->sliceErrors(0) + $this->object->sliceErrors(1) ); $this->assertEquals( - 0, + 1, $this->object->countErrors() ); }