View Issue Details

IDProjectCategoryView StatusLast Update
0032832mantisbtcode cleanuppublic2023-10-31 16:32
Reporterdregad Assigned Todregad  
PrioritynormalSeveritytweakReproducibilityN/A
Status closedResolutionfixed 
Fixed in Version2.26.0 
Summary0032832: 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.

TagsNo tags attached.

Relationships

related to 0030415 closedvboctor REST API: Add API to Get / Delete / Update versions 

Activities

dregad

dregad

2023-08-17 10:10

developer   ~0067996

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).

dregad

dregad

2023-08-17 12:25

developer   ~0067997

strange that RestProjectVersionTest::testProjectUpdateDoesNotExists expects a 204 (version deleted) and not a 404 (not found)

See PR https://github.com/mantisbt/mantisbt/pull/1905

Related Changesets

MantisBT: master e4b23f72

2023-03-01 12:21

dregad


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

dregad


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