Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript error in Block Editor when ClassifAI has not been set up correctly #285

Closed
junaidbhura opened this issue Jun 3, 2021 · 6 comments · Fixed by #286
Closed

JavaScript error in Block Editor when ClassifAI has not been set up correctly #285

junaidbhura opened this issue Jun 3, 2021 · 6 comments · Fixed by #286
Assignees
Labels
type:bug Something isn't working.
Milestone

Comments

@junaidbhura
Copy link
Contributor

Describe the bug
A JavaScript error is fired in the Block Editor when ClassifAI has not been set up. This prevents a post from being saved. This occurs because ClassifAI looks for a meta value without checking for its existence.

The JavaScript error says:

Uncaught TypeError: Cannot ready property '_classifai_error' of undefined

Steps to Reproduce

  1. Install and activate ClassifAI
  2. Do not enter any details
  3. Create a post in the block editor and save, ideally one with post meta boxes
  4. A JavaScript error is fired (Screenshot below)

Expected behavior
Post saves without any JavaScript errors.

Screenshots
Screen Shot 2021-06-04 at 7 50 03 am

Environment information

  • Device: Macbook Pro
  • OS: MacOS 11.4
  • Browser and version: Brave (Chromium 91)
  • WordPress version: 5.7.2

Additional context

@junaidbhura junaidbhura added the type:bug Something isn't working. label Jun 3, 2021
@jeffpaul jeffpaul added this to the 1.7.0 milestone Jun 4, 2021
@dinhtungdu
Copy link
Contributor

@junaidbhura I can't reproduce the issue on WP 5.7.2, new multisite with unconfigured ClassifAI (develop branch). Watching the value of meta, it returns an empty array in my test, which means that the variable is not undefined. Can you give me more detailed instructions?

I agree with your additional check added in #286, we should always check the existence of variable first before using them. But I want to reproduce the issue first before merging your PR.

@junaidbhura
Copy link
Contributor Author

Hey @dinhtungdu do you think you could try it on a post type that is not configured to work with ClassifAI?

@dinhtungdu
Copy link
Contributor

@junaidbhura the same thing happens for unsupported post type, they value of meta always is [].

@junaidbhura
Copy link
Contributor Author

junaidbhura commented Jun 6, 2021

Hey @dinhtungdu I've reached out to you on DM with some additional context!

@dinhtungdu
Copy link
Contributor

Thanks for the clarification! I approved the PR.

@junaidbhura
Copy link
Contributor Author

Thanks @dinhtungdu !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants