Commit Graph

454 Commits

Author SHA1 Message Date
hellofromTonya
807cba060e WPDB: Call wp_load_translations_early() in wpdb::query() and wpdb::process_fields().
For consistency and simplification, replaces the `function_exists( '__' )` checks with `wp_load_translations_early()` to make sure i18n functions are available. This change removes the extra code introduced in [52176] for using non-translated error messages when `__()` is not available.

Improves the plural versions of the error messages.

For performance, when there are more than one problem field, uses `reset()` to populate the field in the error message.

Follow-up to [52176], [52195].

Props sergeybiryukov, hellofromTonya.
Fixes #32315.
Built from https://develop.svn.wordpress.org/trunk@52218


git-svn-id: http://core.svn.wordpress.org/trunk@51810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-19 19:00:00 +00:00
Sergey Biryukov
173a9cb89a Database: Check if the $args[0] value exists in wpdb::prepare() before accessing it.
This avoids an `Undefined array key 0` PHP warning if no values are passed to the method besides the query string.

Follow-up to [41470].

Props mjaschen.
Fixes #54453.
Built from https://develop.svn.wordpress.org/trunk@52206


git-svn-id: http://core.svn.wordpress.org/trunk@51798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-18 14:37:01 +00:00
Sergey Biryukov
5e48f0c591 WPDB: Call wp_load_translations_early() in wpdb::_real_escape().
This follows the pattern used in other `wpdb` methods to make sure the i18n functions are available.

Follow-up to [29840].

Props nacin, johnbillion.
See #32315.
Built from https://develop.svn.wordpress.org/trunk@52195


git-svn-id: http://core.svn.wordpress.org/trunk@51787 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-17 04:05:02 +00:00
hellofromTonya
7a4c5007b6 WPDB: Capture error in wpdb::$last_error when insert fails instead of silently failing for invalid data or value too long.
Instead of silently failing when attempting to insert a value into a field, this commit saves the error in the `wpdb::$last_error` property.

Sets `last_error` with an error message if:
* `wpdb::query()` fails for invalid data
* `wpdb::process_fields()` fails to process the value(s) for the field(s) where the value could be too long or contain invalid data

Sets `last_query` if `wpdb::query()` fails for invalid data.

If `__()` is not available, uses non-translated error message to ensure the error is captured.

There is no change to wpdb aborting when an error occurs.

Adds tests.

Props dlt101, mnelson4, dd32, pento, hellofromTonya, davidbaumwald, sergeybiryukov, johnbillion, swissspidy, datainterlock, anandau14, anthonyeden, asif2bd, audrasjb, chaion07, dpegasusm, fpcsjames, galbaras, jdgrimes, justindocanto, kwisatz, liammitchell, lucasw89, lukecarbis, nettsite, nlpro, procodewp, psufan, richardfoley, skunkbad, travisnorthcutt, woodyhayday, zoiec.
Fixes #37267.
Built from https://develop.svn.wordpress.org/trunk@52176


git-svn-id: http://core.svn.wordpress.org/trunk@51768 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-16 02:59:00 +00:00
hellofromTonya
234877c9c3 Coding Standards: Add public visibility to methods in src directory.
This commit adds the `public` visibility keyword to each method which did not have an explicit visibility keyword.

Why `public`?

With no visibility previously declared, these methods are implicitly `public` and available for use. Changing them to anything else would be a backwards-compatibility break.

Props costdev, jrf.
See #54177.
Built from https://develop.svn.wordpress.org/trunk@51919


git-svn-id: http://core.svn.wordpress.org/trunk@51512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 17:52:58 +00:00
John Blackbourn
6e1cc35a98 Docs: Miscellaneous docblock corrections and improvements.
See #52217, #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 21:23:00 +00:00
hellofromTonya
d345fe2e69 Code Modernization: Fix "passing null to non-nullable" deprecation in wpdb::_real_escape().
The PHP native `mysqli_real_escape_string()` function expects to be passed a string as the second parameter and this is not a nullable parameter.

Passing `null` to it will result in a `mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated` notice on PHP 8.1.

Previously, an input type check was put in place to prevent fatal errors on PHP 8.0 when an array, object or resource was passed. Changeset [48980].

A `null` value was explicitly excluded from that check, even though a `null` value being passed would only ever result in an empty string anyway.

This commit changes the previous input type check to also bow out early for `null` values and to automatically return an empty string for those.

Refs:
- https://www.php.net/manual/en/mysqli.real-escape-string.php
- https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Follow-up to [48980].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51799


git-svn-id: http://core.svn.wordpress.org/trunk@51406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 16:36:57 +00:00
Sergey Biryukov
988c8be693 Code Modernization: Set the MySQLi error reporting off for PHP 8.1.
Prior to PHP 8.1, the default error handling mode was `MYSQLI_REPORT_OFF`. An error in the extension, database, query, or the database connection returned `false` and emitted a PHP warning:
{{{
$mysqli = new mysqli("localhost", "non-existing-user", "", "");

Warning: mysqli::__construct(): (HY000/2002): No connection could be made because the target machine actively refused it in ... on line ...
}}}

From PHP 8.1 and later, the default error mode is set to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT`. An error in the extension, database, query, or the database connection throws an exception:
{{{
$mysqli = new mysqli("localhost", "non-existing-user", "", "");

Fatal error: Uncaught mysqli_sql_exception: Connection refused in ...:...
}}}

WordPress has its own error reporting and gracefully handles the database errors by inspecting the error codes. Setting the MySQLi error reporting to off avoids fatal errors due to uncaught exceptions and maintains the current behavior.

References:
* [https://php.watch/versions/8.1/mysqli-error-mode PHP 8.1: MySQLi: Default error mode set to exceptions]
* [https://wiki.php.net/rfc/mysqli_default_errmode PHP RFC: Change Default mysqli Error Mode]

Props ayeshrajans, jrf.
Fixes #52825.
Built from https://develop.svn.wordpress.org/trunk@51582


git-svn-id: http://core.svn.wordpress.org/trunk@51193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-08 14:10:01 +00:00
John Blackbourn
0434d4d30b Docs: Miscellaneous docblock corrections and improvements.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51088 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-22 16:54:58 +00:00
Sergey Biryukov
c51c4ab729 Code Modernization: Only check collation in wpdb methods if the query is not empty.
This avoids a deprecation notice on PHP 8.1 caused by passing `null` instead of a string to `ltrim()` in `wpdb::check_safe_collation()`, and maintains the current behaviour.

Follow-up to [30345], [32162], [33455].

See #53635.
Built from https://develop.svn.wordpress.org/trunk@51396


git-svn-id: http://core.svn.wordpress.org/trunk@51007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-10 11:15:59 +00:00
John Blackbourn
79685db062 Docs: Corrections and improvements to types used in docblocks for symbols, properties, and filters.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@50907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-01 21:02:57 +00:00
John Blackbourn
f0078d043e Docs: Miscellaneous docblock corrections and improvements.
See #51800.
Built from https://develop.svn.wordpress.org/trunk@49942


git-svn-id: http://core.svn.wordpress.org/trunk@49641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-07 14:17:11 +00:00
Sergey Biryukov
ee7c953731 Docs: Second pass at replacing Codex URLs with a corresponding HelpHub or DevHub article.
Follow-up to [45674-45677].

Props marcio-zebedeu, zodiac1978, netweb.
See #48987.
Built from https://develop.svn.wordpress.org/trunk@49912


git-svn-id: http://core.svn.wordpress.org/trunk@49611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-12-29 20:14:11 +00:00
Sergey Biryukov
30d9432760 Code Modernization: Use explicit visibility for class property declarations.
Using `var` or only `static` to declare a class property is PHP 4 code.

This updates the codebase to use explicit visibility modifiers introduced in PHP 5.

Props jrf.
Fixes #51557. See #22234.
Built from https://develop.svn.wordpress.org/trunk@49184


git-svn-id: http://core.svn.wordpress.org/trunk@48946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-17 16:26:09 +00:00
Sergey Biryukov
e43ff0e991 Code Modernization: Return false from wpdb::query() if the query was filtered to an empty string using the query filter.
This avoids a fatal error on PHP 8 caused by passing an empty string to `mysqli_query()`, and maintains the current behaviour.

Follow-up to [48980], [48981].

See #50913, #50639.
Built from https://develop.svn.wordpress.org/trunk@49072


git-svn-id: http://core.svn.wordpress.org/trunk@48834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-30 12:09:08 +00:00
Sergey Biryukov
eef2e5c85c Code Modernization: Return an empty string from wpdb::prepare() if there are not enough arguments to match the placeholders.
This avoids a fatal error on PHP 8 caused by passing mismatched arguments to `vsprintf()`, and maintains the current behaviour.

Follow-up to [48979], [48980].

See #50913, #50639.
Built from https://develop.svn.wordpress.org/trunk@48981


git-svn-id: http://core.svn.wordpress.org/trunk@48743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-16 02:29:06 +00:00
Sergey Biryukov
9734ed5673 Code Modernization: Return an empty string from wpdb::_real_escape() if a non-scalar value is passed.
This avoids a fatal error on PHP 8 caused by passing a non-string value to ` mysqli_real_escape_string()`, and maintains the current behaviour.

See #50913, #50639.
Built from https://develop.svn.wordpress.org/trunk@48980


git-svn-id: http://core.svn.wordpress.org/trunk@48742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-16 01:48:10 +00:00
Sergey Biryukov
d936f2c959 Docs: Miscellaneous DocBlock corrections.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48591


git-svn-id: http://core.svn.wordpress.org/trunk@48353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:55:04 +00:00
John Blackbourn
9bc7d0a776 Docs: Another pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48590


git-svn-id: http://core.svn.wordpress.org/trunk@48352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:11:05 +00:00
Sergey Biryukov
d9a18d259b Coding Standards: Use strict comparison in wp-includes/wp-db.php.
Props jenilk.
Fixes #49453.
Built from https://develop.svn.wordpress.org/trunk@48507


git-svn-id: http://core.svn.wordpress.org/trunk@48269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-18 11:39:04 +00:00
Sergey Biryukov
00a40b1ef2 Docs: Capitalize "ID", when referring to a user ID, term ID, etc. in a more consistent way.
Follow-up to [48104]

See #49572.
Built from https://develop.svn.wordpress.org/trunk@48200


git-svn-id: http://core.svn.wordpress.org/trunk@47969 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-28 14:09:04 +00:00
Andrea Fercia
ae447adaf4 I18N: Restore the "Error:" prefix for error messages.
Partially reverts [48059] as there's no full consensus on the removal of the text prefix. Further actions should be taken to improve consistency and accessibility of the admin notices. Keeps some improvements to the translatable strings from [48059].

Fixes #47656.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47884 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-21 14:00:09 +00:00
John Blackbourn
1a77bb81d8 Docs: Remove unnecessary variables names from @return tags.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48100


git-svn-id: http://core.svn.wordpress.org/trunk@47869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 22:55:12 +00:00
Andrea Fercia
f83c504b88 I18N: Remove the "Error:" prefix from error messages.
For a number of years, most of the WordPress error messages have been prefixed with "Error:". However, these messages appear in a context where it's already clear an error occurred. Whether it's an error, a warning, or any other classification, that's not so relevant for users. The content of the message is the relevant part. The "Error:" prefix doesn't add great value while it does add unnecessary complexity for the message readability.

Also, revises some of these messages to improve clarity and removes HTML from translatable strings.

Props garrett-eclipse, ramiy, SergeyBiryukov, afercia, sabernhardt, quadthemes, audrasjb. 
See #47003, #43037, #42945, #15887.
Fixes #47656.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47826 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-16 15:35:13 +00:00
Sergey Biryukov
72ef4ae81a Docs: Further update inline documentation for the wpdb class per the documentation standards.
Restore some previous edits from [46696], [47060], [47122], [47230] that were accidentally reverted in [47740].

See #49572.
Built from https://develop.svn.wordpress.org/trunk@47749


git-svn-id: http://core.svn.wordpress.org/trunk@47525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-03 11:45:06 +00:00
John Blackbourn
736874a51e Docs: Update inline documentation for the wpdb class.
Props theMikeD

Fixes #49477
Built from https://develop.svn.wordpress.org/trunk@47740


git-svn-id: http://core.svn.wordpress.org/trunk@47516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-02 17:25:07 +00:00
Sergey Biryukov
38676936ba Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-05 03:02:11 +00:00
Sergey Biryukov
c8cc78671b Database: Introduce wpdb::db_server_info() to retrieve full MySQL server information string as supplied by mysqli_get_server_info().
This complements `wpdb::db_version()`, which only returns a numeric version string and strips any additional information, e.g. vendor name.

Props clarinetlord, birgire, webaware, pento.
Fixes #40037. See #27703.
Built from https://develop.svn.wordpress.org/trunk@47451


git-svn-id: http://core.svn.wordpress.org/trunk@47238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-12 15:55:07 +00:00
Sergey Biryukov
32edd58e4c Docs: Add descriptions for some globals:
* `$wp_version`
* `$wp_local_package`
* `$required_php_version`
* `$required_mysql_version`

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


git-svn-id: http://core.svn.wordpress.org/trunk@47030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-10 03:30:06 +00:00
Sergey Biryukov
641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
47ed56f38f Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`.

This commit also includes:

* Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls.
* Replacing `include` statements for several files with `require_once`, for consistency:
 * `wp-admin/admin-header.php`
 * `wp-admin/admin-footer.php`
 * `wp-includes/version.php`

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.
Built from https://develop.svn.wordpress.org/trunk@47198


git-svn-id: http://core.svn.wordpress.org/trunk@46998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 06:33:11 +00:00
Sergey Biryukov
143c6a1de8 Database: Add ANSI to the list of incompatible SQL modes.
Starting with MySQL 5.7.5, the `ANSI` mode implies `ONLY_FULL_GROUP_BY`, which is already listed in `wpdb` as incompatible per [27072].

When `ANSI` is enabled on MySQL 5.7.5+, `ONLY_FULL_GROUP_BY` remains enabled even after being "unset" by `wpdb::set_sql_mode()`.

To prevent this, the `ANSI` mode should also be listed as incompatible. It is not enabled on default MySQL installations.

Props jnylen0.
Fixes #48377.
Built from https://develop.svn.wordpress.org/trunk@47171


git-svn-id: http://core.svn.wordpress.org/trunk@46971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-04 01:14:07 +00:00
Sergey Biryukov
deb1886078 Accessibility: Text Changes: Use sentence case for the word Error in various error messages, instead of all caps.
Using all caps should be avoided for better readability and because screen readers may pronounce all-caps words as abbreviations.

Props afercia, ryokuhi, sabernhardt, garrett-eclipse.
See #47656, #43037, #42945.
Built from https://develop.svn.wordpress.org/trunk@47156


git-svn-id: http://core.svn.wordpress.org/trunk@46956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-01 21:38:04 +00:00
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