From d3db94b49a975ebcbd02faecc23e7ba4d79bfa51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Berc=CC=81?= <sebastian.berc@gmail.com>
Date: Wed, 18 Jan 2017 11:50:46 +0100
Subject: [PATCH 1/2] Add regression test as a bug proof.

---
 tests/Database/DatabaseQueryBuilderTest.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php
index 769c71252b44..833ce5094c3a 100755
--- a/tests/Database/DatabaseQueryBuilderTest.php
+++ b/tests/Database/DatabaseQueryBuilderTest.php
@@ -1729,6 +1729,11 @@ public function testSelectWithLockUsesWritePdo()
         $builder->getConnection()->shouldReceive('select')->once()
             ->with(m::any(), m::any(), false);
         $builder->select('*')->from('foo')->where('bar', '=', 'baz')->lock()->get();
+
+        $builder = $this->getMySqlBuilderWithProcessor();
+        $builder->getConnection()->shouldReceive('select')->once()
+            ->with(m::any(), m::any(), false);
+        $builder->select('*')->from('foo')->where('bar', '=', 'baz')->lock(false)->get();
     }
 
     public function testBindingOrder()

From 52e520f7b96726962039d8c196eb3758571f731f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Berc=CC=81?= <sebastian.berc@gmail.com>
Date: Wed, 18 Jan 2017 11:59:40 +0100
Subject: [PATCH 2/2] Fix execution queries with locks on the read PDO
 instance.

---
 src/Illuminate/Database/Query/Builder.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php
index cb8b922b5492..e1911ae83028 100755
--- a/src/Illuminate/Database/Query/Builder.php
+++ b/src/Illuminate/Database/Query/Builder.php
@@ -1606,14 +1606,14 @@ public function unionAll($query)
     /**
      * Lock the selected rows in the table.
      *
-     * @param  bool  $value
+     * @param  string|bool  $value
      * @return $this
      */
     public function lock($value = true)
     {
         $this->lock = $value;
 
-        if ($this->lock) {
+        if (! is_null($this->lock)) {
             $this->useWritePdo();
         }