luceos PHP 8.1 Bro
Today I got the above error when replying with empty content. I have corrected it as above
(new Extend\Validator(\Flarum\Post\PostValidator::class))
->configure(function ($flarumValidator, $validator) {
$rules = $validator->getRules();
// Not all attributes are validated every time. Skip if content is not being validated
if (!array_key_exists('content', $rules)) {
return;
}
$rules['content'][] = 'min:30';
$rules['content'] = array_map(function(string $rule) {
if (\Illuminate\Support\Str::startsWith($rule, 'max:')) {
return 'max:20000';
}
return $rule;
}, $rules['content']);
$validator->setRules($rules);
}),
Flarum core: 1.8.3
PHP version: 8.1.26
MySQL version: 10.6.16-MariaDB
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, readline, Reflection, SPL, session, standard, bcmath, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, intl, exif, mysqlnd, PDO, Phar, posix, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlwriter, xsl, mysqli, pdo_mysql, pdo_sqlite, xmlreader, igbinary, memcache, msgpack, memcached, Zend OPcache
+-------------------------------------------+-----------------+--------+
| Flarum Extensions | | |
+-------------------------------------------+-----------------+--------+
| ID | Version | Commit |
+-------------------------------------------+-----------------+--------+
| flarum-flags | v1.8.0 | |
| flarum-tags | v1.8.0 | |
| flarum-approval | v1.8.1 | |
| flarum-likes | v1.8.0 | |
| flarum-suspend | v1.8.1 | |
| flarum-mentions | v1.8.2 | |
| flarum-subscriptions | v1.8.0 | |
| antoinefr-money | v1.3.1 | |
| v17development-seo | v1.8.0 | |
| flarum-sticky | v1.8.0 | |
| flarum-lock | v1.8.0 | |
| fof-formatting | 1.0.3 | |
| ziiven-daily-check-in | v0.3.7 | |
| afrux-forum-widgets-core | v0.1.7 | |
| fof-user-directory | 1.3.3 | |
| fof-follow-tags | 1.2.2 | |
| flarum-nicknames | v1.8.0 | |
| fof-pages | 1.0.8 | |
| fof-masquerade | 2.1.4 | |
| ziiven-view-history | v0.1.7 | |
| ziiven-post-number | v0.1.3 | |
| ziiven-money-transfer | v0.2.5 | |
| ziiven-money-leaderboard | v0.1.7 | |
| yohtozze-markdown-paste | 1.1.0 | |
| xsoft-ict-mason-tag | v1.0.2 | |
| v17development-blog | v0.7.7 | |
| the-turk-stickiest | 3.0.1 | |
| the-turk-quiet-edits | 0.1.3 | |
| the-turk-flamoji | 1.0.4 | |
| the-turk-diff | 1.1.2 | |
| sycho-move-posts | v0.1.7 | |
| sycho-lite-youtube | v0.1.1 | |
| rob006-last-post-avatar | 1.2.4 | |
| ramesh-dada-mobile-newdiscuss | 7.2.1 | |
| nearata-related-discussions | 1.4.0 | |
| nearata-prevent-double-posting | 1.1.0 | |
| nearata-monaco-editor | 1.0.0 | |
| nearata-copy-code-to-clipboard | v2.2.0 | |
| mickmelon-coloured-usernames | 0.1.1 | |
| michaelbelgium-profile-views | v8.0.2 | |
| mattoid-daily-check-in-history | v1.0.3 | |
| matteocontrini-imgur-upload | v3.9.1 | |
| matteociaroni-public-suspensions | v1.0.0 | |
| littlecxm-whisper | 0.1.5 | |
| litalino-more-bbcode | 1.7.0 | |
| justoverclock-welcomebox | 2.0.2 | |
| justoverclock-username-blacklist | 0.1.0 | |
| justoverclock-purify | 0.1.7 | |
| justoverclock-hot-discussions | 0.1.2 | |
| justoverclock-first-visit-indexpage | 0.1.2 | |
| justoverclock-discussion-info | 0.1.5 | |
| justoverclock-country-flags | 0.2.1 | |
| justoverclock-contactme | 0.2.3 | |
| justoverclock-best-answer-badge | 0.1.0 | |
| justoverclock-be-active-user-indicator | 0.1.0 | |
| ianm-syndication | 1.3.3 | |
| ianm-html-head | 1.2.3 | |
| ianm-follow-users | 1.4.2 | |
| glowingblue-password-strength | 3.1.0 | |
| gbcl-userip | 1.0.4 | |
| fof-username-request | 1.2.3 | |
| fof-upload | 1.4.7 | |
| fof-subscribed | 1.1.4 | |
| fof-split | 1.1.1 | |
| fof-sitemap | 2.2.1 | |
| fof-share-social | 1.1.3 | |
| fof-profile-image-crop | 1.1.6 | |
| fof-prevent-necrobumping | 1.1.2 | |
| fof-polls | 2.1.2 | |
| fof-oauth | 1.6.5 | |
| fof-nightmode | 1.5.3 | |
| fof-moderator-notes | 1.2.1 | |
| fof-merge-discussions | 1.4.1 | |
| fof-links | 1.2.1 | |
| fof-linguist | 1.1.2 | |
| fof-ignore-users | 1.2.1 | |
| fof-gamification | 1.6.4 | |
| fof-filter | 1.1.3 | |
| fof-drafts | 1.2.10 | |
| fof-disposable-emails | 1.0.0 | |
| fof-discussion-thumbnail | 1.1.3 | |
| fof-default-user-preferences | 1.2.1 | |
| fof-default-group | 1.1.1 | |
| fof-custom-footer | 1.1.1 | |
| fof-best-answer | 1.4.1 | |
| fof-ban-ips | 1.1.1 | |
| fof-anti-spam | 1.0.0 | |
| fof-analytics | 1.1.0 | |
| flarumtr-mobile-search | v1.2 | |
| flarumite-simple-discussion-views | 1.2.2 | |
| flarum-pusher | v1.8.0 | |
| flarum-package-manager | v1.0.0-beta.2 | |
| flarum-lang-vietnamese | v1.8.0 | |
| flarum-lang-english | v1.8.0 | |
| ecnu-im-sticky-sidenav | v1.1.0 | |
| davwheat-custom-sidenav-links | 1.0.1 | |
| datlechin-silent-edit | v0.1.0 | |
| datlechin-scroll-buttons | v1.1.0 | |
| datlechin-posted-on | v0.2.1 | |
| datlechin-discussion-overview | v0.0.1 | |
| datlechin-discussion-count | v0.1.0 | |
| datlechin-copy-links | v0.1.1 | |
| datlechin-birthdays | v2.0.1 | |
| darkle-fancybox | 1.1.2 | |
| club-1-cross-references | v1.1.1 | |
| club-1-chore-commands | v1.0.0 | |
| clarkwinkelmann-who-read | 1.4.1 | |
| clarkwinkelmann-reset-preferences | 1.0.0 | |
| clarkwinkelmann-post-bookmarks | 1.0.0 | |
| clarkwinkelmann-money-to-all | 1.0.0 | |
| clarkwinkelmann-mailing | 1.1.0 | |
| clarkwinkelmann-lock-likes | 1.1.1 | |
| clarkwinkelmann-likes-received | 1.0.2 | |
| clarkwinkelmann-group-list | 1.0.0 | |
| clarkwinkelmann-first-post-approval | 1.0.1 | |
| clarkwinkelmann-circle-groups | 1.0.1 | |
| clarkwinkelmann-author-change | 1.0.3 | |
| clarkwinkelmann-advanced-search-highlight | 1.0.2 | |
| blomstra-usercard-stats | 0.1.2 | |
| blomstra-user-filter | 0.1.4 | |
| blomstra-turnstile | 0.1.4 | |
| blomstra-spam-prevention | 1.5.0 | |
| blomstra-sort-order-toggle | 0.2.0 | |
| blomstra-digest | 0.1.0-beta.11.6 | |
| blomstra-database-queue | 1.0.2 | |
| blomstra-cache-assets | 0.5 | |
| askvortsov-pwa | v3.3.3 | |
| askvortsov-moderator-warnings | v0.6.3 | |
| askvortsov-discussion-templates | v0.8.3 | |
| askvortsov-categories | v3.0.9 | |
| afrux-forum-stats-widget | v0.1.1 | |
| acpl-my-tags | 1.2.2 | |
| acpl-mobile-tab | 1.4.1 | |
| acpl-lscache | v2.2.1 | |
+-------------------------------------------+-----------------+--------+
Base URL: https://khatvongsong.vn
Installation path: /home/khatvongsong.vn/public_html
Queue driver: database
Session driver: file
Scheduler status: Hoạt động
Mail driver: smtp
Debug mode: off
[root@linux-os public_html]#
I use the code below // getting error when replying with empty content: in file extend.php
flarum.ERROR: TypeError: Flarum\Mentions\Formatter\UnparsePostMentions::__invoke(): Argument #2 ($xml) must be of type string, null given, called in /home/khatvongsong.vn/public_html/vendor/flarum/core/src/Foundation/ContainerUtil.php on line 30 and defined in /home/kkhatvongsong.vn/public_html/vendor/flarum/mentions/src/Formatter/UnparsePostMentions.php:34
(new Extend\Event)
->listen(\Flarum\Post\Event\Saving::class, function ($event) {
// Exclude enforcement for administrator and moderator groups
$user = $event->actor;
if ($user instanceof \Flarum\User\User && ($user->isAdmin())) { //|| $user->isModerator())
//return;
}
if ($event->post->isDirty('content')) {
resolve(\Illuminate\Contracts\Validation\Factory::class)->make([
'content' => $event->post->content,
], [
'content' => 'min:20|max:20000',
])->validate();
}
}),
The strange thing is that I made 2 identical pages:: one page has no error, the other page has the same error as above <<<< by plugin flarum-mentions "flarum.ERROR: TypeError: Flarum\Mentions\Formatter\UnparsePostMentions::__invoke(): Argument #2 ($xml) ...."