Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
d83a7512
Commit
d83a7512
authored
16 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#310447
by Damien Tournoud, Crell, catch: add back SET NAMES='utf8' -- we love
UTF-8
parent
19329548
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/database/mysql/database.inc
+6
-0
6 additions, 0 deletions
includes/database/mysql/database.inc
modules/simpletest/tests/database_test.test
+34
-0
34 additions, 0 deletions
modules/simpletest/tests/database_test.test
with
40 additions
and
0 deletions
includes/database/mysql/database.inc
+
6
−
0
View file @
d83a7512
...
...
@@ -30,6 +30,12 @@ public function __construct(Array $connection_options = array()) {
// Because MySQL's prepared statements skip the query cache, because it's dumb.
PDO
::
ATTR_EMULATE_PREPARES
=>
TRUE
,
));
// Force MySQL to use the UTF-8 character set by default.
$this
->
exec
(
'SET NAMES "utf8"'
);
// Enable MySQL's "strict mode", which removes most of MySQL's
// "just be lazy" behaviors that end up causing more trouble than they're worth.
$this
->
exec
(
'SET sql_mode=STRICT_ALL_TABLES'
);
}
...
...
This diff is collapsed.
Click to expand it.
modules/simpletest/tests/database_test.test
+
34
−
0
View file @
d83a7512
...
...
@@ -1569,3 +1569,37 @@ class DatabaseAlter2TestCase extends DatabaseTestCase {
}
}
}
/**
* Regression tests.
*/
class
DatabaseRegressionTestCase
extends
DatabaseTestCase
{
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Regression tests'
),
'description'
=>
t
(
'Regression tests cases for the database layer.'
),
'group'
=>
t
(
'Database'
),
);
}
/**
* Regression test for #310447.
*
* Tries to insert non-ascii UTF-8 data in a database column and checks
* if its stored properly.
*/
function
testRegression_310447
()
{
// That's a 255 character UTF-8 string.
$name
=
str_repeat
(
"é"
,
255
);
db_insert
(
'test'
)
->
fields
(
array
(
'name'
=>
$name
,
'age'
=>
20
,
'job'
=>
'Dancer'
,
))
->
execute
();
$from_database
=
db_query
(
"SELECT name FROM
{
test
}
WHERE name = :name"
,
array
(
':name'
=>
$name
))
->
fetchField
();
$this
->
assertIdentical
(
$name
,
$from_database
,
t
(
"The database handles UTF-8 characters cleanly."
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment