View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032832 | mantisbt | code cleanup | public | 2023-08-17 03:30 | 2023-10-31 16:32 |
Reporter | dregad | Assigned To | dregad | ||
Priority | normal | Severity | tweak | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Fixed in Version | 2.26.0 | ||||
Summary | 0032832: Remove version_cache_row()'s 2nd parameter | ||||
Description | $p_trigger_errors parameter allows the function to conditionally throw an Exception or return False when the Version can't be found. This is a legacy construct going back to when trigger_error() was used instead of Exceptions, and the parameter is only used once in version_exists(). To simplify the code, the parameter should be removed and a try/catch block used to replace the single use case. | ||||
Additional Information | This issue was identified while working on PR https://github.com/mantisbt/mantisbt/pull/1869 to fix 0032086. | ||||
Tags | No tags attached. | ||||
This caused PHPUnit tests to fail [1], as version_cache_row() does not behave consistently (i.e. throw an exception) when a non-existent version is present in the cache. Independently, I find it strange that RestProjectVersionTest::testProjectUpdateDoesNotExists expects a 204 (version deleted) and not a 404 (not found) [2] (see 0030415). |
|
|
|
MantisBT: master e4b23f72 2023-03-01 12:21 Details Diff |
Remove version_cache_row()'s 2nd parameter $p_trigger_errors allows the function to conditionally throw an Exception or return False when the Version can't be found. This is a legacy construct going back to when trigger_error() was used instead of Exceptions, and is only used once in version_exists(). To simplify code, the parameter is removed and a try/catch block is used to replace the single use case. Fixes 0032832 |
Affected Issues 0032832 |
|
mod - core/version_api.php | Diff File | ||
MantisBT: master 39d5f21c 2023-08-17 12:00 Details Diff |
Throw Exception when unfound version is cached Broken PHPUnit tests following e4b23f723464d01da12c1068c471779a6f386b2a. version_cache_row()'s behavior was inconsistent for non-existing versions, throwing an exception the first time around, and returning false the second time (when the version is stored in the cache). Fixes 0032832 |
Affected Issues 0032832 |
|
mod - core/version_api.php | Diff File |