flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.3k stars 835 forks source link

[Likes] b8 liking deleted post gives error #1618

Closed dsevillamartin closed 4 years ago

dsevillamartin commented 5 years ago

Bug Report

Current Behavior

Deleted post is liked, but error when firing notification for deleted author

Notice: Trying to get property 'id' of non-object in flarum-likes/src/Listener/SendNotificationWhenPostIsLiked.php on line 80

Steps to Reproduce

  1. Change author id of post to non-existent user
  2. Click "Like"
  3. See error

Expected Behavior No error

Screenshots

image

image image


Environment

Flarum core 0.1.0-beta.7 (477553542120a5e59078051acf6f0001c99afaf0)
PHP version: 7.1.23
Loaded extensions: Core, phpdbg_webhelper, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, fileinfo, filter, ftp, gd, gettext, gmp, SPL, iconv, intl, json, ldap, mbstring, mcrypt, session, standard, odbc, pcntl, mysqlnd, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, readline, Reflection, mysqli, shmop, SimpleXML, soap, sockets, exif, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, Zend OPcache
+-------------------------------+---------------+------------------------------------------+
| Flarum Extensions             |               |                                          |
+-------------------------------+---------------+------------------------------------------+
| ID                            | Version       | Commit                                   |
+-------------------------------+---------------+------------------------------------------+
| flarum-mentions               | dev-master    |                                          |
| flarum-likes                  | dev-master    | 2281fe358730c845c2b78b72a339179f527a4077 |
| flarum-tags                   | dev-master    | 87fdf0b8079b71a588f936915f7ed64e75516c78 |
| flagrow-impersonate           | dev-master    |                                          |
| flagrow-users-list            | 0.1.2         |                                          |
| flarum-markdown               | v0.1.0-beta.5 |                                          |
| flarum-bbcode                 | dev-master    |                                          |
| flarum-subscriptions          | dev-master    |                                          |
| flarum-lang-english           | dev-master    | 504ba127e1908848c7c70684176ef4cc670749a8 |
| datitisev-dashboard           | dev-beta.8    | 083f5d75db355fb3ee3a5a3fb09932c621d00ad2 |
| flarum-statistics             | dev-master    | 59e2f896dac3bb430ca7a0e403050694763d081a |
| reflar-reactions              | dev-beta.8    | ace999fbdee57fbf011ba38307ba207a3210ef1b |
| reflar-polls                  | dev-beta8     | 0af9caa3d8e20bcb49a27962c32f11c2fcfffca5 |
| fof-secure-https              | dev-master    | e2accba6a4fa05e3037fe5c3000a6fb1118705b3 |
| fof-formatting                | dev-master    | 5927bf2d3faf08dc635a1c1c92eb454d6e6cfebc |
| flarum-flags                  | dev-master    | 87cd4e44b0c2a1b6ebbf265c2de24b57990d0c0c |
+-------------------------------+---------------+------------------------------------------+
Base URL: https://flarum-latest.localhost
Installation path: /Users/david/Sites/flarum-latest
Debug mode: ON
Don't forget to turn off debug mode! It should never be turned on in a production system.

Possible Solution Don't fire notifications if the actor/author does not exist

askvortsov1 commented 4 years ago

I'm unable to reproduce this: Liking/unliking posts with deleted authors works fine with no error message for me. I'm assuming we fixed something that fixed this during the past 2 years.

dsevillamartin commented 4 years ago

You may need PHP errors/warnings to be enabled to reproduce the error, @askvortsov1. The error used to be at line 80 but now should be at line 33.

Using fof/sentry might help with seeing these warnings.

askvortsov1 commented 4 years ago

This was fixed in https://github.com/flarum/likes/pull/17, I've confirmed the fix, and we can probably close this issue