Commit Graph

2546 Commits

Author SHA1 Message Date
Felix Arntz 1515787d31 Multisite: Add `$network_id` parameter to `wp_is_large_network()`.
Now that `get_blog_count()` and `get_user_count()` both support passing a `$network_id` parameter (see [40370] and [40371]), similar functionality is now available for `wp_is_large_network()`. In addition, the filter `wp_is_large_network` now accepts the network ID as its fourth parameter.

This changeset furthermore introduces unit tests for the `wp_is_large_network()` function and its filter.

Fixes #40489.


git-svn-id: https://develop.svn.wordpress.org/trunk@40590 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-09 15:50:04 +00:00
Felix Arntz 48661c4b00 Multisite: Introduce `minimum_site_name_length` filter.
Prior to this change, the minimum site name length checked in `wpmu_validate_blog_signup()` was set to a fixed value of 4. The new filter allows tweaking this value, as there may be cases where shorter site names may be required.

Fixes #39676.


git-svn-id: https://develop.svn.wordpress.org/trunk@40589 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-09 14:58:39 +00:00
Andrew Ozz 656718a645 Fix linting errors in tinymce-obsolete.js.
See #40690.

git-svn-id: https://develop.svn.wordpress.org/trunk@40585 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-08 06:05:39 +00:00
Andrew Ozz 1727d6fbef TinyMCE: remove the pre-4.6.0 tests. Move regression testing for obsolete tags and attributes to the default QUnit tests.
See #40690.

git-svn-id: https://develop.svn.wordpress.org/trunk@40584 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-08 05:35:41 +00:00
John Blackbourn 45b183ea79 Users: Correct a permission check when showing the User item in the `+ New` admin toolbar menu.
Props dlh
Fixes #39252


git-svn-id: https://develop.svn.wordpress.org/trunk@40581 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-07 17:41:24 +00:00
Joe Hoyle cc661013cf REST API: WP_REST_Request::remove_header() should canonicalize header names.
When headers are stored in WP_REST_Request internally they are canonicalized. This step already happens on setting / getting headers in any way, but was missed when implementing remove_header().

Props TimothyBlynJacobs.
Fixes #40347.


git-svn-id: https://develop.svn.wordpress.org/trunk@40577 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-07 04:08:42 +00:00
John Blackbourn c759785cea Build/Test Tools: Automatically skip tests in the `ms-required` and `ms-excluded` groups.
This removes the need to manually call `$this->skipWithMultisite()` and `$this->skipWithoutMultisite()` from within the test when the test only runs without Multisite or only runs on Multisite, respectively.

Props jdgrimes for the suggestion.

Fixes #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40564 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-01 20:34:10 +00:00
John Blackbourn f72ce6dc6e Users: Add two missing special cases to the capability tests for non-logged-in users.
Also updates a `expectedIncorrectUsage` notation.

See #37405


git-svn-id: https://develop.svn.wordpress.org/trunk@40563 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-01 16:18:19 +00:00
John Blackbourn 46fab9de51 Build/Test Tools: Add object-cache.php to the unit test suite.
This removes an unnecessary external dependency from the Travis tests.

Fixes #40619


git-svn-id: https://develop.svn.wordpress.org/trunk@40561 602fd350-edb4-49c9-b593-d223f7449a82
2017-05-01 11:20:30 +00:00
John Blackbourn c2fd41759c Users: Ensure user counts remain accurate if users are added to or removed from the `users` table without corresponding `usermeta` entries being added or removed.
This has a slight performance impact on sites with a large number of users when the `time` strategy is used for counting users. Hopefully this impact will be negated by enhancements proposed in #38741.

Props psoluch, dots, boonebgorges, ptbello, tharsheblows

Fixes #29785


git-svn-id: https://develop.svn.wordpress.org/trunk@40560 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-30 13:02:50 +00:00
John Blackbourn 7c1d20422f Posts, Post Types: Revert [40558] pending investigation.
See #18375


git-svn-id: https://develop.svn.wordpress.org/trunk@40559 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-30 11:18:43 +00:00
John Blackbourn 0940f8396c Posts, Post Types: Correct the attachment post type template unit test introduced in [38951].
Also adds additional assertions for the templates.

See #18375


git-svn-id: https://develop.svn.wordpress.org/trunk@40558 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-29 21:15:34 +00:00
Boone Gorges 7c4248b5e0 Fix broken `check_comment()` test.
The test `Tests_Comment_CheckComment::test_should_return_true_when_content_does_not_match_moderation_keys()`
did not, in fact, test for a `true` value, but for a false one.
Switching to `assertTrue()` caused a failure, because the test comment
triggered the 'comment_moderation' test. As in other tests in the file,
the solution is to force 'comment_moderation' to 0 for the purposes of
the test.

Introduced in [32519].

Props stephdau.
Fixes #40584.

git-svn-id: https://develop.svn.wordpress.org/trunk@40557 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-27 16:22:36 +00:00
John Blackbourn 626547e9cf Feeds: Remove an incorrect usage of `sizeof()` in a helper class used during unit testing of XML element handling.
This also helps tidy up the test output when running PHP 7.2.

See #40109


git-svn-id: https://develop.svn.wordpress.org/trunk@40555 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-24 01:22:39 +00:00
John Blackbourn 4602012570 REST API: Remove a useless unit test.
See #35907, #38373


git-svn-id: https://develop.svn.wordpress.org/trunk@40545 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 22:19:29 +00:00
John Blackbourn a16ada6d31 Build/Test Tools: Remove more unnecessary test skipping when erroneous situations occur.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40544 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 22:11:52 +00:00
John Blackbourn 64f8351da1 Build/Test Tools: Introduce `skipWithoutMultisite()` and `skipWithMultisite`() methods into the test suite.
This brings much needed uniformity to test skipping when a test requires Multisite or when a test should be excluded from running when Multisite is enabled.

Used in conjunction with the `@group ms-required` and `@group ms-excluded` notation, this removes a significant number of skipped tests from the default test suite run.

Fixes #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40543 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 21:57:31 +00:00
John Blackbourn e3a9d87083 Build/Test Tools: More tweaks to the deprecated calls assertion. This needs to be triggered when there are unexpected deprecated calls or wrongdoings too.
See #40538


git-svn-id: https://develop.svn.wordpress.org/trunk@40542 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 21:34:37 +00:00
John Blackbourn 21ce4e90d3 Build/Test Tools: Only perform an assertion for deprecated calls and wrongdoings if any are expected.
This avoids masking risky tests that don't otherwise perform an assertion.

See #40538


git-svn-id: https://develop.svn.wordpress.org/trunk@40541 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 21:28:44 +00:00
John Blackbourn f5bf5ba8b8 Build/Test Tools: Move the `setExpectedException()` method into the `WP_Ajax_UnitTestCase` class to avoid a fatal error when PHPUnit 3.6 is in use.
This needs more investigation but it gets the test suite on PHP 5.2 passing again.

See #39822


git-svn-id: https://develop.svn.wordpress.org/trunk@40539 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 11:45:46 +00:00
John Blackbourn ce8a915c06 Build/Test Tools: Add support for PHPUnit 6+.
This adds a compatibility shim for the new namespaced structure of PHPUnit and the removed `setExpectedException()` method. In addition, this updates the Travis config so PHPUnit 6.1 is used where appropriate.

Props miyauchi, gitlost.

Fixes #39822


git-svn-id: https://develop.svn.wordpress.org/trunk@40536 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 02:05:12 +00:00
John Blackbourn 208a5dd57f Build/Test Tools: Ensure that `WP_UnitTestCase::expectedDeprecated()` performs an assertion to avoid risky test notices.
See #40538


git-svn-id: https://develop.svn.wordpress.org/trunk@40535 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 01:44:13 +00:00
John Blackbourn a5a1a4d20e Build/Test Tools: Be strict about tests that do not test anything.
See #40538


git-svn-id: https://develop.svn.wordpress.org/trunk@40534 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-23 01:24:41 +00:00
John Blackbourn c0910cd442 Build/Test Tools: Remove unnecessary checks and skips that should instead cause failures if they ever fail.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40533 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 22:54:15 +00:00
John Blackbourn 669bd1bbc3 Build/Test Tools: Convert more test skipping into hard failures. These dependencies should all be present when testing.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40532 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 22:11:56 +00:00
John Blackbourn 446189eac7 Build/Test Tools: Convert more test skipping into hard failures. These dependencies should all be present when testing.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40531 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 22:00:15 +00:00
John Blackbourn b060b7e503 Build/Test Tools: Correct an incorrect `ms-` group name.
See #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40530 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 21:43:13 +00:00
John Blackbourn 583e7a41bc Build/Test Tools: Partially revert [40524].
See #40533, #40535


git-svn-id: https://develop.svn.wordpress.org/trunk@40529 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 21:21:30 +00:00
John Blackbourn f017338460 Build/Test Tools: Don't trigger a skipped test when the built version of `wp-embed.min.js` isn't present.
The grunt command assertion prior to the check for the existence of the file is enough to safeguard this test.

See #34698, #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40526 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 20:17:49 +00:00
John Blackbourn d4effd5d6b Build/Test Tools: Replace test skipping with actual assertions when dealing with the `DISALLOW_UNFILTERED_HTML`, `DISALLOW_FILE_MODS`, and `DISALLOW_FILE_EDIT` constants.
If any of these constants are set during testing, they should cause the tests to fail, not to be skipped, otherwise we have a situation where failure conditions are never seen.

See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40525 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 20:12:29 +00:00
John Blackbourn 950b185aa7 Build/Test Tools: Remove more skipped tests that should actually be failures if their conditions aren't satisfied.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40524 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 19:42:12 +00:00
John Blackbourn b987aa93a7 Build/Test Tools: Remove ancient UT ticket handling.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40523 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 19:38:42 +00:00
John Blackbourn caf86dc849 Build/Test Tools: Add some more tests to the `ms-required` and `ms-excluded` groups.
See #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40522 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 19:21:11 +00:00
John Blackbourn 021dce3aa2 Build/Test Tools: Remove a useless test.
See #33898, #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40521 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 19:09:09 +00:00
John Blackbourn 4f8057f7d5 Build/Test Tools: Introduce `ms-required` and `ms-excluded` groups for tests.
Tests in the `ms-excluded` group are now excluded when running tests with multisite enabled, and tests in the `ms-required` group are excluded when running tests without multisite enabled. The end result is a significantly reduced number of skipped tests polluting PHPUnit's output, which means verbose mode can be used to more easily see which tests are skipped or incomplete, and why.

See #40531


git-svn-id: https://develop.svn.wordpress.org/trunk@40520 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 18:58:46 +00:00
John Blackbourn c717bfbba9 Build/Test Tools: Don't skip tests when php.net or dev.mysql.com are unreachable.
This sort of behaviour subtly hides the fact that these tests will never fail if the URLs where version number information is fetched from go away for one reason or another.

See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40519 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 18:44:18 +00:00
John Blackbourn 040b411ec2 Build/Test Tools: Avoid skipping canonical tests that are connected to open Trac tickets.
This is a remnant of the test suite behaviour before #30284 fixed most of it and makes it far too easy to hide failing tests.

If any tests begin to fail as a result of this change then they should be fixed.

Fixes #40534


git-svn-id: https://develop.svn.wordpress.org/trunk@40518 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 18:25:30 +00:00
John Blackbourn 2eb8cb7ca2 Canonical: Don't skip tests if the test data is invalid.
See #40533


git-svn-id: https://develop.svn.wordpress.org/trunk@40517 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-22 17:29:03 +00:00
Boone Gorges ccd942ddaa Restore support for taxonomy 'args' override when querying object terms.
[7520] introduced an undocumented feature whereby developers could
register a custom taxonomy with an 'args' parameter, consisting of
an array of config params that, when present, override corresponding
params in the `$args` array passed to `wp_get_object_terms()` when
using that function to query for terms in the specified taxonomy.

The `wp_get_object_terms()` refactor in [38667] failed to respect
this secret covenant, and the current changeset atones for the
transgression.

Props danielbachhuber.
Fixes #40496.

git-svn-id: https://develop.svn.wordpress.org/trunk@40513 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-21 19:13:51 +00:00
Felix Arntz 7966b89e29 Multisite: Add `$network_id` parameter to `wp_update_network_counts()`.
After the `$network_id` parameter has been introduced for `wp_update_network_site_counts()` in [40484] and `wp_update_network_user_counts()` in [40485], the new parameter can now also be used on the wrapping function.

Fixes #40386. See #38699.


git-svn-id: https://develop.svn.wordpress.org/trunk@40486 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-20 00:26:30 +00:00
Felix Arntz d6297c051e Multisite: Add `$network_id` parameter to `wp_update_network_user_counts()`.
Using the new parameter, it is now possible to update the user count on a network different from the current one. While the count itself is technically a global user count and not network-wide, it is stored on each individual network, and the new parameter provides more control about where to update the count.

Fixes #40349. See #38699.


git-svn-id: https://develop.svn.wordpress.org/trunk@40485 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-20 00:13:41 +00:00
Felix Arntz 9bf39fa0fc Multisite: Add `$network_id` parameter to `wp_update_network_site_counts()`.
Using the new parameter, it is now possible to update the site counts on a network different from the current network.

Props PieWP, johnjamesjacoby.
Fixes #37528. See #38699.


git-svn-id: https://develop.svn.wordpress.org/trunk@40484 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-19 23:59:16 +00:00
Dominik Schilling (ocean90) 94ad421722 Multisite: After [37918] add support for retrieving custom site properties set by the `site_details` filter.
The behaviour was previously possible with the `blog_details` filter and `get_blog_details()` function. The former is deprecated since [38936].
This change adjusts the magic methods of `WP_Site` to also check if `$key` exists in `WP_Site::get_details()`. 

Fixes #40458.

git-svn-id: https://develop.svn.wordpress.org/trunk@40478 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-19 18:51:25 +00:00
John Blackbourn 620280474f Build/Test tools: Introduce and implement `assertNotIXRError()` and `assertIXRError()` assertion methods.
This aids in debugging XMLRPC tests which fail, by exposing the `IXR_Error` error message in the assertion failure message.

Fixes #40423


git-svn-id: https://develop.svn.wordpress.org/trunk@40417 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-12 14:58:33 +00:00
John Blackbourn 043d3b54a8 Build/Test tools: Improve the failure message reported by `assertQueryTrue()` so it's a little less cryptic.
Fixes #40411


git-svn-id: https://develop.svn.wordpress.org/trunk@40416 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-11 10:48:00 +00:00
Felix Arntz 1abf42b45e Multisite: Introduce an `upgrade_network` capability.
Prior to this change, a mix of `is_super_admin()` calls and `manage_network` capability checks was used to determine whether the current user could upgrade the network. With this changeset a dedicated capability is introduced that allows more granular handling.

Props dhanendran for the original patch.
Fixes #39205. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40404 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-10 21:10:48 +00:00
Andrew Ozz d37198f240 TinyMCE: update the tests for version 4.5.6. Remove default plugins tests, it is quite pointless to keep repeating them at this point.
See #40305.


git-svn-id: https://develop.svn.wordpress.org/trunk@40399 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-09 23:10:15 +00:00
Joe McGill 04e3680d1c Media: Improve handling of non-image files in wp_get_image_mime.
This prevents non-image fileypes from returning a mime type of
"application/octet-stream" when `exif_imagetype()` returns `false`.

Props blobfolio.
Fixes #40017.


git-svn-id: https://develop.svn.wordpress.org/trunk@40397 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-09 22:43:04 +00:00
John Blackbourn 2a261f0d7c Build/Test tools: Remove occurrences of `create_function()` in unit tests.
Props desrosj

See #37082


git-svn-id: https://develop.svn.wordpress.org/trunk@40392 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 13:37:39 +00:00
Felix Arntz 4fbac9b3a7 Multisite: Partially revert [40295].
[40295] removed the restriction of a minimum amount of characters for new site names, which could cause unexpected behavior. That changeset is reverted here with the exception of the removal of the `is_super_admin()` check, which can safely be omitted. A new filter for the minimum site name length will be introduced later to be able to modify that behavior.

See #39676, #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40391 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 13:14:36 +00:00
Felix Arntz 3ca0673036 Multisite: Introduce a `setup_network` capability for setting up multisite.
`setup_network` is a new meta capability that brings more granular control over the permissions to setup a multisite environment. In a non-multisite environment it falls back to `manage_options` while in a multisite it falls back to `manage_network_options`. The introduction of this capability furthermore allows replacing an `is_super_admin()` check.

Props ashokkumar24 for the original patch.
Fixes #39206. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40390 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 12:52:24 +00:00
James Nylen a7b3612f2a REST API: Allow fetching multiple users at once via the `slug` parameter.
This matches similar changes previously made for posts (#38579) and terms (#40027).

Props curdin, MatheusGimenez.
Fixes #40213.


git-svn-id: https://develop.svn.wordpress.org/trunk@40378 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-05 22:24:24 +00:00
James Nylen 99de5d69d7 REST API: Allow fetching multiple terms at once via the `slug` parameter.
This matches a similar change previously made for posts (#38579) and an upcoming change for users (#40213).

Props wonderboymusic, MatheusGimenez, curdin.
Fixes #40027.


git-svn-id: https://develop.svn.wordpress.org/trunk@40376 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-05 20:24:27 +00:00
flixos90 707bf79a9b Multisite: Add `$network_id` parameter to `get_user_count()`.
The `get_user_count()` function returns the number of active users on a network, which is stored in a `user_count` network option. Since `get_network_option()` supports retrieving options from other networks than the current one, `get_user_count()` can now make use of that feature.

Fixes #37866.


git-svn-id: https://develop.svn.wordpress.org/trunk@40371 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-03 23:31:33 +00:00
flixos90 117f2da3cc Multisite: Support the `$network_id` parameter of `get_blog_count()`.
The `get_blog_count()` function used to support an `$id` parameter for the network ID prior to WordPress 3.1. This parameter has not been used since the introduction of `get_site_option()` and was later deprecated in [25113]. With `get_network_option()` however it is possible to support the parameter again, now properly renamed as `$network_id`.

A unit test has for the parameter has been added as well. Another unit test in the same class was adjusted to work properly with multiple networks existing.

Fixes #37865.


git-svn-id: https://develop.svn.wordpress.org/trunk@40370 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-03 23:13:40 +00:00
Adam Silverstein 926853f3a3 REST API: JS Client - Enable connecting to multiple endpoints.
Enable connecting to multiple wp-api `endpoints`. Calling `wp.api.init` with a new `apiRoot` will parse the new endpoint's schema and store a new set of models and collections. A collection of connected endpoints is stored in `wp.api.endpoints`.

Props lucasstark.
Fixes #39683.



git-svn-id: https://develop.svn.wordpress.org/trunk@40364 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-02 19:40:37 +00:00
Boone Gorges cc1c0639d0 Invalidate term query caches when setting or deleting term relationships.
Prior to 4.7, term relationships - as set by `wp_set_object_terms()` or
`wp_remove_object_terms()` - did not affect the term query cache. The
introduction of the 'object_ids' parameter in 4.7 means that the query
cache must be aware of object-term relationships. As such, the
'last_changed' incrementor is now invalidated when term relationships
are modified.

This bug only reared its head when delaying term counting, because term
counting performs its own term query cache invalidation.

Props mboynes.
Fixes #40306.

git-svn-id: https://develop.svn.wordpress.org/trunk@40353 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-30 16:49:47 +00:00
James Nylen c7f1aeb441 Tests: Remove a couple of invalid error assertions.
A couple of REST API tests had an assertion `assertNotInstanceOf( 'WP_Error', $response );` which will never be true.

Since these assertions are invalid, and also made redundant by the response status check, we can just remove them.

Props dlh.
Fixes #40270.


git-svn-id: https://develop.svn.wordpress.org/trunk@40350 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-29 17:05:41 +00:00
Jeremy Felt 8cc8a221fc Multisite: Remove unused `site-lookup` global cache group.
The `site-lookup` group was introduced in WPMU, but never actually used in WordPress core.

Props johnjamesjacoby.
Fixes #38725.


git-svn-id: https://develop.svn.wordpress.org/trunk@40347 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 21:07:22 +00:00
Jeremy Felt 6790fcb55d Multisite: Respect `$_wp_suspend_cache_invalidation` when clearing network and site caches.
Props johnjamesjacoby.
Fixes #40028.


git-svn-id: https://develop.svn.wordpress.org/trunk@40346 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 19:35:49 +00:00
Jeremy Felt 83002e564e Multisite: Allow falsy properties to be cached in `site-details`.
In previous iterations of `WP_Site`, there was concern that not all properties would be available when storing a site's details in cache. When introduced in [37918], an `ms_loaded` check was added to address this concern. Any properties that are still `false` after `ms_loaded` really are `false` and can be cached as such.

Props flixos90.
Fixes #40247.


git-svn-id: https://develop.svn.wordpress.org/trunk@40344 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 02:31:13 +00:00
Jeremy Felt 308554bd84 Tests: Add missing global cache groups.
Add `useremail`, `userslugs`, `networks`, `sites`, and `site-details` as global cache groups when added with unit tests. This aligns the list with the core default.

Fixes #40283.


git-svn-id: https://develop.svn.wordpress.org/trunk@40343 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 01:45:43 +00:00
Jeremy Felt b36363bb69 Tests: Clarify zero path segment tests for `get_network_by_path()`.
The set of assertions in this data provider intend to test a 0 path segment configuration rather than the use of paths.

Fixes #37217.


git-svn-id: https://develop.svn.wordpress.org/trunk@40342 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 01:24:44 +00:00
Jeremy Felt 2f39fe479f Tests: Consolidate logic used to skip API fixture generation.
This checks for `is_multisite()` and the minimum PHP version in the same block and removes two `echo` statements previously used to indicate generation had been skipped.

Fixes #40041.


git-svn-id: https://develop.svn.wordpress.org/trunk@40341 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 21:04:06 +00:00
Jeremy Felt ab57ab8e7f Multisite: Add `lang_id` support to `WP_Site_Query`.
Sites can now be queried by `lang_id`, `lang__in`, and `lang__not_in`.

Props ocean90.
Fixes #40196.


git-svn-id: https://develop.svn.wordpress.org/trunk@40340 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 19:47:53 +00:00
Jeremy Felt ba254dfa63 Tests: Use utf8mb4 max index length when creating keys.
In [31349], core `varchar` column key lengths were changed from 255 to 191 to support the 767 byte index size limit on standard utf8mb4 MySQL installs. This changes the DB schema tests to match.

Props caseypatrickdriscoll, clarinetlord.
Fixes #35958.


git-svn-id: https://develop.svn.wordpress.org/trunk@40339 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 19:33:55 +00:00
westonruter 1e7b157523 Customize: Improve i18n for strings in hidden widget area notices.
Amends [40312].
Props westonruter, ocean90, swissspidy, SergeyBiryukov, michelleweber for copywriting.
See #33567, #33052.
Fixes #39087.


git-svn-id: https://develop.svn.wordpress.org/trunk@40330 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-24 22:02:02 +00:00
Pascal Birchler 54baae39b2 REST API: Use `get_gmt_from_date()` when preparing a draft post for response.
This prevents wrong dates when dealing with DST, see [40115] and [40284].

Props nerrad.
Fixes #40136.

git-svn-id: https://develop.svn.wordpress.org/trunk@40324 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-24 17:31:54 +00:00
Felix Arntz df23b65221 Multisite: Add further unit tests for `get_blog_details()`.
These tests verify that the returned site object is iterable and contains the expected properties.

See #40228, #40180.


git-svn-id: https://develop.svn.wordpress.org/trunk@40317 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-23 17:13:14 +00:00
Weston Ruter 9528740aa3 Customize: Show notice in Widgets panel when there are additional widget areas not rendered in preview.
This extends the existing behavior which only showed a message only when there were no widget areas rendered in the preview. The number of non-rendered widget areas is indicated. Also removes needles deletion of `wp.customize.Widgets.data.l10n` property which hindered plugins.

See #33567, #33052.
Fixes #39087.


git-svn-id: https://develop.svn.wordpress.org/trunk@40312 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-22 19:02:26 +00:00
Rachel Baker bf7d411330 REST API: Confirm the parent post object of an attachment exists in `WP_REST_Posts_Controller::check_read_permission()`.
Avoid a PHP Error when attempting to embed the parent post of an attachment, when the parent post ID is invalid. Instead check if the parent post object exists before checking the read permission for the parent post.

Props GhostToast.
Fixes #39881. 


git-svn-id: https://develop.svn.wordpress.org/trunk@40306 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-20 04:29:50 +00:00
Felix Arntz e6fda09261 Multisite: Handle sites cache invalidation more granularly for option updates.
Previously `update_blog_option()` would trigger an invalidation of that site's entire cache although these changes did not affect the content of these caches. Furthermore changes to the special options `blogname`, `siteurl` and `post_count` should not invalidate the entire cache of that site, but only their respective site details cache. The option `home` now has the same behavior as it also belongs to the site details, but did not invalidate the cache at all previously.

Several new unit tests confirm these changes work as expected.

Fixes #40063.


git-svn-id: https://develop.svn.wordpress.org/trunk@40305 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-19 16:21:38 +00:00
Weston Ruter 83de39a7fb Customize: Trailingslash the home nav menu item URL in starter content.
This prevents an additional 301 redirect when clicking on the nav menu item, and it also prevents a scenario where the auth cookie may not be passed and cause an authentication error when navigating in the customizer.

Props dlh, swissspidy.
Fixes #40112.


git-svn-id: https://develop.svn.wordpress.org/trunk@40300 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-18 03:22:08 +00:00
Pascal Birchler 11d556e42b List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.
Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.

git-svn-id: https://develop.svn.wordpress.org/trunk@40297 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 16:53:08 +00:00
Pascal Birchler e14051c031 Multisite: Ensure first page/post/comment content is not empty when setting up a new site.
This prevents creating page without any content when the options are populated with an empty string.

Props shadyvb.
Fixes #40036.

git-svn-id: https://develop.svn.wordpress.org/trunk@40296 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 15:48:35 +00:00
Felix Arntz eb7a3d1a2f Multisite: Remove restriction of minimum site name length in `wpmu_validate_blog_signup()`.
It is sometimes desirable to support shorter site names than 4 characters, therefore that restriction should be removed. It is still possible to manually enforce it by using the `wpmu_validate_blog_signup` filter.

As a result of this change, another `is_super_admin()` call gets removed which affects the ongoing efforts of working on a network-wide role system.

Props milindmore22.
Fixes #39676. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40295 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 14:35:08 +00:00
Felix Arntz 169c32723f Multisite: Provide unit tests for `wpmu_validate_blog_signup()`.
See #39676.


git-svn-id: https://develop.svn.wordpress.org/trunk@40294 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 14:14:14 +00:00
Boone Gorges 79cfdbd84c Improve querying for terms with falsey names and slugs.
Prior to [38677], `get_term_by()` would always return false if
an empty string were passed as the queried 'name' or 'slug'. The
refactor to use `get_terms()` broke this behavior; inappropriately
imprecise `empty()` checks caused the 'name' or 'slug' clause to be
discarded altogether when fetching terms, resulting in an incorrect
term being returned from the function.

We fix the regression by special-casing truly empty values passed
to `get_term_by()`, and ensuring that `WP_Term_Query` is properly
able to handle `0` and `'0'` term queries.

Props sstoqnov.
Fixes #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@40293 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-16 02:03:53 +00:00
Boone Gorges 3025ba4c8f Fix the formatting of `$taxonomies` parameter of `'wp_get_object_terms'` filter.
[38667] changed the way that the filter parameters are built. That
changeset didn't fully account for the pre-4.7 format of `$taxonomies`.

Props ig_communitysites.
Fixes #40154.

git-svn-id: https://develop.svn.wordpress.org/trunk@40290 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-14 18:41:26 +00:00
James Nylen b9dd2c01f3 REST API: Fix DST handling in a test.
The time chosen for `test_empty_post_date_gmt_shimmed_using_post_date` falls within US daylight savings time.  This may cause the test to fail depending on whether the current locale has DST.

The fix is to specify a numeric `gmt_offset` rather than a `timezone_string`.

Unprops jnylen0.
Fixes #40136.


git-svn-id: https://develop.svn.wordpress.org/trunk@40284 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-13 15:06:10 +00:00
Boone Gorges 5e74056898 Tests: Use `assertSame()` for `WP_Query` 'orderby' tests.
`assertEqualSets()` ignores order, so isn't much good for testing 'orderby'.

See #38034.

git-svn-id: https://develop.svn.wordpress.org/trunk@40278 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-11 03:07:27 +00:00
Boone Gorges 824c50f8ae Don't run 'get_terms' filter when querying for terms within `get_term_by()`.
Historically, it has been possible to call `get_term_by()` within
a 'get_terms' filter callback. Since `get_term_by()` was refactored
to use `get_terms()` internally [38677], callbacks of this nature
have resulted in infinite loops.

As a workaround, we introduce a 'suppress_filter' option to `get_terms()`,
and use it when calling the function from within `get_term_by()`.

Props ocean90.
See #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@40275 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-11 02:26:11 +00:00
John Blackbourn f5f7736177 Build/Test tools: Don't override the `wp_set_auth_cookie()` and `wp_clear_auth_cookie()` functions.
Overriding pluggable functions in the test suite is asking for trouble in the future. In addition, it means the test suite can't be guaranteed to behave the same as core.

This instead introduces a `send_auth_cookies` filter which can be hooked in during the test suite to prevent these functions from attempting to send cookie headers to the client.

Fixes #39367


git-svn-id: https://develop.svn.wordpress.org/trunk@40263 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-10 14:32:31 +00:00
Sergey Biryukov 8060823ff3 Canonical: Strip trailing punctuation from permalinks.
Props joostdevalk, lancewillett, SergeyBiryukov.
Fixes #20383.

git-svn-id: https://develop.svn.wordpress.org/trunk@40256 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-09 20:04:17 +00:00
John Blackbourn 74e02a21b8 Build/Test tools: In Travis, skip some tests when not on trunk.
This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis.

Props netweb, jorbin

Fixes #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40241 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:06:12 +00:00
John Blackbourn 0060ffaa8c Build/Test tools: Revert [40239] due to unrelated changes.
See #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40240 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:04:05 +00:00
John Blackbourn 868eba6850 Build/Test tools: In Travis, skip some tests when not on trunk.
This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis.

Props netweb, jorbin
Fixes #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40239 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:00:47 +00:00
James Nylen 8bbe6a0d50 REST API: Add `gmt_offset` and `timezone_string` to the base `/wp-json` response.
The site's current timezone offset is an important piece of information for any REST API client that needs to manipulate dates.  It has not been previously available.

Expose both the `gmt_offset` (the site's current offset from UTC in hours) and `timezone_string` (which also provides information about daylight savings time) via the "site info" endpoint (the base `/wp-json` response).

Also update the `wp-api-generated.js` fixture file with the changes to the default API responses.

Props sagarkbhatt.
Fixes #39854.


git-svn-id: https://develop.svn.wordpress.org/trunk@40238 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 05:47:32 +00:00
James Nylen e79e137c32 WP_Query: Add missing tests for combinations of `orderby` and include parameters.
This commit adds some missing test cases for combinations of `orderby` and other parameters (`post_parent__in` and `post_name__in`).

Followup to [40056] for `orderby` and `post__in`.

The interaction of these parameters is perhaps counterintuitive because `orderby` does not affect the returned results.  This is overall probably the best design, and it's now better tested and documented.

Props fibonaccina.
See #39055.


git-svn-id: https://develop.svn.wordpress.org/trunk@40237 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 05:26:51 +00:00
John Blackbourn 154d0d15b7 Build/Test Tools: Call `wp_head()` and `wp_footer()` in the theme used during tests.
See #31550
Fixes #39988


git-svn-id: https://develop.svn.wordpress.org/trunk@40235 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 01:33:04 +00:00
Aaron D. Campbell ec30770c50 Strip control characters before validating redirect.
git-svn-id: https://develop.svn.wordpress.org/trunk@40183 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-06 13:37:43 +00:00
Boone Gorges d3e463cb84 Taxonomy: Take 'parent' into account when checking for terms with duplicate names.
Terms with duplicate names are not allowed at the same level of a
taxonomy hierarchy. The name lookup introduced in [34809] did not
properly account for the 'parent' parameter, with the result that
the duplicate-name restriction was tighter than intended (terms
with duplicate names could not be created at different levels of
a single hierarchy).

Props mikejolley.
Fixes #39984.

git-svn-id: https://develop.svn.wordpress.org/trunk@40145 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-03 02:49:13 +00:00
Boone Gorges 8a2341335b Taxonomy: Improve precision of duplicate name checks when inserting terms.
`wp_insert_term()` does not allow for terms with the same name to exist
at the same hierarchy level, unless the second term has a unique slug.
When this logic was refactored in [31792] and [34809], a bug was
introduced whereby it was possible to bypass the no-same-named-sibling
check in cases where the first term had a non-auto-generated slug
(ie, where the name was 'Foo' but the slug something other than 'foo',
such that the second term would get the non-matching slug 'foo').

This changeset fixes this issue by ensuring that the duplicate name
check runs both in cases where there's an actual slug clash *and* in
cases where no explicit `slug` has been provided to `wp_insert_term()`.
The result is a more reliable error condition:
`wp_insert_term( 'Foo' ... )` will always fail if there's a sibling
'Foo', regardless of the sibling's slug.

Props mikejolley.
See #39984.

git-svn-id: https://develop.svn.wordpress.org/trunk@40144 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-03 02:39:09 +00:00
Boone Gorges 735424428c Tests: Starter content tests should use copies of images stored in /tmp.
This ensures that generated thumbnails are kept out of the version-
controlled `DIR_TESTDATA` directory.

Props bor0.
Fixes #40008.

git-svn-id: https://develop.svn.wordpress.org/trunk@40142 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-02 02:25:05 +00:00
Joe McGill 5349b0a08c Media: Skip PDF preview tests when image editor doens't support.
Following [40130] tests fail on environments that don't support PDF
previews because the expected meta data doesn't get written.

See #39875.

git-svn-id: https://develop.svn.wordpress.org/trunk@40131 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 17:50:21 +00:00
Joe McGill 9848a4a466 Media: Keep PDF previews from overwriting files.
Since support for PDF previews were added in [38949], it's possible
that the generated image file could overwrite an existing image file
with the same name. This uses `wp_unique_filename()` to avoid this
issue and adds a '-pdf' identifier on the end of filenames.

Props gitlost, derosj, mikeschroder, joemcgill.
Fixes #39875. See #31050.

git-svn-id: https://develop.svn.wordpress.org/trunk@40130 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 15:38:30 +00:00
John Blackbourn 5ab0154647 Comments: When commenting on a draft post, display a friendly error message if the user can view the post.
This prevents the unhelpful white screen of death when a user who can view the post (eg. preview it) leaves a comment while the post is in draft.

Props sagarprajapati, milindmore22, mayurk, swissspidy
Fixes #39650


git-svn-id: https://develop.svn.wordpress.org/trunk@40128 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 00:22:02 +00:00
Joe McGill 5c99d4ae9c Media: Fix unit tests for MIME checks on multisite.
A few of the multisite tests were failing after [40124] because
multisite filters `upload_mimes` with the `check_upload_mimes()`
function to reduce the set of allowed MIME types. This fixes those
errors by skipping the tests for adding additional MIME types and
only tests file types assumed to be allowed.

See #39550.

git-svn-id: https://develop.svn.wordpress.org/trunk@40125 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-26 16:05:25 +00:00
Joe McGill 7684a241b3 Media: Reduce failing uploads following 4.7.1.
[39831] introduced more strict MIME type checking for uploads, which
resulted in unintetionally blocking several filetypes that were
previously valid. This change uses  a more targeted approach to MIME
validation to restore previous behavior for most types.

Props blobfolio, iandunn, ipstenu, markoheijnen, xknown, joemcgill.
Fixes #39550, #39552.

git-svn-id: https://develop.svn.wordpress.org/trunk@40124 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 16:07:25 +00:00
Mike Schroder cfe271d254 Media: Reset Exif orientation after rotate in `WP_Image_Editor_Imagick`.
Due to inconsistencies in the way browsers handle Exif orientation data,
if a user manually rotates an image within WordPress, set the Exif orientation to
the default (1) so that the image displays with the same rotation/flip in every browser.

Props sanchothefat, triplejumper12, joemcgill, azaozz, markoheijnen, mikeschroder.
See #14459.
Fixes #37140.

git-svn-id: https://develop.svn.wordpress.org/trunk@40123 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 05:25:40 +00:00