You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Contacts cron hook crashes queuescanner.php when a contact has no display name #399
load() returns a boolean, not the object, so the next line calls store() on true or false:
PHP Fatal error: Uncaught Error: Call to a member function store() on bool
in modules/contacts/contacts.class.php:568
#0 classes/w2p/System/HookHandler.class.php(39): CContact->hook_cron()
#1 queuescanner.php(25): w2p_System_HookHandler->process()
w2p_System_HookHandler::process() only catches Exception, so this Error ends queuescanner.php. While any contact has an empty display name, the cron hooks of the modules that come after Contacts never run, for example the Files hook that indexes uploaded files and the Users hook that cleans up orphaned sessions. The event queue (queued e-mail and task reminders) is processed before the hooks, so it isn't affected. The cron job runs as no user, so load() can also fail on the permission check.
To reproduce: set one contact's contact_display_name to '', then run php queuescanner.php.
Fix: keep the object and only store it when load() succeeds (if ($myContact->load($id)) { $myContact->store(); }), or set the display name with a single UPDATE query. HookHandler could also catch Throwable so one module can't stop the others.
Activity
Contacts cron: fill in missing display names without load()/store()