(running hostmaster 6.x-1.1 - I don't see that choice in dropdowns...)

I've enabled client support in aegir, and am now attempting to import a site alias created from provision-save. It looks like the client object is being passed to mysqli_real_escape_string(), resulting in an error:

[aegir@host ~]$ drush provision-save @jktestcom --context_type=site --uri='jktest.com' --platform='@platform_jktestcom' --client_email='jlkinsel@yahoo.com' --client_name='jlkinsel@yahoo.com' --db_server='@server_localhost'
[aegir@host ~]$ drush @hostmaster hosting-import @jktestcom
WD php: mysqli_real_escape_string() expects parameter 2 to be string, object given in
/var/aegir/hostmaster-6.x-1.0/includes/database.mysqli.inc on line 330.     [error]
mysqli_real_escape_string() expects parameter 2 to be string, object given in /var/aegir/hostmaster-6.x-1.0/includes/database.mysqli.inc
on line 330.     [warning] 

Content of site and platform definitions:

[aegir@host ~]$ cat .drush/jktestcom.alias.drushrc.php
<?php
$aliases['jktestcom'] = array (
  'context_type' => 'site',
  'platform' => '@platform_jktestcom',
  'server' => '@server_master',
  'db_server' => '@server_localhost',
  'uri' => 'jktest.com',
  'root' => '/home/jail/./home/jktest/public_html',
  'site_path' => '/home/jail/./home/jktest/public_html/sites/jktest.com',
  'site_enabled' => true,
  'language' => 'en',
  'client_name' => 'my@email.com',
  'aliases' =>
  array (
  ),
  'redirection' => false,
  'profile' => 'default',
);
[aegir@hosting1 ~]$ cat .drush/platform_jktestcom.alias.drushrc.php
<?php
$aliases['platform_jktestcom'] = array (
  'context_type' => 'platform',
  'server' => '@server_master',
  'web_server' => '@server_master',
  'root' => '/home/jail/./home/jktest/public_html',
  'makefile' => '',
);

Here's a trace leading up to the error:

                                db_escape_string(Object:stdClass) # line  224, file: /var/aegir/hostmaster-6.x-1.1/includes/database.inc
                                                _db_query_callback(Array[2]) # line    0, file: unknown
                              preg_replace_callback("/(%d|%s|%%|%f|%b|%n)/", "_db_query_callback", "SELECT c.nid FROM hosting_client c JOIN node n ON c.nid = n.nid ...") # line   40, file: /var/aegir/hostmaster-6.x-1.1/includes/database.mysql-common.inc
                            db_query("SELECT c.nid FROM {hosting_client} c JOIN {node} n ON c.nid = n....", Object:stdClass) # line  125, file: /var/aegir/hostmaster-6.x-1.1/profiles/hostmaster/modules/hosting/client/hosting_client.module
                          hosting_get_client(Object:stdClass) # line  170, file: /var/aegir/hostmaster-6.x-1.1/profiles/hostmaster/modules/hosting/site/hosting_site.nodeapi.inc
                        hosting_site_update(Object:stdClass, null, null, null) # line  659, file: /var/aegir/hostmaster-6.x-1.1/modules/node/node.module
                      node_invoke(Object:stdClass, "update") # line  937, file: /var/aegir/hostmaster-6.x-1.1/modules/node/node.module
                    node_save(Object:stdClass) # line  124, file: /var/aegir/hostmaster-6.x-1.1/profiles/hostmaster/modules/hosting/hosting.drush.inc
                  hosting_drush_import("@jktestcom") # line   78, file: /var/aegir/hostmaster-6.x-1.1/profiles/hostmaster/modules/hosting/hosting.drush.inc
                drush_hosting_import("@jktestcom") # line    0, file: unknown
              call_user_func_array("drush_hosting_import", Array[1]) # line  120, file: /var/aegir/drush/includes/command.inc
            drush_invoke_args("hosting-import", Array[1]) # line   58, file: /var/aegir/drush/includes/command.inc
          drush_invoke("hosting-import", "@jktestcom") # line    0, file: unknown
        call_user_func_array("drush_invoke", Array[2]) # line  721, file: /var/aegir/drush/includes/command.inc
      drush_command("@jktestcom") # line    0, file: unknown
    call_user_func_array("drush_command", Array[1]) # line  204, file: /var/aegir/drush/includes/command.inc
  drush_dispatch(Array[22]) # line  101, file: /var/aegir/drush/drush.php
drush_main() # line   41, file: /var/aegir/drush/drush.php

I'm not sure if this is an issue to address in hosting_site_update() or hosting_get_client() - at line 122 in hosting_client.module I added...

  elseif (is_object($client)) {
    return $client;

Which I think fixed this, but I'm having other issues, so not positive...

Comments

Steven Jones’s picture

Title: mysqli_real_escape_string() expects parameter 2 to be string when trying to resolve client » Clients are not imported from the backend correctly
Version: 6.x-0.4-alpha3 » 6.x-1.3

Bingo!

Thanks for the excellent bug report. This bug exists in the latest version of Aegir too.

Note that:

In hosting_import_site we do this:


  if ($data['client_name']) {
    $client = hosting_import_client($data['client_name']);
  }
...
  $site->client = $client->nid;

But in hosting_site_drush_context_import we do this:

 
    $client = node_load(HOSTING_DEFAULT_CLIENT);
    if ($context->client_name) {
      $client = hosting_import_client($context->client_name);
    }
    $node->client = $client;

We should do one or the other eh?

Steven Jones’s picture

Status: Active » Fixed

Fix was painfully simple:
http://drupalcode.org/project/hostmaster.git/commitdiff/463d03fe70a3b80d...

Thanks for the bug report again!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit c1d3047 on 7.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #1213442 - Fixes Clients are not imported from the backend...

  • Commit c1d3047 on 7.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #1213442 - Fixes Clients are not imported from the backend...