@@ -527,7 +527,7 @@ public function rawFetchRow($sql, $field = null)
527527 protected function _checkDdlTransaction ($ sql )
528528 {
529529 if ($ this ->getTransactionLevel () > 0 ) {
530- $ sql = ltrim (preg_replace ('/\s+/ ' , ' ' , $ sql ));
530+ $ sql = $ sql !== null ? ltrim (preg_replace ('/\s+/ ' , ' ' , $ sql )) : '' ;
531531 $ sqlMessage = explode (' ' , $ sql , 3 );
532532 $ startSql = strtolower (substr ($ sqlMessage [0 ], 0 , 3 ));
533533 if (in_array ($ startSql , $ this ->_ddlRoutines ) && strcasecmp ($ sqlMessage [1 ], 'temporary ' ) !== 0 ) {
@@ -623,7 +623,10 @@ protected function _query($sql, $bind = [])
623623 */
624624 public function query ($ sql , $ bind = [])
625625 {
626- if (strpos (rtrim ($ sql , " \t\n\r\0; " ), '; ' ) !== false && count ($ this ->_splitMultiQuery ($ sql )) > 1 ) {
626+ if ($ sql !== null &&
627+ strpos (rtrim ($ sql , " \t\n\r\0; " ), '; ' ) !== false &&
628+ count ($ this ->_splitMultiQuery ($ sql )) > 1
629+ ) {
627630 throw new \Magento \Framework \Exception \LocalizedException (
628631 new Phrase ("Multiple queries can't be executed. Run a single query and try again. " )
629632 );
@@ -746,6 +749,7 @@ protected function _convertMixedBind(&$sql, &$bind)
746749 {
747750 $ positions = [];
748751 $ offset = 0 ;
752+ $ sql = (string )$ sql ;
749753 // get positions
750754 while (true ) {
751755 $ pos = strpos ($ sql , '? ' , $ offset );
@@ -879,7 +883,7 @@ protected function _splitMultiQuery($sql)
879883 public function dropForeignKey ($ tableName , $ fkName , $ schemaName = null )
880884 {
881885 $ foreignKeys = $ this ->getForeignKeys ($ tableName , $ schemaName );
882- $ fkName = strtoupper ($ fkName );
886+ $ fkName = $ fkName !== null ? strtoupper ($ fkName ) : '' ;
883887 if (substr ($ fkName , 0 , 3 ) == 'FK_ ' ) {
884888 $ fkName = substr ($ fkName , 3 );
885889 }
@@ -1220,7 +1224,7 @@ public function showTableStatus($tableName, $schemaName = null)
12201224 private function isMysql8EngineUsed (): bool
12211225 {
12221226 if (!$ this ->isMysql8Engine ) {
1223- $ version = $ this ->fetchPairs ("SHOW variables LIKE 'version' " )['version ' ];
1227+ $ version = $ this ->fetchPairs ("SHOW variables LIKE 'version' " )['version ' ] ?? '' ;
12241228 $ this ->isMysql8Engine = (bool ) preg_match ('/^(8\.)/ ' , $ version );
12251229 }
12261230
@@ -1430,11 +1434,11 @@ public function getIndexList($tableName, $schemaName = null)
14301434 $ fieldColumn = 'Column_name ' ;
14311435 $ fieldIndexType = 'Index_type ' ;
14321436
1433- if (strtolower ($ row [$ fieldKeyName ]) == AdapterInterface::INDEX_TYPE_PRIMARY ) {
1437+ if (strtolower ($ row [$ fieldKeyName ] ?? '' ) == AdapterInterface::INDEX_TYPE_PRIMARY ) {
14341438 $ indexType = AdapterInterface::INDEX_TYPE_PRIMARY ;
14351439 } elseif ($ row [$ fieldNonUnique ] == 0 ) {
14361440 $ indexType = AdapterInterface::INDEX_TYPE_UNIQUE ;
1437- } elseif (strtolower ($ row [$ fieldIndexType ]) == AdapterInterface::INDEX_TYPE_FULLTEXT ) {
1441+ } elseif (strtolower ($ row [$ fieldIndexType ] ?? '' ) == AdapterInterface::INDEX_TYPE_FULLTEXT ) {
14381442 $ indexType = AdapterInterface::INDEX_TYPE_FULLTEXT ;
14391443 } else {
14401444 $ indexType = AdapterInterface::INDEX_TYPE_INDEX ;
@@ -2368,7 +2372,7 @@ protected function _getIndexesDefinition(Table $table)
23682372 */
23692373 protected function isNdb (Table $ table )
23702374 {
2371- $ engineType = strtolower ($ table ->getOption ('type ' ));
2375+ $ engineType = strtolower ($ table ->getOption ('type ' ) ?? '' );
23722376 return $ engineType == 'ndb ' || $ engineType == 'ndbcluster ' ;
23732377 }
23742378
@@ -2783,7 +2787,7 @@ public function addIndex(
27832787 }
27842788 $ fieldSql = implode (', ' , $ fieldSql );
27852789
2786- switch (strtolower ($ indexType )) {
2790+ switch (strtolower (( string ) $ indexType )) {
27872791 case AdapterInterface::INDEX_TYPE_PRIMARY :
27882792 $ condition = 'PRIMARY KEY ' ;
27892793 break ;
@@ -2806,7 +2810,7 @@ public function addIndex(
28062810 $ result = $ this ->rawQuery ($ query );
28072811 $ cycle = false ;
28082812 } catch (\Exception $ e ) {
2809- if (in_array (strtolower ($ indexType ), ['primary ' , 'unique ' ])) {
2813+ if ($ indexType !== null && in_array (strtolower ($ indexType ), ['primary ' , 'unique ' ])) {
28102814 $ match = [];
28112815 // phpstan:ignore
28122816 if (preg_match ('#SQLSTATE\[23000\]: [^:]+: 1062[^ \']+ \'([\d.-]+) \'# ' , $ e ->getMessage (), $ match )) {
@@ -2837,7 +2841,7 @@ public function dropIndex($tableName, $keyName, $schemaName = null)
28372841 {
28382842 $ indexList = $ this ->getIndexList ($ tableName , $ schemaName );
28392843 $ indexType = 'index ' ;
2840- $ keyName = strtoupper ($ keyName );
2844+ $ keyName = $ keyName !== null ? strtoupper ($ keyName ) : '' ;
28412845 if (!isset ($ indexList [$ keyName ])) {
28422846 return true ;
28432847 }
@@ -3076,7 +3080,7 @@ public function prepareSqlCondition($fieldName, $condition)
30763080 */
30773081 protected function _prepareQuotedSqlCondition ($ text , $ value , $ fieldName )
30783082 {
3079- $ text = str_replace ('{{fieldName}} ' , $ fieldName , $ text );
3083+ $ text = str_replace ('{{fieldName}} ' , ( string ) $ fieldName , ( string ) $ text );
30803084 $ sql = $ this ->quoteInto ($ text , $ value );
30813085 return $ sql ;
30823086 }
@@ -3480,7 +3484,7 @@ public function getIndexName($tableName, $fields, $indexType = '')
34803484 $ fields = implode ('_ ' , $ fields );
34813485 }
34823486
3483- switch (strtolower ($ indexType )) {
3487+ switch (strtolower (( string ) $ indexType )) {
34843488 case AdapterInterface::INDEX_TYPE_UNIQUE :
34853489 $ prefix = 'unq_ ' ;
34863490 break ;
0 commit comments