diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb
index 5e7f34b6232e4fb2623cc0a9943ab2ddf3a99336..467cc60f6a614d460bb72f2b9f5c36720539f8c2 100644
--- a/Library/Homebrew/cmd/update.rb
+++ b/Library/Homebrew/cmd/update.rb
@@ -174,16 +174,17 @@ class Updater
     if initial_revision && initial_revision != current_revision
       diff.each_line do |line|
         status, *paths = line.split
+        src, dst = paths.first, paths.last
 
-        next unless File.extname(paths.last) == ".rb"
-        next unless File.dirname(paths.last) == formula_directory
+        next unless File.extname(dst) == ".rb"
+        next unless paths.any? { |p| File.dirname(p) == formula_directory }
 
         case status
         when "A", "M", "D"
-          map[status.to_sym] << repository.join(paths.first)
+          map[status.to_sym] << repository.join(src)
         when /^R\d{0,3}/
-          map[:D] << repository.join(paths.first)
-          map[:A] << repository.join(paths.last)
+          map[:D] << repository.join(src) if File.dirname(src) == formula_directory
+          map[:A] << repository.join(dst) if File.dirname(dst) == formula_directory
         end
       end
     end
diff --git a/Library/Homebrew/test/fixtures/updater_fixture.yaml b/Library/Homebrew/test/fixtures/updater_fixture.yaml
index 6038623e68953afaa6a700b705399deebba87c97..b12f9d447f43f186187d1c95f962e0c135faea5f 100644
--- a/Library/Homebrew/test/fixtures/updater_fixture.yaml
+++ b/Library/Homebrew/test/fixtures/updater_fixture.yaml
@@ -43,6 +43,9 @@ update_git_diff_output_with_changed_filetype: |
 update_git_diff_output_with_restructured_tap: |
   R100	git.rb	Formula/git.rb
   R100	lua.rb	Formula/lua.rb
+update_git_diff_simulate_homebrew_php_restructuring: |
+  R100	Formula/git.rb	Abstract/git.rb
+  R100	Formula/lua.rb	Abstract/lua.rb
 update_git_diff_output_with_tap_formulae_changes: |
   M	Rakefile
   M	README.md
diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb
index b08766ae2ec1583f03d3d806f91ab9cef2d3ce0e..41824ebdede20e9de5214ed23a27e066653064d1 100644
--- a/Library/Homebrew/test/test_updater.rb
+++ b/Library/Homebrew/test/test_updater.rb
@@ -98,6 +98,17 @@ class UpdaterTests < Homebrew::TestCase
     perform_update("update_git_diff_output_with_restructured_tap")
 
     assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A)
+    assert_empty @report.select_formula(:D)
+  end
+
+  def test_update_homebrew_simulate_homebrew_php_restructuring
+    repo = HOMEBREW_LIBRARY.join("Taps", "foo", "bar")
+    @updater = UpdaterMock.new(repo)
+    repo.join("Formula").mkpath
+
+    perform_update("update_git_diff_simulate_homebrew_php_restructuring")
+
+    assert_empty @report.select_formula(:A)
     assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D)
   end