Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

Too few arguments to function jetpack_oembed_timeout_override() #33719

Closed cliffordp closed 1 year ago

cliffordp commented 1 year ago

Impacted plugin

Jetpack

Quick summary

Trying to connect the Gravity Forms Google Analytics add-on to my GA account causes this fatal. Per GF's support:

According to the full stack trace, this fatal error is caused by a Jetpack module related to shortcode improperly using a filter function. You will need to report this to the developers of Jetpack for resolution. Provide them with this full stack trace when doing so.

Steps to reproduce

  1. start with GF and GF add-on for GA both activated
  2. try to connect the GF GA add-on to your Google account
  3. doing so redirects to the wp-admin area for configuring the Google connection but there's a fatal: /wp-admin/admin.php?page=gf_settings&subview=gravityformsgoogleanalytics&action=gaselect

A clear and concise description of what you expected to happen.

no fatal

What actually happened

fatal

Impact

Some (< 50%)

Available workarounds?

No and the platform is unusable

Platform (Simple and/or Atomic)

No response

Logs or notes

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function jetpack_oembed_timeout_override(), 1 passed in /wp-includes/class-wp-hook.php on line 310 and exactly 2 expected in /wp-content/plugins/jetpack/modules/shortcodes/others.php:29
Stack trace:
#0 /wp-includes/class-wp-hook.php(310): jetpack_oembed_timeout_override(30)
#1 /wp-includes/plugin.php(205): WP_Hook->apply_filters(30, Array)
#2 /wp-content/plugins/gravityformsgoogleanalytics/includes/class-gf-google-analytics-api.php(128): apply_filters('http_request_ti...', 30)
#3 /wp-content/plugins/gravityformsgoogleanalytics/includes/class-gf-google-analytics-api.php(377): Gravity_Forms\Gravity_Forms_Google_Analytics\GF_Google_Analytics_API->make_request('accountSummarie...', 'ga4', Array)
#4 /wp-content/plugins/gravityformsgoogleanalytics/class-gf-google-analytics.php(1987): Gravity_Forms\Gravity_Forms_Google_Analytics\GF_Google_Analytics_API->get_ga4_accounts()
#5 [internal function]: Gravity_Forms\Gravity_Forms_Google_Analytics\GF_Google_Analytics->settings_ga_select_account(Object(Gravity_Forms\Gravity_Forms\Settings\Fields\Base), false)
#6 /wp-content/plugins/gravityforms/includes/settings/fields/class-base.php(215): call_user_func(Array, Object(Gravity_Forms\Gravity_Forms\Settings\Fields\Base), false)
#7 /wp-content/plugins/gravityforms/includes/settings/class-settings.php(908): Gravity_Forms\Gravity_Forms\Settings\Fields\Base->prepare_markup()
#8 /wp-content/plugins/gravityforms/includes/settings/class-settings.php(857): Gravity_Forms\Gravity_Forms\Settings\Settings->render_field(Object(Gravity_Forms\Gravity_Forms\Settings\Fields\Base))
#9 /wp-content/plugins/gravityforms/includes/settings/class-settings.php(637): Gravity_Forms\Gravity_Forms\Settings\Settings->render_section(Array)
#10 /wp-content/plugins/gravityforms/includes/addon/class-gf-addon.php(4825): Gravity_Forms\Gravity_Forms\Settings\Settings->render()
#11 /wp-content/plugins/gravityformsgoogleanalytics/class-gf-google-analytics.php(2208): GFAddOn->plugin_settings_page()
#12 /wp-includes/class-wp-hook.php(310): Gravity_Forms\Gravity_Forms_Google_Analytics\GF_Google_Analytics->plugin_settings_page('')
#13 /wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array)
#14 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#15 /wp-content/plugins/gravityforms/settings.php(144): do_action('gform_settings_...')
#16 /wp-content/plugins/gravityforms/gravityforms.php(3426): GFSettings::settings_page()
#17 /wp-includes/class-wp-hook.php(310): GFForms::settings_page('')
#18 /wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array)
#19 /wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#20 /wp-admin/admin.php(259): do_action('forms_page_gf_s...')
#21 {main}
  thrown in /wp-content/plugins/jetpack/modules/shortcodes/others.php on line 29
cliffordp commented 1 year ago

Possibly related:

anomiex commented 1 year ago

While I can't find the source for this "Gravity Forms Google Analytics" plugin to check directly, it appears to me that this is a problem in that plugin and not Jetpack.

The jetpack_oembed_timeout_override() function is registered as a handler for the core 'http_request_timeout' hook, which according to https://developer.wordpress.org/reference/hooks/http_request_timeout/ supplies two arguments since WordPress 5.1. From the stack trace provided it appears that the Gravity Forms Google Analytics plugin is calling the filter itself without supplying that second argument.

anomiex commented 1 year ago

The workaround documented in https://github.com/Automattic/jetpack/issues/29159#issuecomment-1444445656 looks like it should still work for the user until Gravity Forms Google Analytics can update their code.

cliffordp commented 1 year ago

thanks. curious why not loading shortcodes/others.php is the proposed solution. Would that cause anything to not work unexpectedly?

anomiex commented 1 year ago

It's not really a solution, it's a workaround that disables the feature that needs the WordPress 5.1-compatible invocation of the filter.

Disabling it will cause a few sites to no longer be recognized for embedding.

Gravity Forms's support should be informed that they're wrong in saying that Jetpack is responsible and that they should fix their code to invoke the 'http_request_timeout' filter in a manner compatible with WordPress 5.1+. Once they update their code, the workaround can be removed.

cliffordp commented 1 year ago

tyvm for that additional information. I passed that information along to their Support