This reverts commit e62a85cf6f, reversing
changes made to 2660c2e21d.
This commit is contained in:
Jeff Atwood
2020-05-22 20:25:56 -07:00
parent e62a85cf6f
commit 20780a1eee
236 changed files with 717 additions and 1033 deletions

View File

@@ -65,10 +65,9 @@ module BackupRestore
return if !@is_archive
log "Unzipping archive, this may take a while..."
Discourse::Utils.execute_command(
'tar', '--extract', '--gzip', '--file', @archive_path, '--directory', @tmp_directory,
failure_message: "Failed to decompress archive."
)
pipeline = Compression::Pipeline.new([Compression::Tar.new, Compression::Gzip.new])
unzipped_path = pipeline.decompress(@tmp_directory, @archive_path, available_size)
pipeline.strip_directory(unzipped_path, @tmp_directory)
end
def extract_db_dump

View File

@@ -75,8 +75,6 @@ class DiscoursePluginRegistry
define_filtered_register :editable_group_custom_fields
define_filtered_register :topic_thumbnail_sizes
def self.register_auth_provider(auth_provider)
self.auth_providers << auth_provider
end

View File

@@ -266,6 +266,12 @@ class DiscourseRedis
end
end
def flushdb
DiscourseRedis.ignore_readonly do
keys.each { |k| del(k) }
end
end
def reconnect
@redis._client.reconnect
end

View File

@@ -79,35 +79,12 @@ module FileStore
def has_been_uploaded?(url)
return false if url.blank?
begin
parsed_url = URI.parse(URI.encode(url))
rescue URI::InvalidURIError
return false
end
base_hostname = URI.parse(absolute_base_url).hostname
if url[base_hostname]
# if the hostnames match it means the upload is in the same
# bucket on s3. however, the bucket folder path may differ in
# some cases, and we do not want to assume the url is uploaded
# here. e.g. the path of the current site could be /prod and the
# other site could be /staging
if s3_bucket_folder_path.present?
return parsed_url.path.starts_with?("/#{s3_bucket_folder_path}")
else
return true
end
return false
end
return true if url[base_hostname]
return false if SiteSetting.Upload.s3_cdn_url.blank?
cdn_hostname = URI.parse(SiteSetting.Upload.s3_cdn_url || "").hostname
return true if cdn_hostname.presence && url[cdn_hostname]
false
end
def s3_bucket_folder_path
@s3_helper.s3_bucket_folder_path
cdn_hostname.presence && url[cdn_hostname]
end
def s3_bucket_name

View File

@@ -164,7 +164,7 @@ module I18n
by_site[locale].with_indifferent_access
rescue ActiveRecord::StatementInvalid => e
if PG::UndefinedTable === e.cause || PG::UndefinedColumn === e.cause
if PG::UndefinedTable === e.cause
{}
else
raise

View File

@@ -493,10 +493,6 @@ class Guardian
is_staff?
end
def can_see_about_stats?
true
end
def auth_token
if cookie = request&.cookies[Auth::DefaultCurrentUserProvider::TOKEN_COOKIE]
UserAuthToken.hash_token(cookie)

View File

@@ -165,16 +165,6 @@ class Plugin::Instance
DiscoursePluginRegistry.register_editable_group_custom_field(field, self)
end
# Request a new size for topic thumbnails
# Will respect plugin enabled setting is enabled
# Size should be an array with two elements [max_width, max_height]
def register_topic_thumbnail_size(size)
if !(size.kind_of?(Array) && size.length == 2)
raise ArgumentError.new("Topic thumbnail dimension is not valid")
end
DiscoursePluginRegistry.register_topic_thumbnail_size(size, self)
end
def custom_avatar_column(column)
reloadable_patch do |plugin|
AvatarLookup.lookup_columns << column

View File

@@ -6,44 +6,33 @@ def plugin_initialization_guard(&block)
rescue => error
plugins_directory = Rails.root + 'plugins'
if error.backtrace && error.backtrace_locations
plugin_path = error.backtrace_locations.lazy.map do |location|
Pathname.new(location.absolute_path)
.ascend
.lazy
.find { |path| path.parent == plugins_directory }
end.next
plugin_path = error.backtrace_locations.lazy.map do |location|
Pathname.new(location.absolute_path)
.ascend
.lazy
.find { |path| path.parent == plugins_directory }
end.next
raise unless plugin_path
raise unless plugin_path
stack_trace = error.backtrace.each_with_index.inject([]) do |messages, (line, index)|
if index == 0
messages << "#{line}: #{error} (#{error.class})"
else
messages << "\t#{index}: from #{line}"
end
end.reverse.join("\n")
stack_trace = error.backtrace.each_with_index.inject([]) do |messages, (line, index)|
if index == 0
messages << "#{line}: #{error} (#{error.class})"
else
messages << "\t#{index}: from #{line}"
end
end.reverse.join("\n")
STDERR.puts <<~MESSAGE
#{stack_trace}
STDERR.puts <<~MESSAGE
#{stack_trace}
** INCOMPATIBLE PLUGIN **
** INCOMPATIBLE PLUGIN **
You are unable to build Discourse due to errors in the plugin at
#{plugin_path}
You are unable to build Discourse due to errors in the plugin at
#{plugin_path}
Please try removing this plugin and rebuilding again!
MESSAGE
else
STDERR.puts <<~MESSAGE
** PLUGIN FAILURE **
You are unable to build Discourse due to this error during plugin
initialization:
#{error}
MESSAGE
end
Please try removing this plugin and rebuilding again!
MESSAGE
exit 1
end
end

View File

@@ -374,10 +374,6 @@ class PostCreator
# discourse post.
def create_embedded_topic
return unless @opts[:embed_url].present?
original_uri = URI.parse(@opts[:embed_url])
raise Discourse::InvalidParameters.new(:embed_url) unless original_uri.is_a?(URI::HTTP)
embed = TopicEmbed.new(topic_id: @post.topic_id, post_id: @post.id, embed_url: @opts[:embed_url])
rollback_from_errors!(embed) unless embed.save
end

View File

@@ -567,7 +567,11 @@ class PostRevisor
end
def update_topic_excerpt
@topic.update_excerpt(@post.excerpt_for_topic)
excerpt = @post.excerpt_for_topic
@topic.update_column(:excerpt, excerpt)
if @topic.archetype == "banner"
ApplicationController.banner_json_cache.clear
end
end
def update_category_description

View File

@@ -22,7 +22,6 @@ task "bookmarks:sync_to_table" => :environment do |_t, args|
INNER JOIN posts ON posts.id = post_actions.post_id
LEFT JOIN bookmarks ON bookmarks.post_id = post_actions.post_id AND bookmarks.user_id = post_actions.user_id
INNER JOIN topics ON topics.id = posts.topic_id
INNER JOIN users ON users.id = post_actions.user_id
WHERE bookmarks.id IS NULL AND post_action_type_id = :type_id AND post_actions.deleted_at IS NULL AND posts.deleted_at IS NULL
LIMIT 2000
SQL

View File

@@ -3,7 +3,7 @@
module TopicQueryParams
def build_topic_list_options
options = {}
params[:tags] = [params[:tag_id]] if params[:tag_id].present? && guardian.can_tag_pms?
params[:tags] = [params[:tag_id].parameterize] if params[:tag_id].present? && guardian.can_tag_pms?
TopicQuery.public_valid_options.each do |key|
if params.key?(key)