@@ -112,6 +112,9 @@ public static function register(): void
112112 $ builder = self ::makeBuilder ($ instrumentation , 'PDO::query ' , $ function , $ class , $ filename , $ lineno )
113113 ->setSpanKind (SpanKind::KIND_CLIENT );
114114 $ sqlStatement = mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' );
115+ if (!is_string ($ sqlStatement )) {
116+ $ sqlStatement = 'undefined ' ;
117+ }
115118 if ($ class === PDO ::class) {
116119 $ builder ->setAttribute (TraceAttributes::DB_QUERY_TEXT , $ sqlStatement );
117120 }
@@ -148,6 +151,9 @@ public static function register(): void
148151 $ builder = self ::makeBuilder ($ instrumentation , 'PDO::exec ' , $ function , $ class , $ filename , $ lineno )
149152 ->setSpanKind (SpanKind::KIND_CLIENT );
150153 $ sqlStatement = mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' );
154+ if (!is_string ($ sqlStatement )) {
155+ $ sqlStatement = 'undefined ' ;
156+ }
151157 if ($ class === PDO ::class) {
152158 $ builder ->setAttribute (TraceAttributes::DB_QUERY_TEXT , $ sqlStatement );
153159 }
@@ -184,6 +190,9 @@ public static function register(): void
184190 $ builder = self ::makeBuilder ($ instrumentation , 'PDO::prepare ' , $ function , $ class , $ filename , $ lineno )
185191 ->setSpanKind (SpanKind::KIND_CLIENT );
186192 $ sqlStatement = mb_convert_encoding ($ params [0 ] ?? 'undefined ' , 'UTF-8 ' );
193+ if (!is_string ($ sqlStatement )) {
194+ $ sqlStatement = 'undefined ' ;
195+ }
187196 if ($ class === PDO ::class) {
188197 $ builder ->setAttribute (TraceAttributes::DB_QUERY_TEXT , $ sqlStatement );
189198 }
0 commit comments