stable

Clone or download

Read-only

fix: Replace empty syntax errors by regular errors

Fixes request #40086 JavaScript error when trying an expert query with default mode How to test: - In a Cross-tracker search widget, set up a query in expert mode and save the report. - Switch to default mode, select at least one tracker, do not edit the expert query (leave the SELECT ...). Click on "Search". - The widget should show a translated error message explaining that the "SELECT" keyword is not allowed in default mode. There is no JavaScript error in the console. No functional change excpected for the following errors: - Query is too complicated: change the limit to 1 in the DB, in tracker_report_config table - Too many SELECT fields: tuleap config-set crosstracker_maximum_selected_columns 1, use more than one field in SELECT - SELECT field used more than once: SELECT @id, @id - XTS syntax in tracker report: paste a valid expert query in a Tracker report - Missing FROM: it looks impossible to trigger, the parser will cause a SyntaxError before we reach it. Why? We do not try to use SyntaxError: we are not in a parser, we have no clue what the query string looks like. Instead of trying, we use regular exception to carry the error message. It should be helpful enough without. Exception translations are moved to a dedicated class. It keeps the advantage of having them only in one place, but it removes the responsibility of translation from the Exception classes. They are meant to help programmers, the calling code has the necessary context to know how (or even if) to translate them, or to format them (CSV plain-text or JSON). We did not change all exceptions handled, some of them are collections of messages. It's a start. Notes InvalidSelectablesCollectionBuilder (in Tracker) was never used. Change-Id: I58344a049032ed8da29b58ba8555a7a7f9ce728c

Modified Files

Name
M plugins/crosstracker/include/CrossTracker/REST/v1/CrossTrackerReportsResource.php +18 −20 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/CSV/CSVExportController.php +11 −3 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/CrossTrackerArtifactReportFactory.php +38 −20 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/Query/Advanced/InvalidSelectablesCollectionBuilder.php +0 −4 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/ReportTrackersRetriever.php +6 −9 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/RetrieveReportTrackers.php +6 −0 Go to diff View file
M plugins/crosstracker/scripts/cross-tracker/src/components/ErrorMessage.vue +29 −25 Go to diff View file
M plugins/tracker/composer.json +1 −1 Go to diff View file
M plugins/tracker/include/REST/v1/TrackersResource.class.php +9 −17 Go to diff View file
A plugins/tracker/include/Tracker/Report/Query/Advanced/Errors/QueryErrorsTranslator.php +70 −0 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/ExpertQueryValidator.php +27 −41 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/IBuildInvalidSelectablesCollection.php +2 −0 Go to diff View file
R plugins/tracker/include/Tracker/Report/Query/Advanced/EmptySyntaxError.php Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/LimitSizeIsExceededException.php +3 −3 Go to diff View file
R plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidSelectablesCollectionBuilder.php Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/SelectLimitExceededException.php +6 −19 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/SelectablesMustBeUniqueException.php +1 −15 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/SizeValidatorVisitor.php +3 −0 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/SyntaxNotSupportedException.php +1 −12 Go to diff View file
M plugins/tracker/include/Tracker/Report/Tracker_Report.class.php +4 −11 Go to diff View file
M plugins/tracker/site-content/fr_FR/LC_MESSAGES/tuleap-tracker.po +13 −4 Go to diff View file
M plugins/tracker/site-content/pt_BR/LC_MESSAGES/tuleap-tracker.po +9 −3 Go to diff View file
D plugins/tracker/tests/unit/Tracker/Report/Query/Advanced/InvalidSelectablesCollectionBuilderTest.php +0 −45 Go to diff View file
M tests/psalm/psalm.xml +0 −1 Go to diff View file