Closed chrisyip closed 7 years ago
Hey! Thanks for using Alfred Devdocs. I cannot reproduce the error locally. Do you have the last version of Alfred Devdocs installed? You can install it here.
Still have the issue.
I found something might be useful:
In DevDocs
's constructor, !isset($doc) || empty($doc)
is always true
and $this->processDocumentation($key, $query)
is never called because of none of keys in $pList['connections']
is exists in $documentations
:
foreach ($pList['connections'] as $key => $value) {
print_r($key . " " . array_key_exists($key, $documentations) . "\n");
if (array_key_exists($key, $documentations)) {
$this->checkCache($key);
$this->processDocumentation($key, $query);
}
}
$pList['connections'] count: 9
addalltask 0
addalltaskkeyword 0
addtask 0
doc 0
dotaskbasedoncommand 0
nuketask 0
nuketaskkeyword 0
refreshtask 0
removetask 0
Therefore echo $this->workflows->toxml()
returns a string that only contains a whitespace.
I got the same error, but I found the cache file is not cached completely.
After changed getDocumentations function as blew, it works fine.
private function getDocumentations() {
$docFile = self::$cacheDirectory . 'docs.json';
// Keep the docs in cache during 7 days
if (!file_exists($docFile) || (filemtime($docFile) <= time() - 86400 * 7)) {
$docContent = file_get_contents('http://devdocs.io/docs/docs.json');
file_put_contents($docFile, $docContent);
} else {
$docContent = file_get_contents($docFile);
}
$docs = json_decode($docContent);
$documentations = [];
foreach ($docs as $doc) {
$doc->fullName = $doc->name . (!empty($doc->version) ? ' ' . $doc->version : '');
$documentations[$doc->slug] = $doc;
}
return $documentations;
}
Maybe you need to remove the cache file first.
I guess the difference with the current version is that you do not use the cached file after retrieving it. If this existing code does not work, I think it is because the file_put_contents
method fails.
As I never could reproduce the error, can you confirm that the error comes from the file_put_contents
method?
I created https://github.com/yannickglt/alfred-devdocs/pull/17 which contains the code you suggested, if you can review it :slightly_smiling_face:
OK, this works for me. Maybe @chrisyip can confirm if it works.
Unfortunately, it doesn't work for me:
JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
$HOME/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.yannickglt.alfred2.devdocs/docs.json0
@chrisyip could you upload or send me the docs.json file? I see a trailing 0 at the end of the log you paste, is it a mistake or is it really logged as is?
@yannickglt Alfred logged as is.
Here's docs.json file: https://gist.github.com/chrisyip/ea848b57f1f021a7afd1fe62e171233c
Thanks. Could you send the index.plist file as well plz?
@yannickglt I can't find index.plist file, could you tell me the full path?
I merged #17 and bumped a new version of the workflow. Could you have a check on it plz?
Works now! But I can't get any result from doc KEYWORD
:
Nice! For the doc
command, it works on my end. How many docs did you add? It may take time the first time you run the doc
command as it will fetch all the added docs. Once the cache is built, it should be instant then.
I removed all data and works now! Thank you!
You're welcome. Sorry for the delay. I close the issue.
Still get the Same error on Alfred 3.4.1 - should I Open another ticket
Starting debug for 'devdocs'
[2017-08-07 12:43:02][input.scriptfilter] Queuing argument ''
[2017-08-07 12:43:02][input.scriptfilter] Script with argument '(null)' finished
[2017-08-07 12:43:02][input.scriptfilter] Warning: Invalid argument supplied for foreach() in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/conf.php on line 97
<?xml version="1.0"?>
<items><item uid="" arg="" valid="no" autocomplete=" "><title>No results.</title><subtitle></subtitle><icon></icon></item></items>
[2017-08-07 12:43:02][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Warning: Invalid argument supplied for foreach() in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/conf.php on line 97
<?xml version="1.0"?>
<items><item uid="" arg="" valid="no" autocomplete=" "><title>No results.</title><subtitle></subtitle><icon></icon></item></items>
Could you have a check to the version 1.3.1 of the workflow @machbio?
There seems to be some issue with the Proxy Setting - I have set the HTTP_PROXY in the workflow setting, but it does not work.
[2017-08-07 18:40:02][input.scriptfilter] Queuing argument ''
[2017-08-07 18:40:02][input.scriptfilter] Script with argument '(null)' finished
[2017-08-07 18:40:02][input.scriptfilter] Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 73
Warning: file_get_contents(http://maxcdn-docs.devdocs.io/tensorflow~python/index.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 73
Warning: Invalid argument supplied for foreach() in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 88
<?xml version="1.0"?>
<items><item uid="No results." arg="http://devdocs.io/tensorflow~python/" valid="yes" autocomplete="No results."><title>No results.</title><subtitle></subtitle><icon>tensorflow~python.png</icon></item></items>
[2017-08-07 18:40:02][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 73
Warning: file_get_contents(http://maxcdn-docs.devdocs.io/tensorflow~python/index.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 73
Warning: Invalid argument supplied for foreach() in /Users/Username/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.69A0FEC4-E474-47AA-A0CA-D1280C48DDC2/scripts/devdocs.php on line 88
<?xml version="1.0"?>
<items><item uid="No results." arg="http://devdocs.io/tensorflow~python/" valid="yes" autocomplete="No results."><title>No results.</title><subtitle></subtitle><icon>tensorflow~python.png</icon></item></items>
@yannickglt it seems like your workflow unsets the HTTP_PROXY variable randomly.
It might be because of an update of the workflow. I don't know how Alfred handles environment variables when updating worklow. Do you use Packal to automatically update the workflow?
@yannickglt I downloaded the workflow from this github repository..
Hi @machbio! The variable erasing should be fixed by fecad49def4a9e6b24cd349fb2d971c775da52c9. You can download v1.3.2 which includes this patch.
On macOS 10.12.3 (16D32) and Alfred v3.3.1 [806], I got this error:
I tried to print the result of
file_get_contents('http://devdocs.io/docs/docs.json')
, looks fine: