Make WordPress Core

Opened 8 years ago

Last modified 6 years ago

#41933 new defect (bug)

Undefined offset -1 in $pages array when post without pages is requested

Reported by: computerguru's profile ComputerGuru Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8.2
Component: General Keywords: has-patch
Focuses: Cc:

Description

This patch fixes an undefined index -1 notice generated in post-template.php when a request is made without a page number.

Attachments (2)

0001-Fix-undefined-offset-1-notice-in-pages-array-in-post.patch (1.1 KB) - added by ComputerGuru 8 years ago.
patch
0001-41933-Handle-get_the_content-with-no-pages.patch (1.4 KB) - added by ComputerGuru 7 years ago.
Proper patch for root issue

Download all attachments as: .zip

Change History (12)

#1 @ComputerGuru
8 years ago

This is a sample call stack that triggers the notice:

get_the_content()
    wp-includes/formatting.php:3292
wp_trim_excerpt()
    wp-includes/class-wp-hook.php:298
apply_filters('get_the_excerpt')
    wp-content/plugins/jetpack/_inc/lib/class.media-summary.php:314
Jetpack_Media_Summary::get_excerpt()
    wp-content/plugins/jetpack/_inc/lib/class.media-summary.php:57
Jetpack_Media_Summary::get()
    wp-content/plugins/jetpack/modules/publicize/enhanced-open-graph.php:23
enhanced_og_image()
    wp-includes/class-wp-hook.php:300
apply_filters('jetpack_open_graph_tags')
    wp-content/plugins/jetpack/functions.opengraph.php:216
jetpack_og_tags()
    wp-includes/class-wp-hook.php:298
do_action('wp_head')
    wp-includes/general-template.php:2589
wp_head()
    wp-content/themes/knowhow/header.php:14
load_template('~/wp-content/themes/knowhow/header.php')
    wp-includes/template.php:647
locate_template()
    wp-includes/general-template.php:45
get_header()
    wp-content/themes/knowhow/single.php:1

This ticket was mentioned in Slack in #core by mte90. View the logs.


7 years ago

#3 @ComputerGuru
7 years ago

  • Keywords has-patch added

@ComputerGuru
7 years ago

Proper patch for root issue

#4 @ComputerGuru
7 years ago

Attached a new patch taking place of the old one, better addressing the root problem.

#5 @ComputerGuru
7 years ago

Can I please get someone to review this?

#6 @birgire
7 years ago

Hi @ComputerGuru

It's always risky to trust global variables, as plugins and themes can override it.

Can we reproduce this notice on a vanilla install (default theme and no installed plugins) ?

What steps should we take to reproduce it?

#7 @pento
6 years ago

#43463 was marked as a duplicate.

#8 @ComputerGuru
6 years ago

@birgire it doesn't reproduce on a clean installation, only with JetPack installed and enabled.

#9 @birgire
6 years ago

@ComputerGuru Thanks for the update.

Did you check if there are any open JetPack tickets for this issue?

#10 @ComputerGuru
6 years ago

@birgire I didn't find any at the time; regardless, I believe it is a WordPress defect as it should never trust GET parameters to have sane values.

Note: See TracTickets for help on using tickets.