Skip to content

Commit

Permalink
$_ENV might not be populated in all PHP setups, use getenv() #5
Browse files Browse the repository at this point in the history
  • Loading branch information
stroebjo committed May 21, 2022
1 parent 71fce78 commit 6b77b66
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// check for username
if (empty($_ENV['username'])) {
if (false === getenv('username')) {
echo json_encode([
'items' => [[
"arg" => "https://www.alfredapp.com/help/workflows/advanced/variables/",
Expand All @@ -13,7 +13,7 @@
exit(1);
}

$cache_path = $_ENV['alfred_workflow_cache'];
$cache_path = getenv('alfred_workflow_cache');
$cache_response = $cache_path . '/cache.json';
$cache_icons = $cache_path . '/icons/';

Expand All @@ -25,10 +25,10 @@
mkdir($cache_icons);
}

$username = trim($_ENV['username']); // set inside workflow variables
$token = trim($_ENV['token']); // set inside workflow variables
$username = trim(getenv('username')); // set inside workflow variables
$token = trim(getenv('token')); // set inside workflow variables
$starred_url = sprintf('https://api.github.com/users/%s/starred', $username);
$cache_ttl = (empty($_ENV['cache_ttl'])) ? 3600 * 24 : (int) $_ENV['cache_ttl']; // in seconds
$cache_ttl = (false === getenv('cache_ttl')) ? 3600 * 24 : (int) getenv('cache_ttl'); // in seconds
$query = trim($argv[1]); // optional text search
$http_status = 200; // default status code, so when using cache it doesn't run into error handling

Expand Down

0 comments on commit 6b77b66

Please sign in to comment.