Skip to content

Contacts cron hook crashes queuescanner.php when a contact has no display name #399

Closed

Description

@caseysoftware

CContact::hook_cron() (modules/contacts/contacts.class.php) reloads every contact whose contact_display_name is empty and stores it again:

$myContact = new CContact();
$myContact->overrideDatabase($this->_query);
$myContact = $myContact->load($contactId['contact_id']);
$myContact->store();

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

  1. added a commit that references this issue on Oct 21, 2026
    eef4507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions