Hi, can someone fix behaviour of GFCommon::is_preview() for wp-cli please?
We have a lot of warnings in logs because of this
When it’s called in console mode, RGFormsModel::get_current_page_url() returns URLs without “/” at the end because REQUEST_URI is an empty string for wp-cli (we have multisite, if it matters). In this case parse_url doesn’t return “path” component, and PHP throws “Notice: Undefined index: path” all the time.
public static function is_preview() {
$url_info = parse_url( RGFormsModel::get_current_page_url() );
$file_name = basename( $url_info['path'] );
return $file_name == 'preview.php' || rgget( 'gf_page', $_GET ) == 'preview';
}
Something like this should be enough, well depending on your required PHP version:
$file_name = basename( $url_info['path'] ?? '' );
Or you can always return false for wp-cli.
if ('cli' === PHP_SAPI) { return false; }
Thanks!