Commit Graph

471 Commits

Author SHA1 Message Date
Sergey Biryukov 001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov c67b2c235a Cache API: Remove `WP_Object_Cache::__destruct()` and `wpdb::__destruct()`.
Originally added in [4686], these constructor/destructor pairings were designed to prevent the objects from being destroyed before shutdown, when output buffers are flushed.

A deeper investigation reveals that this approach didn't quite work as expected and was later made redundant by introducing `wp_ob_end_flush_all()` in [5462].

Props wonderboymusic, nacin, Mte90, SergeyBiryukov.
Fixes #21402.
Built from https://develop.svn.wordpress.org/trunk@47107


git-svn-id: http://core.svn.wordpress.org/trunk@46907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-23 00:27:05 +00:00
Sergey Biryukov 2900bb8ea7 Docs: Update links to https://secure.php.net/, they now redirect to https://www.php.net/.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47088


git-svn-id: http://core.svn.wordpress.org/trunk@46888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-20 03:14:06 +00:00
Sergey Biryukov dd4d98a368 Docs: In various `@return` tags, list the expected type first, instead of `false`.
Follow-up to [46696].

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47060


git-svn-id: http://core.svn.wordpress.org/trunk@46860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-11 18:32:05 +00:00
Sergey Biryukov 3d623995a8 Docs: In various `@return` tags, list the expected type first, instead of `WP_Error`.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@46696


git-svn-id: http://core.svn.wordpress.org/trunk@46496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-11 02:43:03 +00:00
John Blackbourn f545bb3f63 Docs: Improve documentation of known return types, plus other docs fixes.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 21:23:02 +00:00
Sergey Biryukov 8d1e51e9c7 Docs: Add a `@since` note about new parameters with the spread operator added to function signatures.
Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46451


git-svn-id: http://core.svn.wordpress.org/trunk@46249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-09 04:28:02 +00:00
John Blackbourn e36d1bcbd8 Docs: Docblock corrections and improvements, mostly related to various `pre_*` filters.
See #47110

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


git-svn-id: http://core.svn.wordpress.org/trunk@46044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-21 17:41:57 +00:00
whyisjake a014bd21c1 Multisite: Remove the redundant `blog_versions` table.
As part of the Multisite installation process, a `blog_versions` table is created. This table is never read from (except immediately prior to updating it), it's only ever inserted into or updated. It is not used to determine which blogs need to be upgraded.
This table was introduced in 3.0 when the WPMU schema was merged #11644 and it appears the table has never been used in core and is therefore redundant and may as well be removed.

Props johnbillion, nacin, ryan, johnjamesjacoby, whyisjake.

Fixes #19755. See #41685.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46006 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-19 22:07:57 +00:00
Sergey Biryukov e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
Sergey Biryukov 16b8d91baa I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.

Includes minor code layout fixes.

Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!

Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926


git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 17:13:59 +00:00
Sergey Biryukov 2d574d673f Database: Use a strict comparison for `has_filter()` check in `wpdb::placeholder_escape()`.
The filter is added with a priority of `0`, so a loose comparison had an unintended effect of adding the filter on every call.

Props withinboredom.
Fixes #47430.
Built from https://develop.svn.wordpress.org/trunk@45707


git-svn-id: http://core.svn.wordpress.org/trunk@45518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-01 02:25:56 +00:00
Gary Pendergast a571a7d621 Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.
PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

Props jrf.
See #47704.



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


git-svn-id: http://core.svn.wordpress.org/trunk@45450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-15 06:25:57 +00:00
Gary Pendergast fbdb267634 WPDB: Allow custom data to be added to logged queries.
This adds a new method, `wpdb::log_query()`, and a new filter, `log_query_custom_data`. The custom data is stored as a new element in each entry of the `wpdb::$queries` array.

Props CrazyJaco, johnbillion, pento.
Fixes 42151.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-15 04:07:57 +00:00
Gary Pendergast 4d3a84aa9f Code Modernisation: Introduce the spread operator in `wpdb::prepare()`.
Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Props jrf.
See #47678.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-12 00:17:57 +00:00
Gary Pendergast abcbee954f Coding Standards: Fix instances of `WordPress.PHP.NoSilencedErrors.Discouraged`.
Noteable changes:
- The `magic_quotes_runtime` and `magic_quotes_sybase` settings were removed in PHP 5.4, so no longer need to be set.
- Some functions that use external libraries can generate errors that can't be tested for, so are globally allowed to silence errors.
- Quite a few functions would cause errors if `safe_mode` was set. This setting was removed in PHP 5.4.
- Only a handful of `header()` calls needed corresponding `headers_sent()` checks for unit tests to pass, but more may need to be added as the nightlies builds are tested.

See #46732.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-09 05:45:58 +00:00
Gary Pendergast 87675d288b Coding Standards: Fix all `WordPress.WhiteSpace.PrecisionAlignment` issues.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45413 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-05 05:21:56 +00:00
Sergey Biryukov b8be081e7e Text Changes: Use consistent question wording in database connection error messages.
Props Presskopp.
See #44878.
Built from https://develop.svn.wordpress.org/trunk@45598


git-svn-id: http://core.svn.wordpress.org/trunk@45409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-04 10:58:56 +00:00
Gary Pendergast 4803fc405e Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Sergey Biryukov 5ec3c66bd3 Docs: Correct `@type` annotation for `wpdb::$last_query`.
Props nextendweb, mukesh27.
Fixes #47095.
Built from https://develop.svn.wordpress.org/trunk@45430


git-svn-id: http://core.svn.wordpress.org/trunk@45241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 02:30:51 +00:00
John Blackbourn 9c6393e967 Docs: Switch to the more common syntax for variadic function documentation.
See #37402

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


git-svn-id: http://core.svn.wordpress.org/trunk@45229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-25 21:59:51 +00:00
Sergey Biryukov d2ccaacedf Docs: Correct spelling in various comments and DocBlocks, per the conventions in Core Contributor Handbook.
Props man4toman, samanehmirrajabi.
Fixes #45857.
Built from https://develop.svn.wordpress.org/trunk@45232


git-svn-id: http://core.svn.wordpress.org/trunk@45041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-17 13:26:51 +00:00
Gary Pendergast 4487551344 Help: Update support forum links.
There are a lot of places in Core that link to https://wordpress.org/support/ for the support forums, but that's now the URL for HelpHub. The new forums link is https://wordpress.org/support/forums/.

Props jitendrabanjara1991, dilipbheda, mukesh27, ianbelanger.
Fixes #46790.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 22:59:56 +00:00
John Blackbourn 9e67ba895d Docs: Correct some documentation typos.
See #46543

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


git-svn-id: http://core.svn.wordpress.org/trunk@44844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-27 17:09:52 +00:00
Sergey Biryukov 5404ae4949 Docs: Remove unnecessary `@see` tag in `wpdb::prepare()`.
The tag is only necessary for hooks. For functions and methods, autolinking is handled automatically on developer.wordpress.org.

Props mbelchev, ocean90, johannadevos.
Fixes #44585. See #45204.
Built from https://develop.svn.wordpress.org/trunk@44901


git-svn-id: http://core.svn.wordpress.org/trunk@44732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-15 11:18:50 +00:00
Gary Pendergast 3cbd512161 Coding Standards: Ignore the violations of `Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase`.
See #45934.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-11 06:08:50 +00:00
Felix Arntz 035877708d Multisite: Update `@since` tags for site meta introduction.
Fixes #37923. Fixes #40229.

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


git-svn-id: http://core.svn.wordpress.org/trunk@44298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-08 08:18:50 +00:00
Sergey Biryukov 312e0d6d60 Docs: Update `@since` tag for the addition of query start time to logged query data.
Fixes #43315.
Built from https://develop.svn.wordpress.org/trunk@44345


git-svn-id: http://core.svn.wordpress.org/trunk@44175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-20 00:59:47 +00:00
Drew Jaynes 1ae038d3db Docs: Update an inline `@see` reference in the DocBlock for wpdb::prepare() to reference `wpdb::esc_like()` the method instead of `esc_like()` the nonexistent function.
Props antaltettinger.
Fixes #45204. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@44160 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 07:30:48 +00:00
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