| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Make collection caching explicit.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Augments the collection caching with some instrumentation that's logged.
For collections that have been cached like:
```ruby
<%= render partial: 'notifications/notification', collection: @notifications, cached: true %>
```
We'll output a line showing how many cache hits we had when rendering it:
```
Rendered collection of notifications/_notification.html.erb [0 / 100 cache hits] (3396.5ms)
```
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Having collection caching that wraps templates and automatically tries
to infer if they are cachable proved to be too much of a hassle.
We'd rather have it be something you explicitly turn on.
This removes much of the code and docs to explain the previous automatic
behavior.
This change also removes scoped cache keys and passing cache_options.
|
|\ \
| |/
|/| |
Fix button_to's params option to support nested names.
|
| |
| |
| |
| |
| |
| | |
In e6e0579defcfcf94ef1c4c1c7659f374a5335cdb the `params` option was added to the `button_to` helper. However, the patch doesn't support nested hashes so `{a: {b: 'c'}}` for example gets turned into a hidden form input with the name 'a' and the value being the string representation of the `{b: 'c'}` nested hash.
Since Rails supports nested hashes everywhere else (and even in the URL params of link_to and button_to), I believe this to be a bug/unfinished feature.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This moves digest calculation cache on to the details key object.
Before, the digest cache was a class level ivar, and one of the keys was
the hash value of the details key object:
https://github.com/rails/rails/blob/13c4cc3b5aea02716b7459c0da641438077f5236/actionview/lib/action_view/digestor.rb#L28
An object's hash value is not unique, so it's possible for this cache
key to produce colliding keys with no resolution. This commit move
cache on to the details key object itself, so we know that the digests
are always unique per details key object.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
I don't think caching this method makes any difference on Ruby 2.0:
```
require 'benchmark/ips'
class Foo
alias :object_hash :hash
attr_reader :hash
def initialize
@hash = object_hash
end
end
class Bar
end
hash = {}
foo = Foo.new
bar = Bar.new
Benchmark.ips do |x|
x.report("foo") { hash[foo] }
x.report("bar") { hash[bar] }
x.report("foo.hash") { foo.hash }
x.report("bar.hash") { bar.hash }
end
__END__
[aaron@TC ruby (trunk)]$ ruby test.rb
Warming up --------------------------------------
foo 118.361k i/100ms
bar 118.637k i/100ms
Calculating -------------------------------------
foo 7.944M (± 3.1%) i/s - 39.769M
bar 7.931M (± 3.4%) i/s - 39.625M
[aaron@TC ruby (trunk)]$ ruby test.rb
Warming up --------------------------------------
foo 122.180k i/100ms
bar 120.492k i/100ms
foo.hash 123.397k i/100ms
bar.hash 119.312k i/100ms
Calculating -------------------------------------
foo 8.002M (± 4.2%) i/s - 39.953M
bar 8.037M (± 4.5%) i/s - 40.124M
foo.hash 8.819M (± 3.9%) i/s - 44.053M
bar.hash 7.856M (± 4.1%) i/s - 39.254M
```
|
|\ \
| | |
| | | |
WIP: Errors in logs should show log tags as well.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- Changed formatted_code_for to return array of logs to be tagged for each line
- Changed some render tests to match new behaviour of return
Fixes #22979
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| | |
if data attribute is nil it is ignored
if value is nil the pair is ignored
if value is nil it is skipped
Improved test for data attr nil
|
| |
| |
| |
| |
| |
| |
| | |
this lets us leverage Ruby's kwarg handling (exceptions for missing
params, etc) ASAP which allows us to skip active support method calls
and make sure the exception stack is closer to where the user called the
methods.
|
| |
| |
| |
| |
| |
| |
| | |
If the collection isn't empty any? will loop through it.
Spare the loop and be more concise with what we're asking the
collection about.
|
| |
| |
| |
| |
| |
| | |
`PartialRenderer.render_collection_with/without_template` returns an array
of rendered partials. Avoid dup'ing and shifting it by indexing into
the collection instead.
|
| |
| |
| |
| | |
Wasn't pulling its weight for a simple yield anymore.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Moves us closer to having access to a local template variable,
we can ask for eligibility and its virtual_path.
Currently we rely on `@template`, which we don't have available
when rendering collections without a fixed template.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A callable cache key writes to the collection cache under a certain namespace.
Which means if we don't have scoped cache key we can just rely on the
`cache model_name do` in the templates to cache them.
Less writes, more sharing.
Add `assert_customer_cached` to better illustrate this in tests, and remove
tests which then don't communicate as much.
|
| |
| |
| |
| |
| |
| | |
`automatic_cache_eligible?´ is only called if there was no `:cache` key
to fetch in the `@options` via `cache_collection?`. So the check will
always be false.
|
| |
| |
| |
| |
| |
| | |
Written when I didn't understand the internals as well. Action View
generally just refers to `@template` when meaning a fixed template
render. So follow that implicit convention.
|
| |
| |
| |
| |
| |
| | |
We should only support a top level `cache_options`. We also don't
have to default the options to a hash as Active Support's cache
defaults that arg to nil.
|
|/
|
|
|
| |
we can use kwargs in this case to avoid values_at and except calls on
the options hash
|
|
|
|
|
|
| |
This metaprogrammed method doesn't seem to be a bottleneck, so lets just
use a regular method so it's easier to understand. We can follow up
with more interesting techniques for cache manipulation soon.
|
|
|
|
| |
Wasn't removed in 57ac777.
|
| |
|
| |
|
|
|
|
| |
then we can stop scattering nil checks (e.g. `try`) through the class.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The view paths cache will eventually query the filesystem when looking
up templates:
https://github.com/rails/rails/blob/2db347bebc9d3f39b3c5e274b7c9beecfce73913/actionview/lib/action_view/template/resolver.rb#L224-L230
The order in which files are returned is file system dependent. Since
the template digest [depends on its children](https://github.com/rails/rails/blob/2db347bebc9d3f39b3c5e274b7c9beecfce73913/actionview/lib/action_view/digestor.rb#L109-L115), the order of the dependencies will impact the fingerprint.
This commit sorts the wildcard dependencies so that we get a consistent
hash.
Fixes #23592
|
|
|
|
|
|
|
|
|
| |
If we check the conditional at registration time, then we can avoid the
conditional at runtime. This commit checks for view path support when
the handler is registered so that runtime calls to `find_dependencies`
won't need to check the conditional. The idea is that
`register_tracker` is called only once where `find_dependencies` may be
called many times.
|
|\
| |
| | |
Fix edge case with ActionView::Template::Error reraise
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When you re-raise an ActionView::Template::Error, the #cause can change.
You can see this behaviour with [nack]. Currently, `web-console` doesn't
run the console in the proper binding in the case of errors in the
views, because when we follow the `#cause` of the exception it is an
[`EOFError`][EOFError].
This also affects [pow] as it runs on [nack].
[nack]: https://github.com/josh/nack
[pow]: http://pow.cx/
[EOFError]: https://github.com/josh/nack/blob/d523cc870c0a11dcf349388a15adfecba9314f97/lib/nack/server.rb#L108
|
| | |
|
| |
| |
| |
| | |
This allows expire_in (and other options) to be passed to the cache method
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* 5-0-beta-sec:
bumping version
fix version update task to deal with .beta1.1
Eliminate instance level writers for class accessors
allow :file to be outside rails root, but anything else must be inside the rails view directory
Don't short-circuit reject_if proc
stop caching mime types globally
use secure string comparisons for basic auth username / password
|
| | | |
|
| |/
| |
| |
| |
| |
| | |
rails view directory
CVE-2016-0752
|
| |
| |
| |
| |
| |
| | |
of html_safe in favour of raw() in AV helpers.
Also changed usage of html_safe to make use of raw() instead so that the intended behaviour is verified with raw()
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A Set can't be implicitly converted into an Array:
```
irb(main):012:0> formats = [ :rss ]
=> [:rss]
irb(main):013:0> formats &= SET.symbols
TypeError: no implicit conversion of Set into Array
from (irb):13:in `&'
from (irb):13
from /Users/kasperhansen/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
```
Besides `Mime::SET.symbols` returns an Array, so we're closer to that.
|
| |
| |
| |
| | |
Match `Mime::SET.symbols`.
|
| |
| |
| |
| | |
If they aren't symbols, then they aren't likely to be in the set anyway.
|
| |
| |
| |
| | |
We'll be using this to map over to Action Dispatch's Mime::Set.
|
| |
| |
| |
| |
| | |
The template types is a private abstraction to fill in basic blanks from Action Dispatch's
mime types. As such we can modify the data structure ourselves.
|
| |
| |
| |
| |
| |
| | |
Spares a to_sym call by aliasing to_sym to ref.
Then the delegate felt meager for one method; ditch and define method ourselves.
|
| |
| |
| |
| |
| |
| |
| | |
The @symbol has already been converted to a symbol in initialize, so no need to call to_sym
when comparing it.
Ditch early return for a simple unless statement.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We delegate to_sym to the internal symbol, which we've already called to_sym on in
initialize, so we don't need to do that.
We also know to_sym will never return a falsy value, so we'll never hit to_s.
Just return the symbolized symbol.
|
|\ \
| | |
| | |
| | | |
Use ActiveSupport::SafeBuffer when flushing content_for
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously, when content_for is flushed, the content
was replaced directly by a new value in
ActionView::OutputFlow#set. The problem is this new
value passed to the method may not be an instance of
ActiveSupport::SafeBuffer.
This change forces the value to be set to a new
instance of ActiveSupport::SafeBuffer.
|
|\ \ \
| | | |
| | | | |
Pass the current locale to Inflector from the pluralize text helper.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The pluralize text helper uses the Inflector to determine the plural
form. The inflector accepts an optional parameter for the locale,
so we can pass it from the text helper to have locale-aware pluralizations
on the text helpers level.
The pluralize text helper now only accepts 2 positional arguments:
`count` and `singular`. Passing `plural` as a positional argument
is now deprecated.
|