Commit Graph

442 Commits

Author SHA1 Message Date
desrosj
945ba795dc WPDB: Check that $wpdb->last_result is countable before counting with it.
`wpdb::get_col()` iterates over `$wpdb->last_result`, which can be a non-countable value, should the preceding query have failed.

Props spacedmonkey, desrosj, pento.

Merges [43934] into trunk.

See #45299.
Built from https://develop.svn.wordpress.org/trunk@44272


git-svn-id: http://core.svn.wordpress.org/trunk@44102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 18:39:52 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


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


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
John Blackbourn
e2719c4e90 Docs: Correct the possible return types for the wpdb::query() method.
Props isabel104

See #42505

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


git-svn-id: http://core.svn.wordpress.org/trunk@42846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-04-28 14:44:23 +00:00
Felix Arntz
176a289050 Multisite: Introduce metadata for sites.
A new global multisite table `wp_blogmeta` is added to the database schema, and a set of `*_site_meta()` API functions are introduced.

The implementation fails gracefully when the new table is not yet available, which may happen especially shortly after the core update, before the network has been upgraded to the new database schema. The presence of the table is detected once and stored as a global setting on the main network.

Core does not yet use site metadata, but there are several use-cases to be implemented or explored in the near future, and it allows plugins to extend sites with arbitrary data, which will come in particularly handy with the upcoming REST API endpoint for sites.

Props spacedmonkey, johnjamesjacoby, jeremyfelt, flixos90.
Fixes #37923.

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


git-svn-id: http://core.svn.wordpress.org/trunk@42666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-16 02:15:31 +00:00
Sergey Biryukov
4848a09b35 I18N: Use the actual placeholder instead of a number in translator comments if the corresponding string does not use numbered placeholders.
Add missing translator comments in `WP_Theme_Install_List_Table` and `wp_notify_postauthor()`.
Add missing commas in some translator comments.

Fixes #43523.
Built from https://develop.svn.wordpress.org/trunk@42827


git-svn-id: http://core.svn.wordpress.org/trunk@42657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-11 16:44:34 +00:00
John Blackbourn
6c09e79cc5 Database: Add the query start time to logged query data.
This allows debugging plugins to plot the time at which queries were executed.

Props Rarst for initial patch.

Fixes #43315

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


git-svn-id: http://core.svn.wordpress.org/trunk@42619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-05 22:54:35 +00:00
Sergey Biryukov
e50b9c943f Database: If both WP_DEBUG and WP_DEBUG_DISPLAY are true, display a more specific error message in wpdb::bail().
Props sivel, Mte90, SergeyBiryukov.
Fixes #13657.
Built from https://develop.svn.wordpress.org/trunk@42716


git-svn-id: http://core.svn.wordpress.org/trunk@42544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-15 14:29:30 +00:00
Dion Hulse
fc42c062f1 WPDB: Use a PCRE syntax which supports PCRE compiled between 2003 and 2006.
This fixes a PHP Warning in `wpdb::parse_db_host()` when WordPress is used with (sometimes a modern) PHP that's compiled against an ancient PCRE version.

Fixes #43109 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@42378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-23 03:39:30 +00:00
Dion Hulse
04efa7e7ea WPDB: Always use mysqli when available.
This change makes WordPress use `mysqli` on PHP <5.5 when available, instead of only in PHP 5.5+ and development installs.

WPDB includes a fallback to `mysql` in the event that the database connection fails with `mysqli` so incompatibilities should be few and far between.

Fixes #42812 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@42217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-12 05:43:48 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Gary Pendergast
c90cfa3b50 General: Fix some precision alignment formatting warnings.
The WPCS `WordPress.WhiteSpace.PrecisionAlignment` rule throws warnings for a bunch of code that will likely cause issues for `wpcbf`. Fixing these manually beforehand gives us better auto-fixed results later.

See #41057.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-26 23:57:55 +00:00
Dion Hulse
b33967cd31 WPDB: Fix the parsing of sockets which contain colons within the socket name (used on some cloud providers).
Props natacado.
Fixes #42634 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@42055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-24 05:52:46 +00:00
Gary Pendergast
8255d04abb WPDB: Check that AUTH_SALT is not empty.
In `wpdb::placeholder_escape()`, the key for `hash_hmac()` defaults to `AUTH_SALT`, but `hash_hmac()` will return an empty string if the key is empty.

This had the side effect of the string `{}` being incorrectly replaced with a `%` character in queries just about to be run on the database.

Props jsonfry.
Fixes #42431.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-07 01:09:47 +00:00
Gary Pendergast
002d65112f WPDB: Fix a PHP notice when AUTH_SALT is undefined.
In `wpdb::placeholder_escape()`, the key for `hash_hmac()` falls back to `rand()` when `AUTH_SALT` is undefined. `hash_hmac()` requires the key to be a string, however, so we need to cast it as such.

Props mkomar.
Fixes #42401.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41948 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-07 00:30:46 +00:00
Gary Pendergast
a2693fd860 Database: Restore numbered placeholders in wpdb::prepare().
[41496] removed support for numbered placeholders in queries send through `wpdb::prepare()`, which, despite being undocumented, were quite commonly used.

This change restores support for numbered placeholders (as well as a subset of placeholder formatting), while also adding extra checks to ensure the correct number of arguments are being passed to `wpdb::prepare()`, given the number of placeholders.

See #41925.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41885 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-31 12:00:49 +00:00
Pascal Birchler
8b4a8b6c15 Database: Add translators comment for error message in wpdb::prepare().
Props felipeelia.
Fixes #42142.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-11 08:35:47 +00:00
Gary Pendergast
fd247bc2e4 Database: When parsing the host, leave the port and socket as null if they're not defined.
This fixes a change in behaviour introduced by [41629].

The host is set to an empty string when it isn't defined, this continues existing behaviour. In particular, the mysqli library treats a `null` host as being the same as `localhost`, which is not always the intended behaviour.

Props birgire, markjaquith, pento.
Fixes #41722.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-11 00:10:47 +00:00
Pascal Birchler
1478135c46 Database: Use numbered placeholders in error message in wpdb::prepare().
Props tobifjellner.
Fixes #42142.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-08 09:18:57 +00:00
Gary Pendergast
f0492c5da8 Database: Fix some PHP errors introduced in [41662].
PHP < 5.4 requires a `$matches` parameter to be passed to `preg_match_all()`

`wpdb::prepare()` can be called before translations are loaded, so needs appropriate `wp_load_translations_early()` calls.

See #42040.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 02:45:47 +00:00
Gary Pendergast
1603a9e067 Database: Throw a notice if wpdb::prepare() is called with an incorrect number of arguments
`wpdb::prepare()` currently gives no information if the number of arguments passed doesn't match the number of placeholders in the query. This change gives an explicit notice that the call was incorrect.

Also fixes an enrelated term meta test that was triggering this new notice.

Props thekt12 for the initial patch.
Fixes #42040.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 02:11:47 +00:00
Gary Pendergast
5f19289fc2 Docs: Clarify the docs for wpdb::prepare().
Make the usage of the `%` wildcard in queries clearer.

Props jrf.
Fixes #41983.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 00:22:45 +00:00
Gary Pendergast
c805479c8b Docs: Update the documentation for wpdb::prepare()
The inline documentation for `wpdb::prepare()` was kind of confusing, and didn't describe some of the behaviour correctly.

Fixes #41983.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-28 11:45:45 +00:00
Gary Pendergast
dbd93ddbb6 Database: Add support for connecting to IPv6 hosts
IPv4 addresses are scarce, overworked, and underpaid. They're ready to retire, but we just won't let them go. If you care about their wellbeing, switch to IPv6 today.

Props schlessera, birgire.
Fixes #41722.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-28 05:37:44 +00:00
Gary Pendergast
0028a9555e Database: Don't quote placeholders in queries going through $wpdb->prepare()
To bring Core into line with the changes to `$wpdb->prepare()` in WordPress 4.8.2, query placeholders shouldn't be quoted.

Props jrf, johnjamesjacoby.
Fixes #41983.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-28 04:32:46 +00:00
Aaron Campbell
fc930d3dae Database: Hardening to bring wpdb::prepare() inline with documentation.
`wpdb::prepare()` supports %s, %d, and %F as placeholders in the query string. Any other non-escaped % will be escaped.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 17:56:45 +00:00
Aaron Campbell
5225e026ef Database: Don’t trigger _doing_it_wrong() for null values in wpdb::prepare().
While `wpdb::prepare()` does not support null values (see #12819) they still appear in the wild like in the WordPress Importer and other plugins.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41316 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 16:06:45 +00:00
Aaron Campbell
70b2127909 Database: Hardening for wpdb::prepare()
Previously if you passed an array of values for placeholders, additional values could be passed as well. Now additional values will be ignored.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 14:48:47 +00:00
Felix Arntz
820d3973a3 Multisite: Rename internal $site_id variables referencing networks to $network_id.
This change improves code clarity by using the current naming conventions for networks.

Props lemacarl.
Fixes #41510.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41081 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-12 12:48:47 +00:00
Drew Jaynes
0860bb2771 Docs: Remove @access notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Drew Jaynes
5c075e5af7 Docs: Remove a few more superfluous @package WordPress and @subpackage notations outside of file headers missed in [40988].
See #41017.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40839 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-01 17:11:41 +00:00
John Blackbourn
523b08600f Database: Add documentation for the allowed utf8mb4_520 value when detecting features with wpdb::has_cap().
Props rcutmore

Fixes #41044

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


git-svn-id: http://core.svn.wordpress.org/trunk@40756 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-15 12:00:43 +00:00
John Blackbourn
4cf5550d8d I18n: Begin introducing translator comments for strings which include placeholders but no accompanying translator comment.
Adds context to one string used in two different contexts for the new user and new site signup email notification.

More to come.

See #38882

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


git-svn-id: http://core.svn.wordpress.org/trunk@39263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-21 01:22:32 +00:00
Gary Pendergast
7329283f7e Database: Add support for LIKE-escaped tables in ::get_table_from_query().
The `SHOW TABLES LIKE` query can be used to search for tables that match a pattern, `wp\_123\_%`, for example. While this isn't the name of an actual table, the `wp_123_` prefix can be used by database drop-ins to direct the query correctly. This change removes the escaping and `%` modifier, to provide this usable prefix.

Props andy, pento.
Fixes #38751.


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


git-svn-id: http://core.svn.wordpress.org/trunk@39215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-17 04:21:31 +00:00
John Blackbourn
b9033ad6a1 Docs: Improve the documentation for parameters which accept OBJECT, ARRAY_A, and ARRAY_N as parameters.
See #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@39128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-09 23:00:32 +00:00
Gary Pendergast
2dee7cdffc Database: Fall back to utf8 when utf8mb4 isn't supported.
Sometimes, `DB_CHARSET` will be set to `utf8mb4`, even if the current setup doesn't support `utf8mb4`. After [38442], this can cause significant character set failures, causing the connection to fall back to `latin1`.

Instead of doing this, we now check that the connection supports `utf8mb4` before trying to use it, and fall back to `utf8` when we need to.

Fixes #37982 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-08 23:49:30 +00:00
Gary Pendergast
0cff37abf5 Database: Find the correct table names in DELETE queries with table aliases
Previously, `wpdb::get_table_from_query()` would not find the correct table name in the query `DELETE a FROM table a`, due to not recognising the table alias immediately after the `DELETE` as correct syntax.

Fixes #37660.


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


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


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


git-svn-id: http://core.svn.wordpress.org/trunk@38382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 07:38:32 +00:00
Gary Pendergast
bd084204c1 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.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 07:14:41 +00:00
Scott Taylor
ca70683001 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-22 21:10:28 +00:00
Sergey Biryukov
597c067b67 Docs: Correct usage examples for wpdb::prepare(), which should not be called statically.
Props TJNowell.
Fixes #37744.
Built from https://develop.svn.wordpress.org/trunk@38289


git-svn-id: http://core.svn.wordpress.org/trunk@38230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-20 13:17:30 +00:00
Sergey Biryukov
2cbe10e79c 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.
Built from https://develop.svn.wordpress.org/trunk@38133


git-svn-id: http://core.svn.wordpress.org/trunk@38074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-21 22:45:28 +00:00
Drew Jaynes
e6267dcf19 Docs: Fix formatting, tense, verb conjugation, and other syntax for wp-includes/* elements introduced or changed in 4.6.
Part 2/2.

Fixes #37318.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 19:33:30 +00:00
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(), breaks 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 booleans
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
Gary Pendergast
364886a5be WPDB: When checking that a string can be sent to MySQL, we shouldn't use mb_convert_encoding(), as it behaves differently to MySQL's character encoding conversion.
Props mdawaffe, pento, nbachiyski, jorbin, johnjamesjacoby, jeremyfelt.

See #32165.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-06 03:00:25 +00:00
Gary Pendergast
85d327d4bd In [32299], we should be using mb_strlen() for our string size checks.
Built from https://develop.svn.wordpress.org/trunk@32306


git-svn-id: http://core.svn.wordpress.org/trunk@32277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-27 14:42:27 +00:00
Gary Pendergast
95d5fa28b4 WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.
Built from https://develop.svn.wordpress.org/trunk@32299


git-svn-id: http://core.svn.wordpress.org/trunk@32270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-27 14:03:27 +00:00
Gary Pendergast
16bdf0ab2c WPDB: When sanity checking a string by sending it to MySQL for conversion checks, the incorrect data structure was being returned from wpdb::strip_invalid_text(), causing all write queries to fail for some character sets when the query contained non-ASCII characters.
See #32051.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-22 15:02:28 +00:00
Gary Pendergast
5775586646 WPDB: When deciding if a query needs extra sanity checking based on collation, we can quickly return if the query is entirely ASCII characters.
See #32029.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32207 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-21 05:24:26 +00:00
Gary Pendergast
6f38333ab2 WPDB: When deciding if a query needs extra sanity checking based on collation, we can quickly return if it's a query that will never return user data.
Fixes #32029.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-21 05:11:27 +00:00
Gary Pendergast
2bbd21f543 WPDB: When sanity checking read queries, there are some collations we can skip, for improved performance.
Props pento, nacin.

See #21212.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32137 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-20 04:46:25 +00:00
Dominik Schilling
64fc7294b6 Use HTTPS URLs for codex.wordpress.org.
see #27115.
Built from https://develop.svn.wordpress.org/trunk@32116


git-svn-id: http://core.svn.wordpress.org/trunk@32095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-12 21:29:32 +00:00