analogwp / analogwp-templates

Style Kits for Elementor adds a number of intuitive styling controls in the Elementor editor that allow you to apply styles globally or per page.
https://analogwp.com
27 stars 7 forks source link

Fatal error in API call #389

Closed gvgvgvijayan closed 4 years ago

gvgvgvijayan commented 4 years ago

Steps to reproduce:

  1. Click the Favorite (star) icon of any templates
  2. API call will trigger
  3. Error from server end throws with HTTP code 500

Files with line number:

Called: https://github.com/analogwp/analogwp-templates/blob/develop/inc/api/class-local.php#L181 https://github.com/analogwp/analogwp-templates/blob/develop/inc/api/class-local.php#L183

But not decalared https://github.com/analogwp/analogwp-templates/blob/develop/inc/Plugin.php#L342

Error call stack:

Fatal error: Uncaught Error: Access to undeclared static property: Analog\Analog_Templates::$user_meta_prefix in /var/www/html/wp5.3/wp-content/plugins/analogwp-templates/inc/api/class-local.php on line 181

Call stack:

Analog\API\Local::mark_as_favorite() wp-includes/rest-api/class-wp-rest-server.php:1015 WP_REST_Server::dispatch() wp-includes/rest-api/class-wp-rest-server.php:342 WP_REST_Server::serve_request() wp-includes/rest-api.php:312 rest_api_loaded() wp-includes/class-wp-hook.php:287 WP_Hook::apply_filters() wp-includes/class-wp-hook.php:311 WP_Hook::do_action() wp-includes/plugin.php:544 do_action_ref_array() wp-includes/class-wp.php:388 WP::parse_request() wp-includes/class-wp.php:739 WP::main() wp-includes/functions.php:1274 wp() wp-blog-header.php:16 require() index.php:17

Optional to read

API call sample:

fetch("http://localhost/wp5.3/index.php/wp-json/agwp/v1/mark_favorite?_locale=user", { "headers": { "accept": "application/json, /;q=0.1", "accept-language": "en-IN,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,ta;q=0.6", "content-type": "application/json", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "x-wp-nonce": "01e34c452f" }, "referrer": "http://localhost/wp5.3/wp-admin/admin.php?page=analogwp_templates", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"id\":\"515\",\"favorite\":false,\"type\":\"template\"}", "method": "POST", "mode": "cors", "credentials": "include" });

mauryaratan commented 4 years ago

@gvgvgvijayan Can you please check the same against develop? If it works in there, it is quite possible that something has changed in your branch.

gvgvgvijayan commented 4 years ago

@mauryaratan In develop branch also same error throws here I took the screenshot after switched to develop branch also in first post I linked develop branch files only not the 384 branch files.

PFA

Error throws in develop

mauryaratan commented 4 years ago

@gvgvgvijayan thanks for clarifying. Can you try fixing it?

If you view the file history, you should be able to find it when it got deleted/moved. Ping me on Slack if any confusion.

gvgvgvijayan commented 4 years ago

@mauryaratan Got it.