GravityKit / GravityView

The best and easiest way to display Gravity Forms entries on your website.
https://www.gravitykit.com/products/gravityview/
245 stars 63 forks source link

Fatal Error shows up for non-admin users on `class-gravityview-object-placeholder.php` if plugin not installed #2127

Closed rafaehlers closed 2 months ago

rafaehlers commented 2 months ago

If Ratings and Reviews is not installed, this Fatal Errors comes up for non-admin users, like an Editor with access to the View editor: https://docs.gravitykit.com/article/598-non-administrator-edit-view

image

Fatal error: Uncaught Error: Call to a member function get_products_data() on null in C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\plugin-and-theme-hooks\class-gravityview-object-placeholder.php:178 
Stack trace: 
#0 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\plugin-and-theme-hooks\class-gravityview-object-placeholder.php(245): GravityView_Object_Placeholder->is_included() 
#1 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\plugin-and-theme-hooks\class-gravityview-plugin-hooks-gravityview-ratings-reviews.php(51): GravityView_Object_Placeholder->render() 
#2 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\admin\metaboxes\class-gravityview-metabox-tab.php(181): GravityView_Plugin_Hooks_GravityView_Ratings_Reviews->{closure}(Object(WP_Post), Array) 
#3 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\admin\metaboxes\views\gravityview-content.php(38): GravityView_Metabox_Tab->render(Object(WP_Post)) 
#4 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\admin\metaboxes\class-gravityview-admin-metaboxes.php(108): include('C:\\Users\\rafae\\...') 
#5 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-admin\includes\template.php(1456): GravityView_Admin_Metaboxes->settings_metabox_render(Object(WP_Post), Array) 
#6 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-admin\edit-form-advanced.php(723): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post)) 
#7 C:\Users\rafae\Local Sites\gravitykit\app\public\wp-admin\post.php(206): require('C:\\Users\\rafae\\...') 
#8 {main} thrown in C:\Users\rafae\Local Sites\gravitykit\app\public\wp-content\plugins\gravityview\includes\plugin-and-theme-hooks\class-gravityview-object-placeholder.php on line 178

Steps to reproduce: 1) Make sure Ratings and Reviews are not installed 2) Create e custom View Editor role or adjust the existing Editor role to have access to the View editor 3) Log with a user on that role 4) Access the View editor and scroll down to the View Settings 5) Click on the Ratings and Reviews tab

I suspect this happens for any plugins that we upsell there (Maps, DataTables, SEO).

Tested on GV 2.27.1

rafaehlers commented 2 months ago

https://secure.helpscout.net/conversation/2690247019/56839

mrcasual commented 2 months ago

@rafaehlers, fixed by https://github.com/GravityKit/GravityView/commit/2b34a457686d2fe8c16704088a032e49815060cd.

rafaehlers commented 2 months ago

https://www.dropbox.com/scl/fi/z66xifeyxuxfrq2gb3xbh/gravityview-2.27.1-2b34a4576.zip?rlkey=gfbi05r7l757s8e4r7tdzewm1&dl=1