Guides & Tutorials8.8 UpdateTroubleshootingError: Call to a member function enabledMetrics() on null

Error: Call to a member function enabledMetrics() on null

Symptom

After updating to WHMCS 8.8, a Call to a member function error displays in the Client Area for some users:

Error: Call to a member function enabledMetrics() on null in /path/to/whmcs/vendor/whmcs/whmcs-foundation/lib/Service/Service.php:0 

Cause

The user's current client contains an orphaned service. An orphaned service is a servicefor a product that does not exist.

The system does not allow admins to delete products while there are associated services, indicating that someone deleted the data from within the MySQL® database.

Troubleshooting

Run this query on your WHMCS installation's MySQL database to identify the orphaned services. You can do this using a tool like phpMyAdmin:

SELECT * FROM `tblhosting` WHERE `packageid` NOT IN (select id from tblproducts)

Solution

To fix this, assign the orphaned services to a product:

1. In the WHMCS Admin Area, go to Configuration > System Settings > Products/Services.

2. Click Create a New Product.

3. Enter a product name. For example, Orphaned Service.

4. Click Continue.

5. Note the package ID in the URL in your browser's URL bar:

Package ID 28

6.  Run the following MySQL query to assign the orphaned services to the newly-created product, replacing  XX with the package ID from the URL:

UPDATE tblhosting SET packageid='XX' WHERE packageid NOT IN (SELECT id FROM tblproducts);