Commit Graph

32788 Commits

Author SHA1 Message Date
Rafael Mendonça França 91363ec529 Merge pull request #7653 from arunagw/warnings-removed
Few more warnings removed.
2012-09-15 03:27:14 -07:00
Jon Leighton c46208c2aa simplify rescue 2012-09-15 10:44:12 +01:00
Arun Agrawal ff04bb84e1 Few more warnings removed.
I found them when I was running
warning mode on with railties

See https://github.com/rails/rails/pull/3782
2012-09-15 14:26:04 +05:30
Steve Klabnik ed2fea908a Deprecate ActiveSupport::Benchmarkable#silence.
Due to its lack of thread safety, we're deprecating this, and it
will be removed in Rails 4.1.

Fixes #4060.
2012-09-15 06:19:55 +04:00
Jon Leighton 60c88e64e2 Fix test
Accidentally checked in commented test code. Fail. >_<
2012-09-15 00:41:56 +01:00
Jon Leighton 02f56554d6 Ensure disconnecting or reconnecting resets the transaction state 2012-09-15 00:03:04 +01:00
Jon Leighton 6195142790 Remove our use of #outside_transaction?
This method was first seen in 045713ee24,
and subsequently reimplemented in
fb2325e358.

According to @jeremy, this is okay to remove. He thinks it was added
because at the time we didn't have much transaction state to keep track
of, and he viewed it as a hack for us to track it internally, thinking
it was better to ask the connection for the transaction state.

Over the years we have added more and more state to track, a lot of
which is impossible to ask the connection for. So it seems that this is
just a relic of the passed and we will just track the state internally
only.
2012-09-15 00:02:59 +01:00
Jon Leighton 748052a99b Remove the transaction_open variable 2012-09-15 00:00:50 +01:00
Jon Leighton 280587588a Move transaction joinability into the transaction object 2012-09-15 00:00:50 +01:00
Jon Leighton a6fbddb7be Alter the naming structure a bit 2012-09-15 00:00:50 +01:00
Jon Leighton 6d9e6b3a80 Split Open into Real and Savepoint 2012-09-15 00:00:50 +01:00
Jon Leighton dd48f0ea4c DRY 2012-09-15 00:00:50 +01:00
Jon Leighton 58ced308d7 Don't do the rollback in #commit
The caller needs to have knowledge of the rollback either way, so do it
all in the caller (#transaction)
2012-09-15 00:00:50 +01:00
Jon Leighton 9296e6939b Store the transaction number in the transaction object
This avoids us having to manually increment and decrement it.
2012-09-15 00:00:50 +01:00
Jon Leighton 02f25a226f Start to tease out transaction handling into a state machine 2012-09-15 00:00:50 +01:00
Jon Leighton b89ffe7f00 Revert "create a transaction object and point AR objects at that object during a"
This reverts commit c24c885209.

Here's the explanation I just sent to @tenderlove:

Hey,

I've been thinking about about the transaction memory leak thing that we
were discussing.

Example code:

post = nil
Post.transaction do
  N.times { post = Post.create }
end

Post.transaction is going to create a real transaction and there will
also be a (savepoint) transaction inside each Post.create.

In an idea world, we'd like all but the last Post instance to be GC'd,
and for the last Post instance to receive its after_commit callback when
Post.transaction returns.

I can't see how this can work using your solution where the Post itself
holds a reference to the transaction it is in; when Post.transaction
returns, control does not switch to any of Post's instance methods, so
it can't trigger the callbacks itself.

What we really want is for the transaction itself to hold weak
references to the objects within the transaction. So those objects can
be GC'd, but if they are not GC'd then the transaction can iterate them
and execute their callbacks.

I've looked into WeakRef implementations that are available. On 1.9.3,
the stdlib weakref library is broken and we shouldn't use it.

There is a better implementation here:

https://github.com/bdurand/ref/blob/master/lib/ref/weak_reference/pure_ruby.rb

We could use that, either by pulling in the gem or just copying the code
in, but it still suffers from the limitation that it uses ObjectSpace
finalizers.

In my testing, this finalizers make GC quite expensive:
https://gist.github.com/3722432

Ruby 2.0 will have a native WeakRef implementation (via
ObjectSpace::WeakMap), hence won't be reliant on finalizers:
http://bugs.ruby-lang.org/issues/4168

So the ultimate solution will be for everyone to use Ruby 2.0, and for
us to just use ObjectSpace::WeakMap.

In the meantime, we have basically 3 options:

The first is to leave it as it is.

The second is to use a finalizer-based weakref implementation and take
the GC perf hit.

The final option is to store object ids rather than the actual objects.
Then use ObjectSpace._id2ref to deference the objects at the end of the
transaction, if they exist. This won't stop memory use growing within
the transaction, but it'll grow more slowly.

I benchmarked the performance of _id2ref this if the object does or does
not exist: https://gist.github.com/3722550

If it does exist it seems decent, but it's hugely more expensive if it
doesn't, probably because we have to do the rescue nil.

Probably most of the time the objects will exist. However the point of
doing this optimisation is to allow people to create a large number of
objects inside a transaction and have them be GC'd. So for that use
case, we'd be replacing one problem with another. I'm not sure which of
the two problems is worse.

My feeling is that we should just leave this for now and come back to it
when Ruby 2.0 is out.

I'm going to revert your commit because I can't see how it solves this.
Hope you don't mind... if I've misunderstood then let me know!

Jon
2012-09-15 00:00:50 +01:00
Santiago Pastorino 8577687fcb Move queue classes to ActiveSupport 2012-09-14 14:10:00 -07:00
José Valim ae00adecf4 Merge pull request #7642 from lest/patch-1
update CHANGELOG
2012-09-14 07:50:35 -07:00
Sergey Nartimov 23851290dc update CHANGELOG
Add entry about 245941101b and
95be790ece.
2012-09-14 18:48:30 +04:00
Dan McClain 4544d2bc90 Moves column dump specific code to a module included in AbstractAdapter
Having column related schema dumper code in the AbstractAdapter. The
code remains the same, but by placing it in the AbstractAdapter, we can
then overwrite it with Adapter specific methods that will help with
Adapter specific data types.

The goal of moving this code here is to create a new migration key for
PostgreSQL's array type. Since any datatype can be an array, the goal is
to have ':array => true' as a migration option, turning the datatype
into an array. I've implemented this in postgres_ext, the syntax is
shown here: https://github.com/dockyard/postgres_ext#arrays

Adds array migration support

Adds array_test.rb outlining the test cases for array data type
Adds pg_array_parser to Gemfile for testing
Adds pg_array_parser to postgresql_adapter (unused in this commit)

Adds schema dump support for arrays

Adds postgres array type casting support

Updates changelog, adds note for inet and cidr support, which I forgot to add before

Removing debugger, Adds pg_array_parser to JRuby platform

Removes pg_array_parser requirement, creates ArrayParser module used by
PostgreSQLAdapter
2012-09-14 08:43:47 -04:00
José Valim 84ba499b16 Merge pull request #7635 from arunagw/warning_removed_shadowing_variable
warning removed: shadowing outer local variable - message
2012-09-14 01:00:52 -07:00
José Valim 40937fe519 Merge pull request #7634 from arunagw/build_fix_actionmailer
Build fix for ActionMailer
2012-09-14 01:00:23 -07:00
Jeremy Kemper e1af54d352 Merge pull request #7637 from NARKOZ/patch-3
use presence method instead of checking for blank
2012-09-13 22:52:06 -07:00
Nihad Abbasov 6927fadbe7 use presence method instead of checking for blank 2012-09-14 11:47:22 +06:00
Arun Agrawal 948a055f23 warning removed: shadowing outer local variable - message 2012-09-14 10:19:10 +05:30
Arun Agrawal 5138a303e4 Build fix for ActionMailer
See

http://travis-ci.org/#!/rails/rails/jobs/2444632
2012-09-14 10:15:18 +05:30
Michael Koziarski bb732beba7 Merge pull request #7616 from lest/null-session-forgery-protection
Implement :null_session CSRF protection method
2012-09-13 20:44:45 -07:00
Rafael Mendonça França 0247443deb Merge pull request #7628 from Pranas/deep_merge_with_block
Allow passing block to deep_merge and deep_merge!
2012-09-13 13:07:49 -07:00
Pranas Kiziela 54575d8797 Allow passing block to deep_merge and deep_merge!
Hash#merge accepts block that you can use to customize how hash values
are merged. This change makes merge and deep_merge compatible.
2012-09-13 23:01:18 +03:00
Rafael Mendonça França 8692db59af Copy-edit deprecation relared documentation [ci skip] 2012-09-13 14:02:18 -03:00
Rafael Mendonça França 1726a94900 Merge pull request #7524 from al2o3cr/store_boolean
Add boolean type conversion for AR::Store
2012-09-13 07:17:33 -07:00
Matt Jones 46873aeded refactor store_accessor 2012-09-13 10:12:11 -04:00
Carlos Antonio da Silva 01ef633f75 Merge pull request #6348 from LTe/no_global_depreactations
Allow ActiveSupport::Deprecation features to be used by rails applications and library authors
2012-09-13 04:47:03 -07:00
Sergey Nartimov 95be790ece Implement :null_session CSRF protection method
It's further work on CSRF after 245941101b.

The :null_session CSRF protection method provide an empty session during
request processing but doesn't reset it completely (as :reset_session
does).
2012-09-13 12:07:37 +03:00
Piotr Niełacny 71993c6f97 Change ActiveSupport::Deprecation to class.
ActiveSupport::Deprecation is now a class rather than a module. You can
get instance of ActiveSupport::Deprecation calling #instance method.

  ActiveSupport::Deprecation.instance

But when you need to get new object od ActiveSupport::Deprecation you
need to just call #new.

  @instance = ActiveSupport::Deprecation.new

Since you can create a new object, you can change the version and the
name of the library where the deprecator concerned.

  ActiveSupport::Deprecation.new('2.0', 'MyGem')

If you need use another deprecator instance you can select it in the
options of deprecate method.

  deprecate :method, :deprecator => deprecator_instance

Documentation has been updated.
2012-09-13 08:42:00 +02:00
Robert Pankowecki 2c690a0f5b extend ActiveSupport::Deprecation with self, allow other objects to extend/include it also.
test local deprecation

deprecator object

Test ActiveSupport::Deprecation when included
2012-09-13 08:42:00 +02:00
Rafael Mendonça França c4b857299b Merge pull request #7623 from tchandy/master
update ConnectionAdapter::Column#type_cast_code to be compatible with rails 3.2 branch
2012-09-12 20:35:40 -07:00
Thiago Pradi d4b3fdb003 update ConnectionAdaptar::Column#type_cast_code to be compatible with 3.2 branch 2012-09-13 00:26:52 -03:00
Rafael Mendonça França 9641cdd884 Merge pull request #7614 from frodsan/scm_agnostic
add --skip-ignore and --skip-keeps options to generators.
2012-09-12 18:37:48 -07:00
Derek Prior ceb05bd1b2 change app/plugin generators to be more SCM agnostic
Users of other SCM's can now generate rails
apps that will add the "empty" directories to source control,
but will not have a useless .gitignore or mis-named .gitkeep
files.

* Change `rails new` and `rails plugin new` generators to name
  the `.gitkeep` as `.keep` in a more SCM-agnostic way.

* Change `--skip-git` option to only skip the `.gitignore` file
  and still generate the `.keep` files.

* Add `--skip-keeps` option to skip the `.keep` files.

It closes #2800.
2012-09-12 20:36:00 -05:00
Jon Leighton e55c75d2d8 Pass in the model class rather than engine
In some circumstances engine was Arel::Table.engine which for separate
reasons was an ActiveRecord::Model::DeprecationProxy, which caused a
deprecation warning.

In any case, we want the actual model class here, since we want to use
it to infer information about associations.
2012-09-13 00:14:36 +01:00
Jon Leighton e588c98035 Refactor to remove some duplication 2012-09-12 23:51:30 +01:00
Jon Leighton eb4a623d74 Fix nested association references
Previously the reflection would be looked up on the wrong class. However
the test passed because the examples referred back to themselves.
2012-09-12 23:32:50 +01:00
Jon Leighton b5aed34c44 Merge pull request #7273 from beerlington/foreign_key_model_queries
Convert model name to foreign key in queries
2012-09-12 14:04:11 -07:00
Carlos Antonio da Silva 0f228b420e Merge pull request #7622 from marcandre/doc
Update documentation for CollectionProxy [ci skip]
2012-09-12 12:02:08 -07:00
Marc-Andre Lafortune 38886f3ed1 Update documentation for CollectionProxy 2012-09-12 14:54:44 -04:00
Rafael Mendonça França 85d8b22a71 Remove the queue configuration from the environments templates since the
default is the SynchronousQueue.
2012-09-12 15:54:06 -03:00
Rafael Mendonça França a25b5f683d Updating the documentation to ActionMailer::Base.queue 2012-09-12 15:50:46 -03:00
Rafael Mendonça França d0c25f253f Define a SynchronousQueue for test in Action Pack.
We don't need to rely on rails/queueing in Action Pack tests
2012-09-12 15:33:42 -03:00
Rafael Mendonça França 45537f00b4 Allow users to configure the queue for the mailers
This allow the users to do:

    config.action_mailer.queue = MyQueue.new

and

    class UsersMailer < ActionMailer::Base
      self.queue = MyQueue.new
    end
2012-09-12 15:32:22 -03:00