File tree Expand file tree Collapse file tree
lhc_web/ezcomponents/Database/src/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,10 +128,25 @@ public function reconnect()
128128 } catch (Exception $ e ) {
129129 if ($ e ->errorInfo [1 ] == 2006 && $ this ->reconnectedCounter < 5 ) {
130130 $ this ->reconnectedCounter ++;
131- parent ::__construct ( $ this ->dbParams , $ this ->dsn );
132- $ this ->query ('SET NAMES \'utf8mb4 \' COLLATE \'utf8mb4_unicode_ci \'' );
131+ $ this ->reconnectClean ();
133132 }
134133 }
134+
135+ // After a fork (php-resque workers), PDO may report an active
136+ // transaction on the inherited connection even though ezc's
137+ // $transactionNestingLevel was reset to 0 in the child. Force
138+ // a fresh connection to clear the stale PDO state.
139+ if ($ this ->inTransaction ()) {
140+ $ this ->reconnectedCounter ++;
141+ $ this ->reconnectClean ();
142+ }
143+ }
144+
145+ private function reconnectClean ()
146+ {
147+ parent ::__construct ( $ this ->dbParams , $ this ->dsn );
148+ $ this ->query ('SET NAMES \'utf8mb4 \' COLLATE \'utf8mb4_unicode_ci \'' );
149+ $ this ->transactionNestingLevel = 0 ;
135150 }
136151
137152 /**
You can’t perform that action at this time.
0 commit comments