#14783 closed enhancement (fixed)
Incorrect/missing PHPDoc
| Reported by: | duck_ | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | Inline Docs | Version: | |
| Severity: | normal | Keywords: | ongoing-project has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Inspired by the 3.org API reference and the spit and polish nature of 3.1 this ticket is for patches addressing problems with current PHPDoc, e.g. spelling/factual corrections and writing missing docs.
Also, testing some methods for easily getting information for docs (e.g. version of introduction).
Attachments (6)
Change History (23)
#1
follow-up:
↓ 2
@
16 years ago
Note in 14783.001.diff there is the removal of the default array() for the $postarr parameter in wp_insert_post. This strikes me (also discussed briefly with nacin) as very odd since leaving out $postarr makes wp_insert_post useless and it will always return 0.
#2
in reply to: ↑ 1
@
16 years ago
Replying to duck_:
This strikes me (also discussed briefly with nacin) as very odd since leaving out $postarr makes wp_insert_post useless and it will always return 0.
In wp-admin/includes/post.php:
543 $post_ID = wp_insert_post( $_POST );
There is no check within that function (wp_write_post()) that the $_POST array is populated.
#4
@
16 years ago
The point of inline documentation and its fixes is to not introduce possible bugs. This enables them to be committed quickly and without testing.
#6
in reply to: ↑ 5
@
16 years ago
Replying to nacin:
(In [15564]) phpdoc, @since, whitespace. Also require an argument in wp_insert_post(). props duck_, see #14783.
If that is the case, then the bug is somewhere else in the code and you are just covering up the cause.
While it is true that probably no where in the code will this function be called without passing at least something in the $postarr variable, it is made at the very least to stand as a feature for someone who wants to create a post and then fill it at some later time. There are a few cases where you'll want to fill in some data and then go back and fill in the rest once you know more.
Furthermore, this change should be in its own ticket to further track its progress and any other information that might be needed.
#10
@
16 years ago
- Keywords ongoing-project added
Anyone planning to add more to this one should do so by November 1st to get in before freeze.
#14
@
16 years ago
- Resolution fixed
- Status closed → reopened
Reopening for an additional patch. It made more sense to reopen this ticket than to create a new one.
This ticket was mentioned in PR #14784 on WordPress/wordpress-develop by @jonsurrell.
3 weeks ago
#16
- Keywords has-patch has-unit-tests added
Stacked on #14783, which is on #14782 and #14781. This PR's own commits are those after 977555cadf. Draft: the branch is not yet rebased on current trunk and conflicts with it in the safe_style_css list, where trunk added the background-clip entries, and in a kses test docblock.
safecss_filter_attr() keeps its signature and now parses the value as a declaration list with WP_HTML_Style_Attribute_Processor, checks each declaration, and rebuilds the output from the accepted ones with serialize_declaration(). The legacy body splits on ;, matches names as text and tests values with regular expressions, so the unit it accepts or rejects is not the declaration a browser reads. Outputs of trunk and of this branch:
COLOR:red; color:/* hi */blue; font-family:"Ben & Jerry" trunk: '' branch: color: red; color: blue; font-family: "Ben \26 Jerry"; font-family:foo\;bar trunk: bar branch: font-family: foo\3b bar; color:red;this-is-not-css-at-all trunk: color:red;this-is-not-css-at-all branch: color: red; color: red; width: calc(1px + (2px*3)); filter: blur(2px) trunk: color: red;width: calc(1px + (2px*3)) branch: color: red; width: calc(1px + (2px*3)); filter: blur(2px);
The policy checks one declaration at a time and drops a rejected declaration whole:
- The decoded, lowercased property name is in the
safe_style_csslist, or the list has--*and the name is a custom property, matched exactly. - Every function in the value, at any depth, is in the function allowlist: the legacy list plus the math, gradient, color, filter and easing functions. A function is listed when its result depends only on its arguments and Blink, Gecko and WebKit ship it unprefixed; the docblock states the rule. There is no per-property list.
- Every URL in the value, at any depth, as a
url()token orurl("…"), is non-empty and unchanged bywp_kses_bad_protocol(). - In a standard property, the value has no bare
( )or{ }block at its top level; a block nested in a function, as incalc(1px + (2px * 3)), is kept. - The value has no
&, control character or\delimiter token anywhere.<,>and=are kept; encoding the output for HTML remains the caller's task.
The checks run on decoded values, so an escaped function name or scheme is checked as what it denotes, and the output re-escapes. A block, string or url that the input ends inside is closed in the output, as CSS closes it, so the output re-parses to the accepted declarations and filtering it again changes nothing.
The output is property: value; for each accepted declaration, joined by a space, with strings double-quoted, comments dropped and punctuation in urls hex-escaped. Core callers that tested for or appended ; are adapted: WP_Style_Engine_CSS_Declarations::filter_declaration(), get_block_wrapper_attributes() and wp_get_layout_style(), which now filters max-width: plus the value because the legacy body passed a bare value through unchecked. WP_Theme_JSON::is_safe_css_declaration() keeps the legacy filter through the new hook until that class builds its declarations with the CSS API. Files under wp-includes/blocks/ are synced from Gutenberg and are not changed; post-featured-image.php appends its own ; and will write ;;, which browsers ignore.
Hooks: safe_style_css is applied once before dispatch; a non-array result is replaced with the default list, and an empty array returns the input as before. The new wp_kses_force_legacy_css_parser filter (default false) selects the pre-7.2.0 body, kept as _safecss_filter_attr_legacy(), for a transition period. safecss_filter_attr_allow_css is deprecated with no replacement: its second argument is the legacy regex's test string, which has no equivalent here, and most callbacks in the plugin and theme directories allow functions the new path accepts by default.
Every intended behavior change is listed in docs/wp-css-declaration-list-filter-spec.md under "Differences From The Legacy Function". On the 158 existing kses test vectors: 20 identical, 119 formatting only, 2 narrowings (expression() inside a gradient; an unmatched )), 17 widenings, 0 defects. tools/Tests_Safecss_Filter_Differential.php runs that comparison and classifies each difference.
Known limitation: Gutenberg's block validation compares a saved style attribute as text, so the escapes and quote changes this filter writes for a user without unfiltered_html can mark a block invalid in the editor. A Gutenberg change is needed before this lands.
Tests: in tests/phpunit/tests/kses.php, data_safecss_filter_attr and data_kses_style_attr_with_url serve both paths. A row lists an expected_legacy value only when the two outputs differ other than in form, and the _legacy tests assert it through the hook. tests/phpunit/tests/kses/safecssFilterAttr.php covers each policy rule, blocks and tokens cut off by the end of the input, the hooks and idempotence. Run on this branch: kses.php 560, safecssFilterAttr.php 269, wpThemeJson.php 242, supportedStyles.php 25, wpRenderBackgroundSupport.php 27, style engine 58; all pass.
Trac ticket: TBD
Use of AI Tools
AI assistance: Yes
Tools: Codex, Claude Code
Models: GPT-5, Claude Opus, Claude Fable 5.1
Used for: implementation, tests, specification drafting, review and this description.
Alot of @since unkown