Relationship Graph

Relationship Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0037512mantisbtapi restpublic2026-11-30 08:39
Reporterdombn Assigned Tocommunity  
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version2.29.0 
Target Version2.29.1 
Summary0037512: Category commands set the project cookie on every call (one Set-Cookie per project in GET /api/rest/projects)
Description

Since 2.29.0, CategoryAddCommand, CategoryGetCommand, CategoryUpdateCommand and CategoryDeleteCommand (introduced with 0032470) call helper_set_current_project() in validate(). That function not only sets the current project for the request, it also sets the project cookie via gpc_set_cookie() – on every call.

This has two visible effects:

  1. REST API: GET /api/rest/projects runs CategoryGetCommand once per project (via mci_project_get() → mci_project_categories()), so the response carries one Set-Cookie: MANTIS_PROJECT_COOKIE=<id> header per visible project. With 27 projects the response headers grew to about 4.1 KB, which exceeds nginx's default proxy_buffer_size of 4k. Behind an nginx reverse proxy the request then failed with 502 – upstream sent too big header (intermittently, as the header size varied by a few bytes around the limit).
  2. Web UI: manage_proj_page.php runs CategoryGetCommand for ALL_PROJECTS, manage_proj_edit_page.php for the edited project. Opening Manage Projects therefore silently switches the user's selected project to All Projects, opening a project's edit page switches it to that project. 2.28 did not do this.

The only thing the commands need the current project for is config_get( 'manage_project_threshold' ) without a project parameter in Add/Update/Delete. Passing the project explicitly – as done for update_readonly_bug_threshold in the fix for 0037460 – makes the call to helper_set_current_project() unnecessary. $g_project_override would not be a good fit, as mci_project_get() runs the command in a loop.

PR with fix and unit test will follow.

Steps To Reproduce
curl -s -D - -o /dev/null -H "Authorization: Bearer <token>" https://<mantis>/api/rest/projects | grep -c MANTIS_PROJECT_COOKIE

Result: one line per visible project (expected: 0).

Web UI: select a specific project, open Manage > Manage Projects – the project selector now shows All Projects.

Additional Information

Verified on our 2.29.0 instance: with the patch applied the curl command returns 0 and the project selection is preserved on the Manage pages.

TagsNo tags attached.

Relationships

related to 0032470 closedvboctor REST API: Project Category Add/Update/Delete 
related to 0037460 closedcommunity Adding a note to a read-only issue is denied when "All Projects" is selected, although allowed by the project's threshold 

Activities

dombn

dombn

2026-11-30 04:17

reporter   ~0071643

PR: https://github.com/mantisbt/mantisbt/pull/2317 (against master-2.29)

Removes helper_set_current_project() from the four category commands and reads manage_project_threshold for the command's project. Includes a unit test checking that none of the commands changes the current project; CI passes on all PHP/DB combinations.

dregad

dregad

2026-11-30 08:39

developer   ~0071645

Thanks for the report and PR, we'll look into it.