forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp_publish_post not checking for unique post slugs #2
Open
nirav7707
wants to merge
4
commits into
trunk
Choose a base branch
from
test/wp_publish_post
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add testcase for the wp_publish_post function to ensure that post have same title have different slug.
Change the way of post creation from wp_insert_post to factory object to follow test standard.
…est/wp_publish_post
nirav7707
pushed a commit
that referenced
this pull request
Nov 7, 2022
…heme()` tests. In the tests for updating a theme via Ajax, `wp_installing( true )` is called to prevent `wp_update_themes()` from running. This worked as expected in `test_update_theme()`, however, it was missed in `test_uppercase_theme_slug()`, which was accidentally relying on the `wp_installing()` status not being properly restored in the previous test. Now that the `wp_installing()` status was corrected in [54723], the latter test started throwing an error on PHP 8.2: {{{ 1) Tests_Ajax_wpAjaxUpdateTheme::test_uppercase_theme_slug http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated /var/www/src/wp-includes/Requests/Transport/cURL.php:345 /var/www/src/wp-includes/Requests/Transport/cURL.php:135 /var/www/src/wp-includes/class-requests.php:381 /var/www/src/wp-includes/class-wp-http.php:395 /var/www/src/wp-includes/class-wp-http.php:615 /var/www/src/wp-includes/http.php:179 /var/www/src/wp-includes/update.php:719 /var/www/src/wp-admin/includes/ajax-actions.php:4292 /var/www/src/wp-includes/class-wp-hook.php:308 /var/www/src/wp-includes/class-wp-hook.php:332 /var/www/src/wp-includes/plugin.php:517 /var/www/tests/phpunit/includes/testcase-ajax.php:265 /var/www/tests/phpunit/tests/ajax/wpAjaxUpdateTheme.php:157 }}} Replicating the `wp_installing()` status changes in this test too resolves the error. Follow-up to [38168], [38710], [54722], [54723]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54725 602fd350-edb4-49c9-b593-d223f7449a82
nirav7707
pushed a commit
that referenced
this pull request
Aug 21, 2024
When saving options from the Settings page, include the `'ping_sites'` option in the allowed "writing" options list only when the `'blog_public'` option is `'1'`. Fixes a PHP 8.1 and above "null to non-nullable" deprecation notice in `sanitize_option()` ([https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php?annotate=blame#L4952 which happens when here] as part of [22255]): {{{ Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in .../wp-includes/formatting.php }}} **Explanation** [https://developer.wordpress.org/apis/options/#writing Per the documentation], the `ping_sites` option requires the `'blog_public'` option to have a value of `'1'` and must be a `string` data type. `null` is not valid for this option. The relationship between the 2 options shows itself in the `options-writing.php` code ([https://core.trac.wordpress.org/browser/tags/6.5.4/src/wp-admin/options-writing.php#L233 shown here] and in [4326]), as the `textarea#ping_sites` only renders when `'1' === get_option( 'blog_public' )`. **What happens if `'blog_public'` is not `'1'`?** The `'ping_sites'` option will not be a field on the page. Upon saving: * HTTP POST (`$_POST`) does not include `'ping_sites'`. * Before this commit: * The [https://core.trac.wordpress.org/browser/trunk/src/wp-admin/options.php#L333 option's value was set to] `null` before being passed to `update_option()`. * `update_option()` invokes `sanitize_option()`. * A `null` value for the `'ping_sites'` case was passed to `explode()`, which threw a deprecation notice on PHP 8.1 and above. * With this commit, the `'ping_sites'` option is no longer included in the allow list and thus will not be passed to `update_options()` > `sanitize_option()` > `explode()`. Follow-up to [22255], [12825], [4326], [949]. Props kitchin, SergeyBiryukov, swissspidy, devmuhib, rajinsharwar, hellofromTonya. Fixes #59818. git-svn-id: https://develop.svn.wordpress.org/trunk@58425 602fd350-edb4-49c9-b593-d223f7449a82
nirav7707
pushed a commit
that referenced
this pull request
Aug 21, 2024
…t_mime_types(). Fixes a PHP 8.1 and above "null to non-nullable" deprecation notice in `get_available_post_mime_types()`: {{{ Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in ./wp-includes/post.php on line 3395 }}} [https://developer.wordpress.org/reference/functions/get_available_post_mime_types/#return This function is documented] to: * Return `An array of MIME types.` * as an array of `string`s, i.e. `string[]`. A `null` or empty element within the returned array is not a valid MIME type. If a `null` exists in the returned array, it is the root cause of PHP throwing the deprecation notice. This commit removes the `null` and empty elements from the returned array of MIME types. It also adds a unit test. Follow-up to [56623], [56452]. Props nosilver4u, jrf, ironprogrammer, antpb, antonvlasenko, rajinsharwar, hellofromTonya. Fixes #59195. git-svn-id: https://develop.svn.wordpress.org/trunk@58437 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A draft post which have identical title and slug to already publish post, testcase ensure that after changing post status to publish of draft post with wo_publish_post function the slug will be unique with the all available slug in posts table.
Trac ticket: https://core.trac.wordpress.org/ticket/50447
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.