Commit Graph

131 Commits

Author SHA1 Message Date
Gary Pendergast
7fc579eec9 Database: Don't force an unsupported character set that previously would've silently failed.
[37320] corrected some behaviour in how PHP and MySQL character sets are matched up. This was correct, but had the side effect of causing some incorrectly configured sites to start failing.

Prior to [37320], if `DB_CHARSET` was set to `utf8mb4`, but the PHP version didn't support `utf8mb4`, it would fall back to the default character set - usually `latin1`. After [37320], the `SET NAMES` query would force MySQL to treat the connection character set as `utf8mb4`, even if PHP wasn't able to understand it.

By checking if `mysqli_set_charset()` succeeded, we can simulate the old behaviour, while maintaining the fix in [37320].

Props danielkanchev fo helping to diagnose this issue.
Fixes #37689 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@38441 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 07:37:59 +00:00
Gary Pendergast
fd7979ad63 Database: Ensure that variables are defined correctly.
There were some cases where some local variables in `wpdb::init_charset()` could be undefined when they were used.

Props Frozzare.
Fixes #37683 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@38439 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 07:13:31 +00:00
Scott Taylor
670878cbaa Database: WP_Network, WP_Network_Query, and WP_Site_Query call wpdb::_escape(), thus requiring it to be public. It previously had no access modifier. _ at the beginning of a method, believe it or not, does not enforce visibility constraints.
See #37771.


git-svn-id: https://develop.svn.wordpress.org/trunk@38314 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-22 21:09:03 +00:00
Sergey Biryukov
4bf8693357 Docs: Correct usage examples for wpdb::prepare(), which should not be called statically.
Props TJNowell.
Fixes #37744.

git-svn-id: https://develop.svn.wordpress.org/trunk@38289 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 13:16:33 +00:00
Sergey Biryukov
e7bd22f87e Database: Replace incorrect use of E_USER_NOTICE in wpdb::_real_escape() with the version number where the message was added.
Props andizer.
Fixes #36403.

git-svn-id: https://develop.svn.wordpress.org/trunk@38133 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-21 22:44:26 +00:00
Drew Jaynes
7e52b06003 Docs: Fix formatting, tense, verb conjugation, and other syntax for wp-includes/* elements introduced or changed in 4.6.
Part 2/2.

Fixes #37318.


git-svn-id: https://develop.svn.wordpress.org/trunk@38125 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-20 19:32:05 +00:00
Sergey Biryukov
920f29616a Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core.
Props metodiew.
Fixes #36495.

git-svn-id: https://develop.svn.wordpress.org/trunk@37985 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 12:39:01 +00:00
Peter Wilson
db0195c936 DOCS: Replace HTTP links with HTTPS.
Replaces unsecure links in documentation and translator comments with their secure versions.

Props johnpgreen, netweb

Fixes #36993


git-svn-id: https://develop.svn.wordpress.org/trunk@37674 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-10 04:49:09 +00:00
Gary Pendergast
bc975d28d4 Database: Split the logic of wpdb::init_charset() into a separate method.
The logic for determining the appropriate character set and collation to use is becoming more complex, particularly with the recent additions of [37522] and [37523]. As `init_charset()` has side effects, and makes use of constants instead of parameters, it's not possible to unit test this logic.

This commit splits the logic part of `init_charset()` out into a new method, `wpdb::determine_charset()`, along with appropriate unit tests.

See #32105, #37522.

Fixes #36917.



git-svn-id: https://develop.svn.wordpress.org/trunk@37601 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-01 02:37:20 +00:00
Drew Jaynes
1942855ada Docs: Standardizes and improves DocBlock summaries for the __get(), __set(), __isset(), and __unset() magic methods in wpdb.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@37585 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-27 17:11:47 +00:00
Gary Pendergast
01356e100e Database: Don't generate unnecessary warnings in wpdb::query().
In the event that the database has gone away for some reason, calls to `mysqli_errno()` and `mysqli_error()` (and their `ext/mysql` equivalents, of course), will generate PHP warnings, which are unsightly, and not how we do things in these parts.

Props mbijon, craig-ralston for the original patch.

Fixes #23085.



git-svn-id: https://develop.svn.wordpress.org/trunk@37548 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-24 05:23:06 +00:00
Drew Jaynes
9531107084 Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

Fixes #36921.


git-svn-id: https://develop.svn.wordpress.org/trunk@37544 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 19:01:40 +00:00
Gary Pendergast
a09ea91d16 Database: Use the utf8mb4_unicode_520_ci collation, when available.
The `utf8mb4_unicode_520_ci` (Unicode Collation Algorithm 5.2.0, October 2010) collation is an improvement over `utf8mb4_unicode_ci` (UCA 4.0.0, November 2003).

There is no word on when MySQL will support later UCAs.

Fixes #32105.



git-svn-id: https://develop.svn.wordpress.org/trunk@37523 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 06:31:44 +00:00
pento
4422aac17c Database: Obey locale-specific utf8 collation settings.
Some sites prefer to use locale-specific location settings. For example, the Swedish WordPress package use `utf8_swedish_ci`, instead of `utf8_unicode_ci`. When upgrading the connection to `utf8mb4`, we were overriding this to be `utf8mb4_unicode_ci`, instead of maintaining the use of the `_swedish_ci` variant.

The locale-specific collations do have extra collation rules just for that language, so it's useful to maintain compatibility.

Fixes #32405.




git-svn-id: https://develop.svn.wordpress.org/trunk@37521 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 05:53:02 +00:00
Drew Jaynes
d11f7ed391 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.


git-svn-id: https://develop.svn.wordpress.org/trunk@37518 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 18:49:05 +00:00
Drew Jaynes
195572596b Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.


git-svn-id: https://develop.svn.wordpress.org/trunk@37431 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-13 18:40:19 +00:00
Eric Andrew Lewis
878343d4d1 Database: Set MySQL connection collation.
Fixes #36649.


git-svn-id: https://develop.svn.wordpress.org/trunk@37320 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-28 01:38:31 +00:00
Gary Pendergast
9a4c6dc3de Database: Suppress connection error messages when WP_DEBUG isn't enabled.
This is a partial revert of [35860], which has been causing un-catchable warnings to be generated on some server configurations.

Fixes #36629 for trunk.
See #21870.



git-svn-id: https://develop.svn.wordpress.org/trunk@37292 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 05:18:08 +00:00
Drew Jaynes
b7e91e1dcc Docs: Following [37085], properly indent the markdown-formatted examples in the DocBlock for wpdb::esc_like().
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@37086 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-27 18:26:33 +00:00
Drew Jaynes
2ac50341ab Docs: Add missing quotes around a specifier in a query example in the DocBlock for wpdb::esc_like().
Props madvic.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@37085 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-27 18:24:45 +00:00
Gary Pendergast
8233227667 WPDB: Reset connection status variables when the connection is closed.
Fixes #36240.



git-svn-id: https://develop.svn.wordpress.org/trunk@36997 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-15 03:27:14 +00:00
Drew Jaynes
9775eef208 Docs: Remove an errant period following the @access tag in the DocBlock for wpdb::close(), mistakenly introduced in [36493].
Props markoheijnen.
See #34903. See #35986.


git-svn-id: https://develop.svn.wordpress.org/trunk@36840 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-04 00:02:56 +00:00
Drew Jaynes
2eeaf25112 Docs: Add an @access tag and fix a typo in the DocBlock for wpdb::close().
See #34903. See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@36493 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-07 02:02:27 +00:00
Gary Pendergast
2918cca22c WPDB: Add a close() method to wpdb, for when the connection needs to be manually closed.
In the event that it was closed prematurely, `wpdb::query()` will re-open the connection automatically.

Fixes #34903.



git-svn-id: https://develop.svn.wordpress.org/trunk@36433 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-02 00:12:28 +00:00
Sergey Biryukov
5d56b9a465 Docs: Correct wpdb::db_version() description.
Props luciole135.
Fixes #35588.

git-svn-id: https://develop.svn.wordpress.org/trunk@36385 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-23 11:21:14 +00:00
ericlewis
26e7188154 Don't suppress error messages in database function calls.
Fixes #21870.


git-svn-id: https://develop.svn.wordpress.org/trunk@35860 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 03:39:52 +00:00
Drew Jaynes
800971f2fd Docs: Fix mid-file separator syntax in wp-includes/wp-db.php.
Props liamdempsey.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@35787 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 20:25:45 +00:00
Gary Pendergast
d55c605242 WPDB: Fall back to the connection charset when sanity checking strings.
If `DB_CHARSET` isn't defined (or is empty), `wpdb::$charset` will be empty, too. `wpdb::strip_invalid_text()` assumes that it isn't empty, however, so we need to fall back to the connection character set when we're running our sanity checks.

Fixes #34708.



git-svn-id: https://develop.svn.wordpress.org/trunk@35655 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-17 06:12:08 +00:00
Sergey Biryukov
d3f117c81c I18N: Add a translator comment for the string introduced in [24758] and made translatable in [29840].
Props swissspidy.
See #34249.

git-svn-id: https://develop.svn.wordpress.org/trunk@35544 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-05 21:17:11 +00:00
Sergey Biryukov
017e097daf Add wp_load_translations_early() to wpdb::check_connection().
Fixes #29306. See #34216.

git-svn-id: https://develop.svn.wordpress.org/trunk@34943 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 17:10:58 +00:00
Sergey Biryukov
9a80bffdb3 Split database error messages into separate strings to remove unnecessary HTML tags from translations.
Add translator comments for placeholders.

Fixes #34216.

git-svn-id: https://develop.svn.wordpress.org/trunk@34942 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 16:51:50 +00:00
Gary Pendergast
f9f56fb942 WPDB: Allow null values in the CRUD functions.
Specifically, `::insert()`, `::replace()`, `::update()`, and `::delete()` can now set a column to `NULL`, or add the `IS NULL` condition to the `WHERE` clause.

This is based on [backpress 279].

Props pento, nbachiyski, sorich87.

Fixes #15158.



git-svn-id: https://develop.svn.wordpress.org/trunk@34737 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 05:36:15 +00:00
Gary Pendergast
2b78c9579a WPDB: Make sure we don't run sanity checks on DB dropins.
Previously, we'd run the sanity checks if `is_mysql` was not set to `false`. This caused problems for DB drop-ins that didn't define `is_mysql` at all. Instead, we can just check if `is_mysql` is `empty()`.

Also fix some unit tests that accidently ran correctly because of the strict `false ===` comparison.

Fixes #33501.



git-svn-id: https://develop.svn.wordpress.org/trunk@34655 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 01:16:29 +00:00
Boone Gorges
3425177325 Introduce metadata for taxonomy terms.
Adds a new table to the database schema (`wp_termmeta`), and a set of
`*_term_meta()` API functions. `get_terms()` and `wp_get_object_terms()`
now also support 'meta_query' parameters, with syntax identical to other
uses of `WP_Meta_Query`.

When fetching terms via `get_terms()` or `wp_get_object_terms()`, metadata for
matched terms is preloaded into the cache by default. Disable this behavior
by setting the new `$update_term_meta_cache` paramater to `false`.

To maximize performance, within `WP_Query` loops, the termmeta cache is *not*
primed by default. Instead, we use a lazy-loading technique: metadata for all
terms belonging to posts in the loop is loaded into the cache the first time
that `get_term_meta()` is called within the loop.

Props boonebgorges, sirzooro.
See #10142.

git-svn-id: https://develop.svn.wordpress.org/trunk@34529 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 03:58:59 +00:00
Gary Pendergast
e1fafc56d5 WPDB: When attempting to fall back to ext/mysql in db_connect(), return the result of the fall back.
While it doesn't affect Core, we should also be passing the `$allow_bail` parameter, for anything that uses it differently.

Props markoheijnen, johnbillion.

Fixes #33105.



git-svn-id: https://develop.svn.wordpress.org/trunk@34478 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 04:29:40 +00:00
Scott Taylor
ed7d34cb13 Pass false as the 2nd argument to class_exists() to disable autoloading and to not cause problems for those who define __autoload().
Fixes #20523.


git-svn-id: https://develop.svn.wordpress.org/trunk@34348 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-20 03:51:55 +00:00
Drew Jaynes
7682e433fc Docs: Put "it's" in its place (again).
Props kitchin.
Fixes #33894.


git-svn-id: https://develop.svn.wordpress.org/trunk@34234 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-16 12:45:51 +00:00
Scott Taylor
ae16cec9fb In wpdb::get_col_length(), the final return false is unreachable since the default switch case returns.
See #33491.


git-svn-id: https://develop.svn.wordpress.org/trunk@33956 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-09 00:47:31 +00:00
Scott Taylor
3b8c5529cb foreach is a statement, not a function.
See #33491.


git-svn-id: https://develop.svn.wordpress.org/trunk@33734 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-25 20:27:56 +00:00
Gary Pendergast
bf3d36e0b6 WPDB: get_table_from_query() didn't find table names with hyphens in them.
Props dustinbolton for the fix.

Fixes #33470.



git-svn-id: https://develop.svn.wordpress.org/trunk@33718 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-24 00:18:49 +00:00
Scott Taylor
326b67c0aa In wpdb::get_col_length(), breaks are not necessary when a case returns
See #33491.


git-svn-id: https://develop.svn.wordpress.org/trunk@33701 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-21 18:40:55 +00:00
Drew Jaynes
6db612790d Docs: Standardize @deprecated tag formatting in the DocBlocks for several wpdb methods.
Props Alphawolf.
See #28806.


git-svn-id: https://develop.svn.wordpress.org/trunk@33679 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-20 22:41:07 +00:00
Gary Pendergast
dfb86dc965 WPDB: When checking the encoding of strings against the database, make sure we're only relying on the return value of strings that were sent to the database. Also make sure that we're not trying to sanity check strings that've been marked as not needing sanity checking.
Fixes #32279.



git-svn-id: https://develop.svn.wordpress.org/trunk@33455 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-28 06:31:39 +00:00
Gary Pendergast
7217a4f6e5 WPDB: ::strip_text_from_query() doesn't pass a length to ::strip_invalid_text(), which was causing queries to fail when they contained characters that needed to be sanity checked by MySQL.
Props dd32, mdawaffe, pento.

Fixes #32279.



git-svn-id: https://develop.svn.wordpress.org/trunk@33310 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-17 07:06:33 +00:00
Gary Pendergast
bea2bf1502 WPDB: Remove some of the complexities in ::strip_invalid_text() associated with switching character sets between queries. Instead of trying to dynamically change connection character sets, we now rely on the value of ::charset. This also fixes the case where queries were being blocked when DB_CHARSET was utf8, but the column character set was non-utf8.
Fixes #32165.



git-svn-id: https://develop.svn.wordpress.org/trunk@33308 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-17 06:33:36 +00:00
Gary Pendergast
c160106af1 WPDB: When checking that text isn't too long to insert into a column, LONGTEXT columns could fail, as their length is longer than PHP_INT_MAX. Treating their length as a float instead of an int fixes this.
See #32165.



git-svn-id: https://develop.svn.wordpress.org/trunk@33276 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-15 04:32:55 +00:00
Gary Pendergast
7711b72639 WPDB: When extracting the table name from a query, we had a 1000 character limit on the SQL string that would be searched. This was a hangover from when the code was imported from HyperDB, and isn't appropriate for Core, where a wider range of queries are likely to be run.
Fixes #32763



git-svn-id: https://develop.svn.wordpress.org/trunk@33259 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-14 10:18:57 +00:00
Dion Hulse
e709e91218 Enable utf8mb4 for MySQL extension users. Previously utf8mb4 was limited to MySQLi users only unintentionally.
This change does the following things
 * Allows utf8mb4 for the MySQL extension
 * Re-runs the utf8->utf8mb4 conversion for single sites, this will do nothing for tables already converted
 * Re-runs the utf8->utf8mb4 conversion for global tables in multisite when the environment supports utf8mb4
 * Removes upgrade_420() calling as upgrade_430() will perform those changes now instead

The index shortenings should have still taken place on utf8 sites previously, so there's no need to run those again. 

Props kovshenin, pento, dd32
Fixes #32127 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@33055 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-03 03:25:07 +00:00
Dominik Schilling (ocean90)
9db82ab3a7 wpdb: Make "WordPress database error:" translatable.
props jrf.
see #32021.

git-svn-id: https://develop.svn.wordpress.org/trunk@33006 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-30 19:59:28 +00:00
Scott Taylor
f162be6046 For doc block types, favor bool over the few remaining booleans
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32964 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-27 01:02:12 +00:00