Skip to content

Commit

Permalink
Fix a potential fatal error when running update from a Cron Job.
Browse files Browse the repository at this point in the history
Problem: The update script loads its dependencies using a relative path, so it may crash if you run it from a different directory. Fixed by using an absolute path instead.

Fixes #2
  • Loading branch information
YahnisElsts committed Aug 1, 2018
1 parent b0f19fd commit cde49c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Wpup;
use PDO;
require 'vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

$db = new PDO("sqlite:" . __DIR__ . '/db/stats.db3');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Expand Down
2 changes: 1 addition & 1 deletion update.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require 'vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

if (php_sapi_name() !== "cli") {
echo 'Error: This script must be run from the command line.';
Expand Down

0 comments on commit cde49c9

Please sign in to comment.