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

[5.0] Smart Search: Improving error handling of Indexing #39965

Merged
merged 4 commits into from
May 30, 2023

Conversation

Hackwar
Copy link
Member

@Hackwar Hackwar commented Feb 28, 2023

Pull Request for Issue #39717.

Summary of Changes

The indexer in Smart Search currently has situations where errors are returned and instead of gracefully reporting an error, the whole indexing just silently stops and does not proceed. This PR tries to catch all output and notices from finder plugins and return that as properly formatted error. I also removed some unused code.

Testing Instructions

  1. Go to a finder plugin, for example /plugins/finder/content/src/Extension/Content.php and trigger any output in the index() method. For example you can add var_dump($item->title).
  2. In the Smart Search component in the backend click on "Index".

Actual result BEFORE applying this Pull Request

The indexing starts, but shortly after it does not progress any further.

Expected result AFTER applying this Pull Request

The indexing starts and shortly after an error message is displayed. The whole response can be found in the browser console.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@Fedik
Copy link
Member

Fedik commented Feb 28, 2023

I have tested this item ✅ successfully on 8b37e66


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39965.

Co-authored-by: Quy <quy@nomonkeybiz.com>
@wilsonge
Copy link
Contributor

wilsonge commented Mar 1, 2023

OK this just hides the message and doesn't give us any way to actually fix the problem? Like if there are PHP errors - yes we don't want things to silently fail - but we do want to make sure that they are logged so we can fix them properly in the future rather than just silently swallowing them.

@Fedik
Copy link
Member

Fedik commented Mar 1, 2023

I think George is right.
It probably can be improved in clinet side

onSuccess: (response) => {
handleResponse(JSON.parse(response));
},
onError: (xhr) => {
handleFailure(xhr);
},

Need kind of

let response;
try {
  response = JSON.parse(data);
} catch (e) {
  Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr, 'parsererror'));
}
handleResponse(response); 

Need to test

@Hackwar
Copy link
Member Author

Hackwar commented Mar 1, 2023

I tried the try-catch and had all of that ready, but it made everything a lot uglier. The thing is that you need to have access to the output and that is now properly in the browser console.

I've used this approach because we have most of the necessary code already in there. We have ob_start() everywhere, but we are missing actually suppressing the output.

@Fedik
Copy link
Member

Fedik commented Mar 1, 2023

I will prepare another pr, need some time

@Fedik Fedik mentioned this pull request Mar 1, 2023
2 tasks
@Fedik
Copy link
Member

Fedik commented Mar 1, 2023

There it is #39973, please review 😉

@chmst
Copy link
Contributor

chmst commented Mar 4, 2023

@Hackwar as #39973 is RTC, could you close this one?

@Hackwar
Copy link
Member Author

Hackwar commented Mar 4, 2023

They are both valid from my perspective.

@Hackwar Hackwar added the bug label Apr 7, 2023
@Hackwar Hackwar closed this Apr 18, 2023
@Hackwar Hackwar reopened this Apr 18, 2023
@Hackwar Hackwar changed the base branch from 4.3-dev to 5.0-dev April 18, 2023 12:56
@Hackwar Hackwar changed the title [4.3] Improving error handling of Smart Search Indexing [5.0] Improving error handling of Smart Search Indexing Apr 18, 2023
@Hackwar Hackwar changed the title [5.0] Improving error handling of Smart Search Indexing [5.0] Smart Search: Improving error handling of Indexing Apr 18, 2023
@Quy Quy removed the PR-4.3-dev label Apr 18, 2023
@HLeithner
Copy link
Member

this can be closed since #39973 has been merged right? @Hackwar

@Hackwar
Copy link
Member Author

Hackwar commented May 30, 2023

No, I'd like to have both merged, since this one here fixes issues on the PHP side, while #39973 fixes this on JS side of things.

@@ -264,6 +282,7 @@ public static function sendResponse($data = null)
$response->buffer = ob_get_contents();
$response->memory = memory_get_usage(true);
}
ob_clean();
Copy link
Member

Choose a reason for hiding this comment

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

looks like we try to silently hide errors, didn't you try to avoid this?

@HLeithner HLeithner merged commit 1ba66fb into joomla:5.0-dev May 30, 2023
@HLeithner
Copy link
Member

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants