Commit Graph

117 Commits

Author SHA1 Message Date
Drew Jaynes
d11f7ed391 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.


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

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

Props ocean90.
Fixes #36835.


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


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

Fixes #36629 for trunk.
See #21870.



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


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


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



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


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


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

Fixes #34903.



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

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


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


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

Fixes #34708.



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

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

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

Fixes #34216.

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

This is based on [backpress 279].

Props pento, nbachiyski, sorich87.

Fixes #15158.



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

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

Fixes #33501.



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

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

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

Props boonebgorges, sirzooro.
See #10142.

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

Props markoheijnen, johnbillion.

Fixes #33105.



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


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


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


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


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

Fixes #33470.



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


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


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



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

Fixes #32279.



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



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



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



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

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

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


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

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


git-svn-id: https://develop.svn.wordpress.org/trunk@32964 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-27 01:02:12 +00:00
Scott Taylor
5f8df2290f Add missing/alter existing doc blocks for wp-db.php.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32641 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-28 20:09:54 +00:00
Scott Taylor
5e20854d3d 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@32640 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-28 16:33:31 +00:00
Scott Taylor
6378cb5d60 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@32515 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-19 20:29:30 +00:00
Gary Pendergast
ba24459a63 The UTF-8 regex can occasionally fail on very low memory machines. Reduce the amount of memory it uses.
See #32204.



git-svn-id: https://develop.svn.wordpress.org/trunk@32375 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-06 06:57:44 +00:00
Gary Pendergast
ed53ad2c53 WPDB: When sanity checking query character sets, there's no need to check queries that don't return user data.
See #32104.



git-svn-id: https://develop.svn.wordpress.org/trunk@32374 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-06 06:04:50 +00:00
Gary Pendergast
923c6c981b 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@32368 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-06 05:00:39 +00:00
Gary Pendergast
2ce97b2984 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@32364 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-06 02:59:50 +00:00
Gary Pendergast
0152b8f49b In [32299], we should be using mb_strlen() for our string size checks.
git-svn-id: https://develop.svn.wordpress.org/trunk@32306 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-27 14:41:48 +00:00
Gary Pendergast
45b0abbef1 WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.
git-svn-id: https://develop.svn.wordpress.org/trunk@32299 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-27 14:02:45 +00:00
Gary Pendergast
cc8a9824c5 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@32261 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-22 15:01:25 +00:00
Gary Pendergast
afe046a84c 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@32233 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-21 05:23:44 +00:00
Gary Pendergast
0fe5a64e56 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@32232 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-21 05:10:11 +00:00
Gary Pendergast
faa66d8145 WPDB: When sanity checking read queries, there are some collations we can skip, for improved performance.
Props pento, nacin.

See #21212.



git-svn-id: https://develop.svn.wordpress.org/trunk@32162 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 04:45:12 +00:00
Dominik Schilling (ocean90)
b0d6757918 Use HTTPS URLs for codex.wordpress.org.
see #27115.

git-svn-id: https://develop.svn.wordpress.org/trunk@32116 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-12 21:28:58 +00:00