Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API error response "file" property is getting lost #1937

Closed
hdodov opened this issue Jul 22, 2019 · 5 comments

Comments

@hdodov
Copy link

commented Jul 22, 2019

Describe the bug
The file specified in the JSON response is "":
image

Expected behavior
The problematic file should be specified in the error response.

Screenshots
image

Kirby Version
3.2.0

Additional context
As you can see in the debug console (screenshot), $e->getFile() correctly returns the file where the error occurred. However, after the DOCUMENT_ROOT check, $file is now "". Here's some evaluated code in the debug console after this check:

$file
""
$e->getFile()
"C:\xampp\htdocs\kirby\site\plugins\exporter\src\Formatter.php"
$_SERVER['DOCUMENT_ROOT']
"C:/xampp/htdocs"
@hdodov

This comment has been minimized.

Copy link
Author

commented Aug 28, 2019

This also happens in other cases where the error is not a Kirby exception:

image

In this case, execution when through the other conditional block at line 544 and after it exited, the $file was empty again.


It would be great if we can get some sort of hotfix for the time being because you need to alter the core every time a new release is out in order to debug properly.

@hdodov

This comment has been minimized.

Copy link
Author

commented Aug 28, 2019

I've currently fixed it by adding this:

if (isset($e) && is_array($result)) {
    $result['file'] = $e->getFile();
}

After the try-catch block, i.e. after this line:

if ($result === null) {

bastianallgeier added a commit that referenced this issue Sep 5, 2019
bastianallgeier added a commit that referenced this issue Sep 5, 2019
@bastianallgeier bastianallgeier modified the milestones: 3.5.0, 3.2.5 Sep 5, 2019
bastianallgeier added a commit that referenced this issue Sep 9, 2019
bastianallgeier added a commit that referenced this issue Sep 9, 2019
bastianallgeier added a commit that referenced this issue Sep 9, 2019
bastianallgeier added a commit that referenced this issue Sep 9, 2019
bastianallgeier added a commit that referenced this issue Sep 9, 2019
@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Sep 9, 2019

@hdodov

This comment has been minimized.

Copy link
Author

commented Sep 9, 2019

Wow, you did quite a bit of refactoring. Thanks! It's been a small bug, but quite annoying.

@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Sep 9, 2019

I think it was really worth it! Especially for the Spaghetti code in the Api class.

afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
This reverts commit 08a808f.
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
afbora added a commit to afbora/kirby that referenced this issue Sep 13, 2019
This reverts commit 08a808f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.