FriendsOfFlarum / user-directory

The permission based public user directory extension for your Flarum forum.
https://discuss.flarum.org/d/5682
MIT License
22 stars 17 forks source link

Cannot read properties of undefined (reading 'UserDirectoryPage') when re-enabling the extension #85

Open giuliomoro opened 2 years ago

giuliomoro commented 2 years ago

Bug Report

I disabled the extension and then re-enabled it. Now when trying to load any page on the user-facing site (e.g.: / or /d/2031) I get "Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error." and the js console shows:

Screenshot 2022-01-16 at 22 53 25

I tried hard refreshing and php flarum cache:clear but none of that works. Only disabling the extension makes the site work again.

Environment

Flarum core 1.1.1
PHP version: 7.4.15
MySQL version: 8.0.26-0ubuntu0.20.04.2
Loaded extensions: Core, date, libxml, pcre, sqlite3, filter, hash, intl, json, mbstring, SPL, PDO, Reflection, session, pdo_sqlite, standard, mysqlnd, bcmath, bz2, calendar, ctype, curl, dom, exif, fileinfo, ftp, gd, gettext, iconv, imap, mysqli, openssl, pcntl, pdo_mysql, zlib, posix, pspell, sodium, SimpleXML, soap, sockets, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, Phar, imagick, Zend OPcache
+-----------------------------+---------+--------+
| Flarum Extensions           |         |        |
+-----------------------------+---------+--------+
| ID                          | Version | Commit |
+-----------------------------+---------+--------+
| flarum-subscriptions        | v1.1.0  |        |
| flarum-tags                 | v1.1.0  |        |
| flarum-flags                | v1.1.0  |        |
| flarum-markdown             | v1.1.1  |        |
| fof-follow-tags             | 1.0.2   |        |
| flarum-suspend              | v1.1.0  |        |
| flarum-approval             | v1.1.0  |        |
| the-turk-mathren            | 1.0.3   |        |
| matteocontrini-imgur-upload | v3.9.1  |        |
| ianm-follow-users           | 1.0.4   |        |
| fof-user-directory          | 1.2.0   |        |
| fof-subscribed              | 1.0.2   |        |
| fof-split                   | 1.0.1   |        |
| fof-recaptcha               | 1.0.0   |        |
| fof-merge-discussions       | 1.1.5   |        |
| fof-impersonate             | 1.0.1   |        |
| fof-formatting              | 1.0.2   |        |
| fof-analytics               | 1.0.0   |        |
| flarum-sticky               | v1.1.0  |        |
| flarum-statistics           | v1.1.0  |        |
| flarum-mentions             | v1.1.3  |        |
| flarum-lock                 | v1.1.0  |        |
| flarum-likes                | v1.1.0  |        |
| flarum-emoji                | v1.1.1  |        |
| flarum-bbcode               | v1.1.0  |        |
| flarum-akismet              | v1.1.0  |        |
| askvortsov-markdown-tables  | v1.2.1  |        |
+-----------------------------+---------+--------+
Base URL: https://wtf.bela.io
Installation path: /home/belaplatform/wtf.bela.io
Queue driver: sync
Mail driver: smtp
Debug mode: ON

grep'ing for 'fof-user-directory` in the database gives:

(224, '2019_06_10_000000_rename_permissions', 'fof-user-directory'),
('c-link', '0'),
('fof-user-directory.default-sort', ''),
('fof-user-directory.disable-global-search-source', '1'),
('fof-user-directory.use-small-cards', '0'),
clarkwinkelmann commented 2 years ago

I think the problem might be with ianm/follow-users. Can you try to disable that extension and re-enable it after User Directory to see if the issue goes away?

If that's the case it's surprising because it seems like the extending is done correctly. It's used in JS here https://github.com/imorland/follow-users/blob/d0c156e90feb7fba5ec491048bc1ce4ffc3ed15d/js/src/forum/addFollowingUsers.js#L33 and due to the optional-dependencies https://github.com/imorland/follow-users/blob/d0c156e90feb7fba5ec491048bc1ce4ffc3ed15d/composer.json#L42 checking for the initializer should be enough.

@imorland want to take a look?

giuliomoro commented 2 years ago

I think the problem might be with ianm/follow-users. Can you try to disable that extension and re-enable it after User Directory to see if the issue goes away?

That worked: I disabled ianm/follow-users, re-enabled fof/user-directory, re-enabled ianm/follow-users. All seems to be working fine now.