Commit 662f8af4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'fix-cache-key-expiration-for-commits' into 'master'

Fix bug where transferring a project would result in stale commit links

Transferring a project to another namespace updates the project's updated_at
field, but since the cache key did not depend on the object, the page fragments
were not invalidated. This resulted in stale links to the commits. Changing
the cache key to use the project pathname solves this issue.

Closes gitlab-org/omnibus-gitlab#843

See merge request !1497
Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased)
- Fix bug where transferring a project would result in stale commit links (Stan Hu)
- Include full path of source and target branch names in New Merge Request page (Stan Hu)
- Fix Message-ID header to be RFC 2111-compliant to prevent e-mails being dropped (Stan Hu)
- Add user preference to view activities as default dashboard (Stan Hu)
......@@ -296,7 +296,7 @@ def last_push_event
def readme_cache_key
sha = @project.commit.try(:sha) || 'nil'
[, sha, "readme"].join('-')
[@project.path_with_namespace, sha, "readme"].join('-')
def round_commit_count(project)
......@@ -5,7 +5,7 @@
- note_count = notes.user.count
- ci_commit = project.ci_commit(commit.sha)
- cache_key = [,, note_count]
- cache_key = [project.path_with_namespace,, note_count]
- cache_key.push(ci_commit.status) if ci_commit
= cache(cache_key) do
......@@ -61,13 +61,13 @@
it "returns a valid cach key" do
expect(helper.send(:readme_cache_key)).to eq("#{}-#{}-readme")
expect(helper.send(:readme_cache_key)).to eq("#{project.path_with_namespace}-#{}-readme")
it "returns a valid cache key if HEAD does not exist" do
allow(project).to receive(:commit) { nil }
expect(helper.send(:readme_cache_key)).to eq("#{}-nil-readme")
expect(helper.send(:readme_cache_key)).to eq("#{project.path_with_namespace}-nil-readme")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment