[wp-trac] [WordPress Trac] #45292: wp_targeted_link_rel "corrupts" the customized changeset JSON when inserting the changeset post in database
WordPress Trac
noreply at wordpress.org
Mon Jan 28 21:45:30 UTC 2019
#45292: wp_targeted_link_rel "corrupts" the customized changeset JSON when
inserting the changeset post in database
--------------------------------------+---------------------
Reporter: nikeo | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone: 5.1
Component: Customize | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+---------------------
Comment (by westonruter):
@peterwilsoncc If I understand correctly, you can try creating a draft
`customize_changeset` post that has one setting in it which contains a
link as shown in the description. Then publish the changeset and make sure
that the data in the changeset remains intact as valid JSON, and that it
isn't corrupted as @nikeo shows the currently behavior.
For example:
{{{#!php
<?php
// ...
/**
* Ensure that changeset data is not not corrupted by
wp_targeted_link_rel().
*/
public function test_uncorrpteded_changeset_data() {
require_once ABSPATH . WPINC . '/class-wp-customize-
manager.php';
wp_set_current_user( $this->factory()->user->create(
array( 'role' => 'administrator' ) ) );
global $wp_customize;
$wp_customize = new \WP_Customize_Manager();
$option_name = 'test_target_link';
$wp_customize->add_setting(
$option_name,
array(
'type' => 'option',
)
);
$value = 'Global Climate Change : this <a
href="https://climate.nasa.gov/vital-signs/carbon-dioxide/"
target="_blank">time series</a> below shows global distribution and
variation of the concentration of mid-tropospheric carbon dioxide in parts
per million (ppm).';
$wp_customize->set_post_value( $option_name, $value );
$wp_customize->save_changeset_post(
array(
'status' => 'draft',
)
);
$post_id = $wp_customize->changeset_post_id();
$saved_data = json_decode( get_post( $post_id
)->post_content, true );
$this->assertInternalType( 'array', $saved_data );
$this->assertEquals( $value, $saved_data[ $option_name
]['value'] );
$wp_customize->save_changeset_post( array( 'status' =>
'publish' ) );
$this->assertEquals( get_option( $option_name ), $value );
$saved_data = json_decode( get_post( $post_id
)->post_content, true );
$this->assertInternalType( 'array', $saved_data );
$this->assertEquals( $value, $saved_data[ $option_name
]['value'] );
}
// ...
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45292#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list