Defect #44257
openWiki page "Rename" form does not refresh "Parent page" options when "Project" is changed
Description
Hey Team, I have a possible bug for your consideration. I'd be happy to work on a patch with a little direction, Redmine has been a great project.
On the wiki page rename/move form (/wiki/<page>/rename), changing the Project dropdown (wiki_page[wiki_id]) is supposed to refresh the Parent page dropdown (wiki_page[parent_id]) to show pages belonging to the newly selected project, via an AJAX call. In practice, nothing happens: the Parent page list keeps showing pages from the original project no matter what you select in Project.
Expected behavior¶
Changing "Project" on the rename form updates "Parent page" to list pages belonging to the newly selected project's wiki.
Actual behavior¶
The "Parent page" list never changes. If you actually submit the form after switching projects, the previously-selected parent page (which
belongs to the old project's wiki) is either silently dropped or produces an inconsistent parent/child relationship across projects.
Steps to reproduce¶
- Create (or use) a project with a wiki containing at least one page with children, and a second project with its own wiki.
- Go to a wiki page and click Rename.
- Open browser devtools → Network tab.
- Change the "Project" dropdown to the other project.
- Observe: the "Parent page" dropdown does not update, and the AJAX request fired for this change fails or returns nothing usable (see
- root cause below).
Root cause¶
Looking at app/views/wiki/rename.html.erb:
$('#wiki_page_wiki_id').change(function() {
$.ajax({
url: '<%= rename_project_wiki_page_path(@wiki, :format => 'js') %>',
type: 'get',
data: { 'wiki_page[wiki_id]': $('#wiki_page_wiki_id').val() }
});
});
This handler has no success/error callback. It appears to rely on the Rails convention where a format.js response is a literal snippet of JavaScript that jQuery auto-evals. All the actual DOM-update logic would have to live in the response body itself.
For that to work, two things are needed and neither appears to exist:
WikiController#rename has no respond_to block:
def rename
return render_403 unless editable?
@page.redirect_existing_links = true
@original_title = @page.pretty_title
@page.safe_attributes = params[:wiki_page]
if request.post? && @page.save
flash[:notice] = l(:notice_successful_update)
redirect_to project_wiki_page_path(@page.project, @page.title)
end
end
On a GET request with format=js (which is what the AJAX call sends), this falls through to Rails' implicit-render lookup for rename.js.erb. app/views/wiki/rename.js.erb does not appear to exist anywhere in app/views/wiki/ — only rename.html.erb is present.
Separately, the "Parent page" <select> options are built once at initial page load from @wiki.pages, where @wiki is resolved via the find_wiki before_action from the page's original project — not from whatever gets selected afterward in the Project dropdown. The AJAX call's entire purpose is clearly to refresh that list against the newly chosen project, but with no working response handling, that refresh never happens.
Environment: Redmine version 6.0.7.stable Ruby version 3.3.7-p123 (2025-01-15) [x86_64-linux] Rails version 7.2.2.2 Environment production Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::SidekiqAdapter Mailer delivery sendmail Redmine settings: Redmine theme Circle-6.0 (includes JavaScript) SCM: Subversion 1.14.5 Git 2.50.1 Filesystem Redmine plugins:
Also tested in the latest docker container using this docker-compose.yml with identical result:
services:
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: redmine
POSTGRES_USER: redmine
POSTGRES_PASSWORD: secret_password
volumes:
- pg_data:/var/lib/postgresql/data
redmine:
image: redmine:latest
ports:
- "8080:3000"
environment:
REDMINE_DB_POSTGRES: db
REDMINE_DB_DATABASE: redmine
REDMINE_DB_USERNAME: redmine
REDMINE_DB_PASSWORD: secret_password
depends_on:
- db
volumes:
- redmine_data:/usr/src/redmine/files
volumes:
pg_data:
redmine_data:
Thank you kindly for your consideration.
No data to display