Skip to content

Commit 74984d0

Browse files
committed
Bugfix exclude CLI
1 parent 59df15f commit 74984d0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Config/Events.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
use CodeIgniter\Config\Services;
55

66
Events::on('post_controller_constructor', function () {
7-
Services::visits()->record();
7+
// Ignore CLI requests
8+
return is_cli() ?: Services::visits()->record();
89
});

src/Visits.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public function __construct(BaseConfig $config, $db = null)
8787
// add a new visit, or increase the view count on an existing one
8888
public function record()
8989
{
90+
// Ignore CLI requests
91+
if (is_cli())
92+
return;
93+
9094
// Check for ignored AJAX requests
9195
if (Services::request()->isAJAX() && $this->config->ignoreAjax)
9296
return;

0 commit comments

Comments
 (0)