Skip to content

Commit

Permalink
Bugfix exclude CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jul 3, 2019
1 parent 59df15f commit 74984d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Config/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
use CodeIgniter\Config\Services;

Events::on('post_controller_constructor', function () {
Services::visits()->record();
// Ignore CLI requests
return is_cli() ?: Services::visits()->record();
});
4 changes: 4 additions & 0 deletions src/Visits.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function __construct(BaseConfig $config, $db = null)
// add a new visit, or increase the view count on an existing one
public function record()
{
// Ignore CLI requests
if (is_cli())
return;

// Check for ignored AJAX requests
if (Services::request()->isAJAX() && $this->config->ignoreAjax)
return;
Expand Down

0 comments on commit 74984d0

Please sign in to comment.