Comments (5)
Hello,
The same problem occured on a website I maintain during an update. Sharing the user table, the impact is important as nobody can authenticate after the update.
As this kind of settings (mutliple prefix) is not so often met, I understand it's just a regression introduced while making the CMS compatible with MySQL 8+ which ask to escape its keywords.
Here is a patch I developed and that works for the website I maintain:
double_table_name_prefixing_fix.zip
from drupal.
Now it's removing pipes from some string arguments in a query of mine. Not the best way to solve this. ;D
I've replaced the lower part of the function with the following, which I believe fixes the original issue, while not breaking pipes in the rest of the query.
// Add prefixes and transform curly braces into brace/pipes in order to mark already done operations
// while preserving table name encapsulation for the next step.
foreach ($db_prefix_local as $table_name => $prefix) {
$sql = strtr($sql, array('{' . $table_name . '}' => '{|' . $prefix . $table_name . '|}'));
}
$sql = strtr($sql, array('{' => '{|' . $default_replacement, '}' => '|}'));
// For MySQL 8, escape table names corresponding to reserved keywords.
if (db_version_compare('mysql', '8.0.0')) {
foreach ($db_mysql8_reserved_keywords as $keyword) {
$sql = str_replace('{|' . $keyword . '|}', '`' . $keyword . '`', $sql);
}
}
// Remove curly brace/pipes.
return strtr($sql, array('{|' => '', '|}' => ''));
from drupal.
Sorry for the regression.
For the fix, something totally different from/not including curly braces must be used as a replacement. If no, the second strtr will also modify previously modified curly braces.
Maybe triple pipes instead of single pipes? A quick search let me think it's not used in SQL (while double pipes may).
Other possibilities:
- find another good character to replace the single pipes
- (use regexp to match well the strings to replace - too heavy for that treatment, isn't it?)
- introduce a first strtr to double curly braces and then, reduce them to single curly braces in the other calls to strtr
from drupal.
Fix tried with the third solution proposed:
// Double curly braces in order to be able to mark already done operations
// while preserving table name encapsulation for the next step,
// adding prefixes and then, escaping MySQL 8 reserved keywords.
$sql = strtr($sql, array('{' => '{{' , '}' => '}}'));
// Add prefixes.
foreach ($db_prefix_local as $table_name => $prefix) {
$sql = strtr($sql, array('{{' . $table_name . '}}' => '{' . $prefix . $table_name . '}'));
}
$sql = strtr($sql, array('{{' => '{' . $default_replacement, '}}' => '}'));
// For MySQL 8, escape table names corersponding to reserved keywords.
if (db_version_compare('mysql', '8.0.0')) {
foreach ($db_mysql8_reserved_keywords as $keyword) {
$sql = str_replace('{' . $keyword . '}', '`' . $keyword . '`', $sql);
}
}
// Remove curly braces.
return str_replace(array('{', '}'), '', $sql);
And the corresponding patch:
db_prefix_tables_fix.zip
Haven't tried it but seems good...
from drupal.
from drupal.
Related Issues (20)
- substr() in database.inc HOT 2
- session_destroy(): Session callback expects true/false return value
- Typo in exclude HOT 1
- Ajax quoting problem with utf8 chars HOT 4
- One more theme.inc change HOT 6
- I broke my d6 site HOT 1
- replace ereg_replace and other removed functions HOT 2
- CHANGELOG.txt not updated since 6.52 HOT 1
- 6.58 update issue HOT 13
- MySQL 5.7 support? HOT 4
- Workaround for multi-byte characters HOT 4
- Drush 8.x does not work for some commands like `cc all` HOT 1
- Expectations with postgresql 12? HOT 1
- XSS Vulnerability - 1 HOT 2
- XSS Vulnerability - 2 HOT 3
- Regex in .htaccess to protect files and directories from prying eyes seems to have a typo HOT 1
- Any hope for php 8? HOT 28
- Website for d6lts org info points to spam
- Apache update causes Drupal URLs with spaces and other special characters to fail HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drupal.