Commit cd1c7e05 authored by Alex Hanselka's avatar Alex Hanselka

Merge branch '11-9-stable-prepare-rc10' into '11-9-stable'

Prepare 11.9.0-rc10 release

See merge request gitlab-org/gitlab-ce!26379
parents 8436b72f 5eb153ed
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
<div class="note-actions-item"> <div class="note-actions-item">
<gl-button <gl-button
ref="button" ref="button"
v-gl-tooltip.bottom v-gl-tooltip
class="note-action-button" class="note-action-button"
variant="transparent" variant="transparent"
:title="__('Reply to comment')" :title="__('Reply to comment')"
......
---
title: Gracefully handles excluded fields from attributes during serialization on
JsonCache
merge_request: 26368
author:
type: fixed
---
title: 'GitHub import: Create new branches as project owner'
merge_request: 26335
author:
type: fixed
...@@ -86,6 +86,11 @@ by another folder with the next 2 characters. They are both stored in a special ...@@ -86,6 +86,11 @@ by another folder with the next 2 characters. They are both stored in a special
### Hashed object pools ### Hashed object pools
CAUTION: **Beta:**
Hashed objects pools are considered beta, and are not ready for production use.
Follow [gitaly#1548](https://gitlab.com/gitlab-org/gitaly/issues/1548) for
updates.
For deduplication of public forks and their parent repository, objects are pooled For deduplication of public forks and their parent repository, objects are pooled
in an object pool. These object pools are a third repository where shared objects in an object pool. These object pools are a third repository where shared objects
are stored. are stored.
......
...@@ -89,7 +89,7 @@ module Gitlab ...@@ -89,7 +89,7 @@ module Gitlab
return if project.repository.branch_exists?(source_branch) return if project.repository.branch_exists?(source_branch)
project.repository.add_branch(merge_request.author, source_branch, pull_request.source_branch_sha) project.repository.add_branch(project.owner, source_branch, pull_request.source_branch_sha)
rescue Gitlab::Git::CommandError => e rescue Gitlab::Git::CommandError => e
Gitlab::Sentry.track_acceptable_exception(e, Gitlab::Sentry.track_acceptable_exception(e,
extra: { extra: {
......
...@@ -80,8 +80,23 @@ module Gitlab ...@@ -80,8 +80,23 @@ module Gitlab
# when the new_record? method incorrectly returns false. # when the new_record? method incorrectly returns false.
# #
# See https://gitlab.com/gitlab-org/gitlab-ee/issues/9903#note_145329964 # See https://gitlab.com/gitlab-org/gitlab-ee/issues/9903#note_145329964
attributes = klass.attributes_builder.build_from_database(raw, {}) klass
klass.allocate.init_with("attributes" => attributes, "new_record" => new_record?(raw, klass)) .allocate
.init_with(
"attributes" => attributes_for(klass, raw),
"new_record" => new_record?(raw, klass)
)
end
def attributes_for(klass, raw)
# We have models that leave out some fields from the JSON export for
# security reasons, e.g. models that include the CacheMarkdownField.
# The ActiveRecord::AttributeSet we build from raw does know about
# these columns so we need manually set them.
missing_attributes = (klass.columns.map(&:name) - raw.keys)
missing_attributes.each { |column| raw[column] = nil }
klass.attributes_builder.build_from_database(raw, {})
end end
def new_record?(raw, klass) def new_record?(raw, klass)
......
...@@ -273,6 +273,11 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi ...@@ -273,6 +273,11 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
mr.state = 'opened' mr.state = 'opened'
mr.save mr.save
# Ensure the project owner is creating the branches because the
# merge request author may not have access to push to this
# repository.
allow(project.repository).to receive(:add_branch).with(project.owner, anything, anything).and_call_original
importer.insert_git_data(mr, exists) importer.insert_git_data(mr, exists)
expect(project.repository.branch_exists?(mr.source_branch)).to be_truthy expect(project.repository.branch_exists?(mr.source_branch)).to be_truthy
......
...@@ -7,7 +7,7 @@ describe Gitlab::JsonCache do ...@@ -7,7 +7,7 @@ describe Gitlab::JsonCache do
let(:namespace) { 'geo' } let(:namespace) { 'geo' }
let(:key) { 'foo' } let(:key) { 'foo' }
let(:expanded_key) { "#{namespace}:#{key}:#{Rails.version}" } let(:expanded_key) { "#{namespace}:#{key}:#{Rails.version}" }
let(:broadcast_message) { create(:broadcast_message) } set(:broadcast_message) { create(:broadcast_message) }
subject(:cache) { described_class.new(namespace: namespace, backend: backend) } subject(:cache) { described_class.new(namespace: namespace, backend: backend) }
...@@ -321,6 +321,42 @@ describe Gitlab::JsonCache do ...@@ -321,6 +321,42 @@ describe Gitlab::JsonCache do
expect(result).to be_new_record expect(result).to be_new_record
end end
it 'gracefully handles bad cached entry' do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return('{')
expect(cache.read(key, BroadcastMessage)).to be_nil
end
it 'gracefully handles an empty hash' do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return('{}')
expect(cache.read(key, BroadcastMessage)).to be_a(BroadcastMessage)
end
it 'gracefully handles unknown attributes' do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return(broadcast_message.attributes.merge(unknown_attribute: 1).to_json)
expect(cache.read(key, BroadcastMessage)).to be_nil
end
it 'gracefully handles excluded fields from attributes during serialization' do
backend.write(expanded_key, broadcast_message.to_json)
result = cache.fetch(key, as: BroadcastMessage) { 'block result' }
excluded_fields = BroadcastMessage.cached_markdown_fields.html_fields
(excluded_fields + ['cached_markdown_version']).each do |field|
expect(result.public_send(field)).to be_nil
end
end
end end
it "returns the result of the block when 'as' option is nil" do it "returns the result of the block when 'as' option is nil" do
......
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