Jump to content

Recommended Posts

Posted

I recently upgraded to 5.11. And I saw the namesilo module required an upgrade

image.thumb.png.516e7bba1046475af46abd126e3010da.png

After clicking on upgrade I get a white screen and this error in the logs

[2025-02-26T17:33:16.450128+00:00] general.ERROR: PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `blesta`.`module_client_meta`.`client_id` at row 1 in .../blesta/vendors/minphp/db/src/PdoConnection.php:196 Stack trace: #0 .../blesta/vendors/minphp/db/src/PdoConnection.php(196): PDOStatement->execute() #1 .../blesta/vendors/minphp/record/src/Record.php(305): Minphp\Db\PdoConnection->query() #2 .../blesta/components/modules/namesilo/namesilo.php(168): Minphp\Record\Record->insert() #3 .../blesta/components/modules/namesilo/namesilo.php(105): Namesilo->setContactsFromServices() #4 .../blesta/app/models/module_manager.php(449): Namesilo->upgrade() #5 .../blesta/app/controllers/admin_company_modules.php(179): ModuleManager->upgrade() #6 .../blesta/vendors/minphp/bridge/src/Lib/Dispatcher.php(142): AdminCompanyModules->upgrade() #7 .../blesta/index.php(21): Dispatcher::dispatch() #8 {main} 

 

I noticed that the error is pointing to this for loop inside the function 'setContactsFromServices' which is called from the Upgrade() method.

        foreach ($client_contacts as $contact_client_id => $contacts) {
            $this->Record->duplicate('module_id', '=', $module_row->module_id)->
                duplicate('module_row_id', '=', $module_row->id)->
                duplicate('client_id', '=', $contact_client_id)->
                duplicate('key', '=', 'contacts')->
                insert(
                    'module_client_meta',
                    [
                        'module_id' => $module_row->module_id,
                        'module_row_id' => $module_row->id,
                        'client_id' => $contact_client_id,
                        'key' => 'contacts',
                        'value' => json_encode($contacts),
                    ]
                );
        }

I guess this function call from the upgrade method is to retrieve all contacts for all domains and set them into the module_client_meta table.

The issue as I see it is that the $client_contacts does not contain contacts per customer, but its key is an empty element.

 

(data masked)
Array
(
    [] => Array <-- I guess here should be the blesta client_id?
        (
            [54789654] => Name1
            [65465465] => Name2
            [65465555] => Name3
            ...
        )

)

 

I believe these lines are setting the client_id to [] so the $contact_client_id is null.

            $contact_ids = $domainInfo->response(true)['contact_ids'];
            if (!isset($client_contacts[$client_id])) {
                $client_contacts[$client_id] = [];
            }

 

I can't get pass the upgrade method.

Posted

I think I found a solution... Around line 125 in namesilo.php

Change this:

$services = $this->Record->fetchAll();
foreach ($services as $service) {
    $domain_clients[$service->domain] = $client_id;
}

For this

$services = $this->Record->fetchAll();
foreach ($services as $service) {
    $domain_clients[$service->domain] = $client_id ?? $service->client_id;
}

 

I don't know if it still applies for cases where the client_id comes as a parameter, but I think it will.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...