From 56d6682461be82da1a3bafc454dad2c9da451a38 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 10 Jan 2015 21:21:22 +0000 Subject: [PATCH] In `edit-form-advanced.php`: * `get_permalink( $post_ID )` can return `false`, set it to a variable and check it * Using the variable allows us to replace 11 separate calls to `get_permalink( $post_ID )` in the file * These notices were triggered by the potential for `false` to be passed to `esc_url()` See #30799. Built from https://develop.svn.wordpress.org/trunk@31131 git-svn-id: http://core.svn.wordpress.org/trunk@31112 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 27 ++++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 54695159de..912432fbaa 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -65,35 +65,40 @@ add_action( 'admin_footer', '_local_storage_notice' ); /* * @todo Document the $messages array(s). */ +$permalink = get_permalink( $post_ID ); +if ( ! $permalink ) { + $permalink = ''; +} + $messages = array(); $messages['post'] = array( 0 => '', // Unused. Messages start at index 1. - 1 => sprintf( __('Post updated. View post'), esc_url( get_permalink($post_ID) ) ), + 1 => sprintf( __('Post updated. View post'), esc_url( $permalink ) ), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Post updated.'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __('Post published. View post'), esc_url( get_permalink($post_ID) ) ), + 6 => sprintf( __('Post published. View post'), esc_url( $permalink ) ), 7 => __('Post saved.'), - 8 => sprintf( __('Post submitted. Preview post'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + 8 => sprintf( __('Post submitted. Preview post'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), 9 => sprintf( __('Post scheduled for: %1$s. Preview post'), /* translators: Publish box date format, see http://php.net/date */ - date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), - 10 => sprintf( __('Post draft updated. Preview post'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), + 10 => sprintf( __('Post draft updated. Preview post'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); $messages['page'] = array( 0 => '', // Unused. Messages start at index 1. - 1 => sprintf( __('Page updated. View page'), esc_url( get_permalink($post_ID) ) ), + 1 => sprintf( __('Page updated. View page'), esc_url( $permalink ) ), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Page updated.'), 5 => isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __('Page published. View page'), esc_url( get_permalink($post_ID) ) ), + 6 => sprintf( __('Page published. View page'), esc_url( $permalink ) ), 7 => __('Page saved.'), - 8 => sprintf( __('Page submitted. Preview page'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), - 9 => sprintf( __('Page scheduled for: %1$s. Preview page'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), - 10 => sprintf( __('Page draft updated. Preview page'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + 8 => sprintf( __('Page submitted. Preview page'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), + 9 => sprintf( __('Page scheduled for: %1$s. Preview page'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), + 10 => sprintf( __('Page draft updated. Preview page'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); $messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated.' ) ); // Hack, for now. @@ -485,7 +490,7 @@ do_action( 'edit_form_before_permalink', $post ); public ? get_sample_permalink_html($post->ID) : ''; $shortlink = wp_get_shortlink($post->ID, 'post'); -$permalink = get_permalink( $post->ID ); + if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) $sample_permalink_html .= '' . __('Get Shortlink') . ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b0454d26a..999902a7e9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31130'; +$wp_version = '4.2-alpha-31131'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.