Commit Graph

350 Commits

Author SHA1 Message Date
Sergey Biryukov 139387b7e5 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.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Peter Wilson 47d26cd9fb DOCS: Replace HTTP links with HTTPS.
Replaces unsecure links in documentation and translator comments with their secure versions.

Props johnpgreen, netweb

Fixes #36993

Built from https://develop.svn.wordpress.org/trunk@37674


git-svn-id: http://core.svn.wordpress.org/trunk@37640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-10 04:50:33 +00:00
Gary Pendergast 69147eb345 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.


Built from https://develop.svn.wordpress.org/trunk@37601


git-svn-id: http://core.svn.wordpress.org/trunk@37569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-01 02:38:29 +00:00
Drew Jaynes 7b5364d2ec Docs: Standardizes and improves DocBlock summaries for the `__get()`, `__set()`, `__isset()`, and `__unset()` magic methods in `wpdb`.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@37585


git-svn-id: http://core.svn.wordpress.org/trunk@37553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-27 17:12:29 +00:00
Gary Pendergast 2441b7b52f 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.


Built from https://develop.svn.wordpress.org/trunk@37548


git-svn-id: http://core.svn.wordpress.org/trunk@37516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-24 05:24:26 +00:00
Drew Jaynes 9193013158 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.

Built from https://develop.svn.wordpress.org/trunk@37544


git-svn-id: http://core.svn.wordpress.org/trunk@37512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 19:02:28 +00:00
Gary Pendergast db3917d491 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.


Built from https://develop.svn.wordpress.org/trunk@37523


git-svn-id: http://core.svn.wordpress.org/trunk@37491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 06:32:29 +00:00
Gary Pendergast 1aff99307f 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.



Built from https://develop.svn.wordpress.org/trunk@37521


git-svn-id: http://core.svn.wordpress.org/trunk@37489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 05:54:27 +00:00
Drew Jaynes 9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37518


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Drew Jaynes b1804afeaf 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.

Built from https://develop.svn.wordpress.org/trunk@37431


git-svn-id: http://core.svn.wordpress.org/trunk@37397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 18:41:31 +00:00
Eric Lewis cc1b2fae67 Database: Set MySQL connection collation.
Fixes #36649.

Built from https://develop.svn.wordpress.org/trunk@37320


git-svn-id: http://core.svn.wordpress.org/trunk@37286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-28 01:39:26 +00:00
Gary Pendergast b45e906927 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.


Built from https://develop.svn.wordpress.org/trunk@37292


git-svn-id: http://core.svn.wordpress.org/trunk@37258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-22 05:19:27 +00:00
Drew Jaynes b6d1626613 Docs: Following [37085], properly indent the markdown-formatted examples in the DocBlock for `wpdb::esc_like()`.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@37086


git-svn-id: http://core.svn.wordpress.org/trunk@37053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-27 18:27:26 +00:00
Drew Jaynes 60b9a5a48f Docs: Add missing quotes around a specifier in a query example in the DocBlock for `wpdb::esc_like()`.
Props madvic.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@37085


git-svn-id: http://core.svn.wordpress.org/trunk@37052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-27 18:25:26 +00:00
Gary Pendergast c233a88379 WPDB: Reset connection status variables when the connection is closed.
Fixes #36240.


Built from https://develop.svn.wordpress.org/trunk@36997


git-svn-id: http://core.svn.wordpress.org/trunk@36964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-15 03:28:26 +00:00
Drew Jaynes e842a7b2e0 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.

Built from https://develop.svn.wordpress.org/trunk@36840


git-svn-id: http://core.svn.wordpress.org/trunk@36807 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-04 00:03:27 +00:00
Drew Jaynes b0ef4d14c5 Docs: Add an `@access` tag and fix a typo in the DocBlock for `wpdb::close()`.
See #34903. See #32246.

Built from https://develop.svn.wordpress.org/trunk@36493


git-svn-id: http://core.svn.wordpress.org/trunk@36460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-07 02:03:26 +00:00
Gary Pendergast 5779ed9d8a 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.


Built from https://develop.svn.wordpress.org/trunk@36433


git-svn-id: http://core.svn.wordpress.org/trunk@36400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-02 00:13:26 +00:00
Sergey Biryukov b0b311053e Docs: Correct `wpdb::db_version()` description.
Props luciole135.
Fixes #35588.
Built from https://develop.svn.wordpress.org/trunk@36385


git-svn-id: http://core.svn.wordpress.org/trunk@36352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-23 11:22:26 +00:00
Eric Lewis b07bb412ee Don't suppress error messages in database function calls.
Fixes #21870.

Built from https://develop.svn.wordpress.org/trunk@35860


git-svn-id: http://core.svn.wordpress.org/trunk@35824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-11 03:40:26 +00:00
Drew Jaynes 4048bfb25c Docs: Fix mid-file separator syntax in wp-includes/wp-db.php.
Props liamdempsey.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35787


git-svn-id: http://core.svn.wordpress.org/trunk@35751 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-06 20:26:24 +00:00
Gary Pendergast ffc4d6965c 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.


Built from https://develop.svn.wordpress.org/trunk@35655


git-svn-id: http://core.svn.wordpress.org/trunk@35619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-17 06:13:26 +00:00
Sergey Biryukov 123765d9c8 I18N: Add a translator comment for the string introduced in [24758] and made translatable in [29840].
Props swissspidy.
See #34249.
Built from https://develop.svn.wordpress.org/trunk@35544


git-svn-id: http://core.svn.wordpress.org/trunk@35508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-05 21:18:25 +00:00
Sergey Biryukov 639371de09 Add `wp_load_translations_early()` to `wpdb::check_connection()`.
Fixes #29306. See #34216.
Built from https://develop.svn.wordpress.org/trunk@34943


git-svn-id: http://core.svn.wordpress.org/trunk@34908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-08 17:11:24 +00:00
Sergey Biryukov 50e6ef8bd7 Split database error messages into separate strings to remove unnecessary HTML tags from translations.
Add translator comments for placeholders.

Fixes #34216.
Built from https://develop.svn.wordpress.org/trunk@34942


git-svn-id: http://core.svn.wordpress.org/trunk@34907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-08 16:52:24 +00:00
Gary Pendergast 3942226c90 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.


Built from https://develop.svn.wordpress.org/trunk@34737


git-svn-id: http://core.svn.wordpress.org/trunk@34701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-01 05:37:26 +00:00
Gary Pendergast 9347f1af71 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.


Built from https://develop.svn.wordpress.org/trunk@34655


git-svn-id: http://core.svn.wordpress.org/trunk@34619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 01:17:24 +00:00
Boone Gorges 8b4a5d1ec0 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.
Built from https://develop.svn.wordpress.org/trunk@34529


git-svn-id: http://core.svn.wordpress.org/trunk@34493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 03:59:27 +00:00
Gary Pendergast 1b91141437 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.


Built from https://develop.svn.wordpress.org/trunk@34478


git-svn-id: http://core.svn.wordpress.org/trunk@34442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 04:30:25 +00:00
Scott Taylor 84da11d918 Pass `false` as the 2nd argument to `class_exists()` to disable autoloading and to not cause problems for those who define `__autoload()`.
Fixes #20523.

Built from https://develop.svn.wordpress.org/trunk@34348


git-svn-id: http://core.svn.wordpress.org/trunk@34312 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-20 03:52:25 +00:00
Drew Jaynes 13c25f5f49 Docs: Put "it's" in its place (again).
Props kitchin.
Fixes #33894.

Built from https://develop.svn.wordpress.org/trunk@34234


git-svn-id: http://core.svn.wordpress.org/trunk@34198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 12:46:28 +00:00
Scott Taylor 128cc02f39 In `wpdb::get_col_length()`, the final `return false` is unreachable since the default `switch` case returns.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@33956


git-svn-id: http://core.svn.wordpress.org/trunk@33925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 00:48:26 +00:00
Scott Taylor ef87172270 `foreach` is a statement, not a function.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@33734


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Gary Pendergast eb99787e32 WPDB: `get_table_from_query()` didn't find table names with hyphens in them.
Props dustinbolton for the fix.

Fixes #33470.


Built from https://develop.svn.wordpress.org/trunk@33718


git-svn-id: http://core.svn.wordpress.org/trunk@33685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-24 00:19:25 +00:00
Scott Taylor 029c274b86 In `wpdb::get_col_length()`, `break`s are not necessary when a `case` returns
See #33491.

Built from https://develop.svn.wordpress.org/trunk@33701


git-svn-id: http://core.svn.wordpress.org/trunk@33668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-21 18:41:25 +00:00
Drew Jaynes 4770601d73 Docs: Standardize `@deprecated` tag formatting in the DocBlocks for several `wpdb` methods.
Props Alphawolf.
See #28806.

Built from https://develop.svn.wordpress.org/trunk@33679


git-svn-id: http://core.svn.wordpress.org/trunk@33646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 22:42:25 +00:00
Gary Pendergast e6904bc0e8 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.


Built from https://develop.svn.wordpress.org/trunk@33455


git-svn-id: http://core.svn.wordpress.org/trunk@33422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-28 06:32:24 +00:00
Gary Pendergast a6cb4b293c 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.


Built from https://develop.svn.wordpress.org/trunk@33310


git-svn-id: http://core.svn.wordpress.org/trunk@33282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-17 07:07:26 +00:00
Gary Pendergast 6759a210ca 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.


Built from https://develop.svn.wordpress.org/trunk@33308


git-svn-id: http://core.svn.wordpress.org/trunk@33280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-17 06:34:26 +00:00
Gary Pendergast f28b182a7c 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.


Built from https://develop.svn.wordpress.org/trunk@33276


git-svn-id: http://core.svn.wordpress.org/trunk@33248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-15 04:33:25 +00:00
Gary Pendergast 4ee0da1798 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


Built from https://develop.svn.wordpress.org/trunk@33259


git-svn-id: http://core.svn.wordpress.org/trunk@33231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-14 10:19:24 +00:00
Dion Hulse cbacb92dae 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.

Built from https://develop.svn.wordpress.org/trunk@33055


git-svn-id: http://core.svn.wordpress.org/trunk@33026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-03 03:26:24 +00:00
Dominik Schilling 54424e9755 wpdb: Make "WordPress database error:" translatable.
props jrf.
see #32021.
Built from https://develop.svn.wordpress.org/trunk@33006


git-svn-id: http://core.svn.wordpress.org/trunk@32977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-30 20:00:25 +00:00
Scott Taylor a0e373ef80 For doc block types, favor `bool` over the few remaining `boolean`s
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32964


git-svn-id: http://core.svn.wordpress.org/trunk@32935 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-27 01:03:25 +00:00
Scott Taylor 6ab487dde6 Add missing/alter existing doc blocks for `wp-db.php`.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32641


git-svn-id: http://core.svn.wordpress.org/trunk@32611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-28 20:10:29 +00:00
Scott Taylor 2f3e567f44 Alter visibility of some properties in `wpdb`:
`num_queries` is accessed publicly in core.
`num_rows` is accessed publicly in `ms-settings.php`.
`insert_id` is accessed publicly in core.
`prefix` is accessed publicly in `upgrade.php` and `capabilities.php`.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32640


git-svn-id: http://core.svn.wordpress.org/trunk@32610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-28 16:34:25 +00:00
Scott Taylor 45d897d0e7 In `wpdb::load_col_info()`, don't fetch the number of fields in the result row on each iteration of the `for` loop. It can be stored in a var and referenced.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32515


git-svn-id: http://core.svn.wordpress.org/trunk@32485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-19 20:30:27 +00:00
Gary Pendergast 7ca423d449 The UTF-8 regex can occasionally fail on very low memory machines. Reduce the amount of memory it uses.
See #32204.


Built from https://develop.svn.wordpress.org/trunk@32375


git-svn-id: http://core.svn.wordpress.org/trunk@32345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-06 06:58:24 +00:00
Gary Pendergast c24c5923c3 WPDB: When sanity checking query character sets, there's no need to check queries that don't return user data.
See #32104.


Built from https://develop.svn.wordpress.org/trunk@32374


git-svn-id: http://core.svn.wordpress.org/trunk@32344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-06 06:05:26 +00:00
Gary Pendergast 6e7fff514b WPDB: Allow queries to reference tables in the `dbname.tablename` format, and allow table names to contain any valid character, rather than just ASCII.
Props pento, willstedt for the initial patch.

See #32090.


Built from https://develop.svn.wordpress.org/trunk@32368


git-svn-id: http://core.svn.wordpress.org/trunk@32338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-06 05:01:26 +00:00