Navigation Menu

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

Display error when Mantis log file is not writable #1483

Merged
merged 2 commits into from Apr 1, 2019

Conversation

dregad
Copy link
Member

@dregad dregad commented Mar 21, 2019

Replaces PR #606

Fixes #19642

Here's how it looks...
image

@dregad
Copy link
Member Author

dregad commented Mar 21, 2019

This PR is built on top of #1482, which should be merged first.

Copy link
Member

@vboctor vboctor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test how this works with API calls? I wonder if we need to be using exceptions vs triggering errors.

@dregad
Copy link
Member Author

dregad commented Mar 22, 2019

Thanks for the feedback @vboctor.

I'm not sure I understand what kind of testing you expect me to do, and what you mean with needing exceptions, as the new code does not trigger any errors (see changes in logging_api.php), it just adds a message to the queue for display at page bottom, and prints it to the system log as well (which would be how the problem would be logged in the case of an API call).

Are you saying that I should instead be throwing an exception to interrupt the execution flow ? I can certainly do that, but my thinking was that a failure to log is not a blocking error.

@dregad
Copy link
Member Author

dregad commented Mar 26, 2019

@vboctor you have not responded to #1483 (comment).

@dregad
Copy link
Member Author

dregad commented Mar 29, 2019

@vboctor without feedback from you, I'll go ahead and merge this coming week-end.

Encapsulates the logic to enqueue error messages for later display.

Issue #19642
@vboctor
Copy link
Member

vboctor commented Mar 30, 2019

@dregad The thing I wanted to make sure doesn't happen is that if:

  • logging is enabled.
  • Log file is not writable.
  • An API call is made that triggers logging

The result shouldn't be that execution stops, but API is successful. This may not be an issue due to different error handlers, but it is worth making sure that is the case.

@dregad
Copy link
Member Author

dregad commented Apr 1, 2019

@vboctor thanks for your feedback, I understand what you mean now. Will test and confirm that the system behaves per your expectation.

@dregad
Copy link
Member Author

dregad commented Apr 1, 2019

@vboctor the test is successful - the system behaves as per your expectations, just as I thought it would.

Testing scenario

  1. set config_inc.php
    $g_log_level = LOG_EMAIL;
    $g_log_destination = 'file:/tmp/mantisbt.log';
  2. Make an API call: add a bugnote (note: assumes that the action would actually trigger an e-mail notification, e.g. the issue's reporter is not the same as the user making the call)
    curl -sS -o /dev/null -w "Status: %{response_code}\n" --request POST \
      --url https://path.to/mantisbt/api/rest/issues/1/notes \
      --header 'Authorization: {{token}}' \
      --header 'Content-Type: application/json' \
      --data '{"text": "test note", "view_state": {"name": "public"}}'
  3. Output is Status: 201, a new bugnote has been added to the issue and the MantisBT log file shows:
    2019-04-01 12:21 UTC MAIL email_api.php:980 email_bugnote_add() Note ~31 added to issue #1
    
  4. Make MantisBT log-file read-only
    chmod 444 /tmp/mantisbt.log
  5. Repeat the same API call
  6. Output is Status: 201, a new bugnote has been added to the issue, nothing was added to the MantisBT log file, and the PHP error log shows:
    [01-Apr-2019 12:27:55 UTC] MantisBT - The file specified in $g_log_destination "/tmp/mantisbt.log" is not writable.
    

@vboctor
Copy link
Member

vboctor commented Apr 1, 2019

Thanks @dregad for testing this.

@dregad dregad merged commit 6d288c6 into mantisbt:master Apr 1, 2019
@dregad dregad deleted the i19642-log-not-writable branch April 1, 2019 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants