aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2024-11-25 14:01:57 +0100
committerAndreas Gohr <andi@splitbrain.org>2024-11-25 14:01:57 +0100
commit109ebc86261a0180ea28685cc90702b1c701198e (patch)
tree28114f6726ffe00eb6234a355c054f1de341f5b2
parentf577a2efaaaefaee955f65130d5d7f54483f9be1 (diff)
downloaddokuwiki-109ebc86261a0180ea28685cc90702b1c701198e.tar.gz
dokuwiki-109ebc86261a0180ea28685cc90702b1c701198e.zip
io_replaceInFile: replace warning with logging call
-rw-r--r--_test/tests/inc/io_replaceinfile.test.php7
-rw-r--r--inc/io.php3
2 files changed, 3 insertions, 7 deletions
diff --git a/_test/tests/inc/io_replaceinfile.test.php b/_test/tests/inc/io_replaceinfile.test.php
index 61b0e12e0..a3ec44669 100644
--- a/_test/tests/inc/io_replaceinfile.test.php
+++ b/_test/tests/inc/io_replaceinfile.test.php
@@ -104,12 +104,7 @@ class io_replaceinfile_test extends DokuWikiTest {
*/
function test_badparam()
{
- if (class_exists('PHPUnit\Framework\Error\Warning')) {
- $expect = 'PHPUnit\Framework\Error\Warning'; // PHPUnit 6
- } else {
- $expect = 'PHPUnit_Framework_Error_Warning'; // PHPUnit 5
- }
- $this->expectException($expect);
+ $this->expectLogMessage('io_replaceInFile() $oldline parameter cannot be empty');
/* The empty $oldline parameter should be caught before the file doesn't exist test. */
$this->assertFalse(io_replaceInFile(TMP_DIR.'/not_existing_file.txt', '', '', false, 0));
diff --git a/inc/io.php b/inc/io.php
index da42d4185..85a9e325a 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -7,6 +7,7 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
+use dokuwiki\Logger;
use dokuwiki\Utf8\PhpString;
use dokuwiki\HTTP\DokuHTTPClient;
use dokuwiki\Extension\Event;
@@ -343,7 +344,7 @@ function io_saveFile($file, $content, $append = false)
function io_replaceInFile($file, $oldline, $newline, $regex = false, $maxlines = 0)
{
if ((string)$oldline === '') {
- trigger_error('$oldline parameter cannot be empty in io_replaceInFile()', E_USER_WARNING);
+ Logger::error('io_replaceInFile() $oldline parameter cannot be empty');
return false;
}