mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
remove patches that have been upstreamed
clean up rails4 checks so they are consistent
This commit is contained in:
parent
00951e0578
commit
691377b5af
6 changed files with 23 additions and 77 deletions
|
@ -1,4 +1,4 @@
|
||||||
unless Rails.version =~ /^4/
|
unless rails4?
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
class Relation
|
class Relation
|
||||||
# Patch Rails 3 ActiveRecord::Relation to noop on Rails 4 references
|
# Patch Rails 3 ActiveRecord::Relation to noop on Rails 4 references
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
#see: https://github.com/rails/rails/pull/12065
|
|
||||||
if rails4?
|
|
||||||
module ActiveRecord
|
|
||||||
class Result
|
|
||||||
private
|
|
||||||
def hash_rows
|
|
||||||
@hash_rows ||=
|
|
||||||
begin
|
|
||||||
# We freeze the strings to prevent them getting duped when
|
|
||||||
# used as keys in ActiveRecord::Base's @attributes hash
|
|
||||||
columns = @columns.map { |c| c.dup.freeze }
|
|
||||||
@rows.map { |row|
|
|
||||||
# In the past we used Hash[columns.zip(row)]
|
|
||||||
# though elegant, the verbose way is much more efficient
|
|
||||||
# both time and memory wise cause it avoids a big array allocation
|
|
||||||
# this method is called a lot and needs to be micro optimised
|
|
||||||
hash = {}
|
|
||||||
|
|
||||||
index = 0
|
|
||||||
length = columns.length
|
|
||||||
|
|
||||||
while index < length
|
|
||||||
hash[columns[index]] = row[index]
|
|
||||||
index += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
hash
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,22 +0,0 @@
|
||||||
# see PR: https://github.com/rails/rails/pull/12185
|
|
||||||
#
|
|
||||||
class ActiveRecord::Associations::JoinDependency::JoinPart
|
|
||||||
|
|
||||||
def extract_record(row)
|
|
||||||
# Used to be: Hash[column_names_with_alias.map{|cn, an| [cn, row[an]]}]
|
|
||||||
# that is fairly inefficient cause all the values are first copied
|
|
||||||
# in to an array only to construct the Hash
|
|
||||||
# This code is performance critical as it is called per row.
|
|
||||||
hash = {}
|
|
||||||
|
|
||||||
index = 0
|
|
||||||
while index < column_names_with_alias.length do
|
|
||||||
cn,an = column_names_with_alias[index]
|
|
||||||
hash[cn] = row[an]
|
|
||||||
index += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
hash
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -10,27 +10,28 @@ class ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ActionView::Helpers::AssetTagHelper::AssetIncludeTag
|
unless rails4?
|
||||||
private
|
class ActionView::Helpers::AssetTagHelper::AssetIncludeTag
|
||||||
|
private
|
||||||
|
|
||||||
# pluralization is fairly expensive, and pluralizing the word javascript 400 times is pointless
|
# pluralization is fairly expensive, and pluralizing the word javascript 400 times is pointless
|
||||||
# this is fixed in Rails 4
|
# this is fixed in Rails 4
|
||||||
|
|
||||||
|
def path_to_asset(source, options = {})
|
||||||
|
asset_paths.compute_public_path(source, pluralize_asset_name(asset_name), options.merge(:ext => extension))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def path_to_asset_source(source)
|
||||||
|
asset_paths.compute_source_path(source, pluralize_asset_name(asset_name), extension)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def pluralize_asset_name(asset_name)
|
||||||
|
@@pluralization_cache ||= {}
|
||||||
|
plural = @@pluralization_cache[asset_name] ||= asset_name.to_s.pluralize
|
||||||
|
end
|
||||||
|
|
||||||
def path_to_asset(source, options = {})
|
|
||||||
asset_paths.compute_public_path(source, pluralize_asset_name(asset_name), options.merge(:ext => extension))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def path_to_asset_source(source)
|
|
||||||
asset_paths.compute_source_path(source, pluralize_asset_name(asset_name), extension)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def pluralize_asset_name(asset_name)
|
|
||||||
@@pluralization_cache ||= {}
|
|
||||||
plural = @@pluralization_cache[asset_name] ||= asset_name.to_s.pluralize
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
unless Rails.version =~ /^4/
|
unless rails4?
|
||||||
module HTML
|
module HTML
|
||||||
class WhiteListSanitizer
|
class WhiteListSanitizer
|
||||||
# Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute
|
# Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute
|
||||||
|
|
|
@ -97,7 +97,7 @@ module RailsMultisite
|
||||||
# see: https://github.com/rails/rails/issues/8344#issuecomment-10800848
|
# see: https://github.com/rails/rails/issues/8344#issuecomment-10800848
|
||||||
#
|
#
|
||||||
@@default_connection_handler = ActiveRecord::Base.connection_handler
|
@@default_connection_handler = ActiveRecord::Base.connection_handler
|
||||||
ActiveRecord::Base.send :include, NewConnectionHandler
|
ActiveRecord::Base.send :include, NewConnectionHandler if ActiveRecord::VERSION::MAJOR == 3
|
||||||
ActiveRecord::Base.connection_handler = @@default_connection_handler
|
ActiveRecord::Base.connection_handler = @@default_connection_handler
|
||||||
@@connection_handlers = {}
|
@@connection_handlers = {}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue