Commit Graph

441 Commits

Author SHA1 Message Date
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
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