Skip to content

Commit

Permalink
Small performance check for downgrading utf8mb4 (#12847)
Browse files Browse the repository at this point in the history
  • Loading branch information
OctavianC authored and HLeithner committed Jun 30, 2019
1 parent f527b14 commit 631d862
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/joomla/database/driver.php
Expand Up @@ -897,6 +897,12 @@ public function convertUtf8mb4QueryToUtf8($query)
return $query;
}

// Don't do preg replacement if string does not exist
if (stripos($query, 'utf8mb4') === false)
{
return $query;
}

// Replace utf8mb4 with utf8 if not within single or double quotes or name quotes
return preg_replace('/[`"\'][^`"\']*[`"\'](*SKIP)(*FAIL)|utf8mb4/i', 'utf8', $query);
}
Expand Down

0 comments on commit 631d862

Please sign in to comment.