Skip to content

Commit 3f1a71b

Browse files
committed
fix: DEPRECATED error in Honeypot
[DEPRECATED] str_ireplace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in SYSTEMPATH\Honeypot\Honeypot.php on line 93.
1 parent ba8c285 commit 3f1a71b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

system/Honeypot/Honeypot.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function hasContent(RequestInterface $request)
7878
*/
7979
public function attachHoneypot(ResponseInterface $response)
8080
{
81+
if ($response->getBody() === null) {
82+
return;
83+
}
84+
8185
if ($response->getCSP()->enabled()) {
8286
// Add id attribute to the container tag.
8387
$this->config->container = str_ireplace(

tests/system/Honeypot/HoneypotTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ public function testAttachHoneypot(): void
6767
$this->assertStringNotContainsString($this->config->name, $this->response->getBody());
6868
}
6969

70+
public function testAttachHoneypotBodyNull(): void
71+
{
72+
$this->response->setBody(null);
73+
74+
$this->honeypot->attachHoneypot($this->response);
75+
76+
$this->assertNull($this->response->getBody());
77+
}
78+
7079
public function testAttachHoneypotAndContainer(): void
7180
{
7281
$this->response->setBody('<form></form>');

0 commit comments

Comments
 (0)