FriendsOfFlarum / default-user-preferences

Enable emails for replies and mentions by default in user preferences
MIT License
6 stars 3 forks source link

Type hint error on PHP <8.0 #4

Closed clarkwinkelmann closed 2 years ago

clarkwinkelmann commented 2 years ago

Bug Report

Current Behavior Latest version of extension doesn't work on PHP 7.4

PHP Fatal error: Uncaught TypeError: Argument 2 passed to FoF\DefaultUserPreferences\Extend\RegisterUserPreferenceDefault::default() must be an instance of FoF\DefaultUserPreferences\Extend\mixed, int given, called in /home/odieshos/domain.com/vendor/fof/nightmode/extend.php on line 61 and defined in /home/odieshos/domain.com/vendor/fof/default-user-preferences/src/Extend/RegisterUserPreferenceDefault.php:33

Steps to Reproduce Try using with PHP <8.0 Probably needs one of the other extension that provide integration, like the latest version of fof/nightmode

Expected Behavior Extension should support PHP 7.3 and 7.4 or define an explicit 8.0 requirement.

Environment

Flarum core 1.3.1
PHP version: 7.4.30
MySQL version: 8.0.29-cll-lve
Loaded extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bz2, calendar, ctype, curl, hash, filter, ftp, gettext, gmp, SPL, iconv, pcntl, readline, Reflection, session, standard, shmop, SimpleXML, mbstring, tokenizer, xml, i360, bcmath, dbase, dom, fileinfo, gd, json, propro, raphf, http, igbinary, imagick, imap, intl, exif, mysqli, mysqlnd, OAuth, PDO, pdo_mysql, pdo_sqlite, Phar, posix, redis, soap, sockets, xmlreader, xmlwriter, xsl, yaml, zip, ionCube Loader
+------------------------------------------+---------+--------+
| Flarum Extensions | | |
+------------------------------------------+---------+--------+
| ID | Version | Commit |
+------------------------------------------+---------+--------+
| flarum-flags | v1.3.0 | |
| flarum-subscriptions | v1.3.1 | |
| flarum-tags | v1.3.0 | |
| flarum-approval | v1.3.0 | |
| flarum-suspend | v1.3.1 | |
| flarum-lock | v1.3.0 | |
| flarum-markdown | v1.3.0 | |
| flarum-likes | v1.3.0 | |
| flarum-bbcode | v1.3.0 | |
| flarum-sticky | v1.3.0 | |
| afrux-forum-widgets-core | v0.1.7 | |
| fof-follow-tags | 1.1.5 | |
| fof-impersonate | 1.1.0 | |
| fof-byobu | 1.1.6 | |
| sycho-advanced-extension-categories | v0.1.3 | |
| zerosonesfun-up | 1.0 | |
| zerosonesfun-inline-audio | 2.0 | |
| zerosonesfun-essential-audio | 0.3 | |
| zerosonesfun-direct-links | 2.2 | |
| zerosonesfun-bbcode-button | 1.1.2 | |
| v17development-user-badges | v0.2.1 | |
| v17development-seo | v1.8.0 | |
| v17development-blog | 0.4.2 | |
| therealsujitk-gifs | v4.1.1 | |
| the-turk-diff | 1.1.1 | |
| sycho-profile-cover | v1.3.2 | |
| serakoi-verified-badge | 0.0.3 | |
| ramesh-dada-realtime | 100.1 | |
| ramesh-dada-gui-image-and-link | 1.0 | |
| noriods-auto-more | v1.0.0 | |
| nomiscz-auth-steam | v1.0.1 | |
| nearata-no-self-likes | v1.2.0 | |
| nearata-cakeday | v2.0.0 | |
| malago-ads | 0.3.2 | |
| littlecxm-reply-to-see | 1.0.2 | |
| kilowhat-audit-free | 1.5.1 | |
| justoverclock-welcomebox | 1.3.6 | |
| justoverclock-thread-read-time | 0.1.7 | |
| justoverclock-hashtag | 1.0.1 | |
| justoverclock-feedback | 0.1.9 | |
| justoverclock-emoticonpack | 0.1.2 | |
| justoverclock-edit-posts | 0.1.1 | |
| justoverclock-custom-html-widget | 0.1.4 | |
| justoverclock-broken-links-checker | 0.1.1 | |
| isamuraii-op-dark-mode-tuning | 0.2 | |
| ianm-same-page-admin | 0.1.0 | |
| ianm-html-head | 1.1.0 | |
| ianm-follow-users | 1.1.1 | |
| fof-webhooks | 1.0.6 | |
| fof-username-request | 1.0.1 | |
| fof-user-bio | 1.1.0 | |
| fof-upload | 1.2.3 | |
| fof-terms | 1.1.2 | |
| fof-split | 1.0.1 | |
| fof-spamblock | 1.0.2 | |
| fof-socialprofile | 1.1.4 | |
| fof-sitemap | 1.0.3 | |
| fof-share-social | 1.1.0 | |
| fof-reactions | 1.1.0 | |
| fof-profile-image-crop | 1.0.1 | |
| fof-prevent-necrobumping | 1.0.1 | |
| fof-polls | 1.1.0 | |
| fof-pages | 1.0.4 | |
| fof-oauth | 1.2.2 | |
| fof-moderator-notes | 1.1.0 | |
| fof-links | 1.1.1 | |
| fof-linguist | 1.0.4 | |
| fof-ignore-users | 1.1.0 | |
| fof-html-errors | 1.1.0 | |
| fof-github-autolink | 1.0.0 | |
| fof-formatting | 1.0.2 | |
| fof-drafts | 1.1.2 | |
| fof-discussion-thumbnail | 1.1.0 | |
| fof-default-user-preferences | 1.1.0 | |
| fof-cookie-consent | 1.1.0 | |
| fof-best-answer | 1.2.2 | |
| fof-bbcode-tabs | 1.0.2 | |
| fof-bbcode-details | 1.0.0 | |
| fof-ban-ips | 1.0.2 | |
| flarumtr-mobile-search | v1.2 | |
| flarumite-simple-spoilers | 1.0.0 | |
| flarum-statistics | v1.3.0 | |
| flarum-pusher | v1.3.0 | |
| flarum-mentions | v1.3.1 | |
| flarum-lang-turkish | 1.3.1.2 | |
| flarum-emoji | v1.3.0 | |
| dem13n-topic-starter-label | 0.1.8 | |
| davwheat-custom-sidenav-links | 1.0.1 | |
| datlechin-pronouns | v0.1.0 | |
| datlechin-posted-on | v0.1.6 | |
| datlechin-keyboard-shortcuts | v0.1.1 | |
| datlechin-bbcode-hide-content | v0.1.0 | |
| datlechin-add-like-controls | v1.0.6 | |
| clarkwinkelmann-status | 1.0.0 | |
| clarkwinkelmann-shadow-ban | 1.1.0 | |
| clarkwinkelmann-scratchpad | 1.5.1 | |
| clarkwinkelmann-predefined-avatars | 1.0.1 | |
| clarkwinkelmann-popular-discussion-badge | 1.1.0 | |
| clarkwinkelmann-mailing | 1.0.0 | |
| clarkwinkelmann-emojionearea | 1.0.0 | |
| clarkwinkelmann-editable-user-attributes | 1.0.0 | |
| clarkwinkelmann-create-user-modal | 1.3.0 | |
| clarkwinkelmann-comicsans | 1.0.0 | |
| clarkwinkelmann-circle-groups | 1.0.1 | |
| clarkwinkelmann-author-change | 1.0.2 | |
| blomstra-notification-deleter | 0.2.1 | |
| askvortsov-rich-text | v2.1.7 | |
| askvortsov-pwa | v3.1.3 | |
| askvortsov-moderator-warnings | v0.6.1 | |
| askvortsov-checklist | v1.3.1 | |
| askvortsov-categories | v3.0.6 | |
| antoinefr-bbcode-fa | v1.0.0 | |
| afrux-top-posters-widget | v0.1.4 | |
| afrux-online-users-widget | v0.1.6 | |
| afrux-news-widget | v0.1.1 | |
| afrux-forum-stats-widget | v0.1.1 | |
| afrux-asirem | v0.1.7 | |
| acpl-mobile-tab | 1.1.0 | |
| 2nrwls-audio | v3.0 | |
+------------------------------------------+---------+--------+

Possible solution(s) mixed typing isn't available before PHP 8.0

It seems to be used in 2 different places in the extension, introduced in #3

https://github.com/FriendsOfFlarum/default-user-preferences/blob/310d4d92b9197cee83b81d4d57524d17b702ba0a/src/Extend/RegisterUserPreferenceDefault.php#L33

https://github.com/FriendsOfFlarum/default-user-preferences/blob/310d4d92b9197cee83b81d4d57524d17b702ba0a/src/Listeners/ApplyDefaultPreferences.php#L47

Additional Context Reported at https://discuss.flarum.org/d/31088-an-error-about-fof-night-mode

Something similar was just fixed in core by luceos. Coincidence? https://github.com/flarum/framework/commit/9532b71312977c9f8e3ee92371bc0c39266b89f7

luceos commented 2 years ago

You cheeky @imorland 😂