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

Cannot read property 'filter' of undefined #1

Open
evantill opened this issue Sep 22, 2020 · 0 comments
Open

Cannot read property 'filter' of undefined #1

evantill opened this issue Sep 22, 2020 · 0 comments

Comments

@evantill
Copy link

Context

  • Discourse is configured with required login setting (see /admin/site_settings/category/login?filter=login).

  • Layouts plugin is installed.

  • Layout Category list Widget is installed and enabled on all themes.

  • Layouts plugin version 0.2).

  • Discourse version 2.6.0.beta2 543e972fec.

Actual

The login page display a blank page and there is an error in the debug console:

_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:4069 Uncaught TypeError: Cannot read property 'filter' of undefined
    at Object.initialize (e873dec102d20e90fb2c24daae6a56ce65472335.js?__ws=discourse.apelsophiebarat.net:38)
    at Object.s.initialize (_application-2a5d8f98ee67bd11be94df82d7e717b97d025d663f47c3c2bf412ba973929a50.js:6968)
    at _ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:49347
    at i.each (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:67724)
    at i.walk (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:67638)
    at n.each (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:67568)
    at n.topsort (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:67576)
    at t._runInitializer (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:49361)
    at t.runInstanceInitializers (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:49345)
    at t._bootSync (_ember_jquery-d0ba1603b80181031290e4bd850857d41d63bc4a081d7b4bf16d4e1a4e355a22.js:46813)

The error Uncaught TypeError: Cannot read property 'filter' of undefined is on this line :

var categories = site.categories.filter(function (c) {
        return !c.isUncategorizedCategory;
      });

I think that testing site.categories is not null before continuing should fix the problem. I will test it and can make a PR.

Expected behavior

  • Login page should work without errors.
  • The widget should not be displayed as there are no available categories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant