Editing a group space preset and saving results in the following error:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= ''' at line 1 query: SELECT id FROM purl WHERE provider = 'vsite_domain' AND = '' in /var/www/SCHOLAR-2-0-BETA10/sites/all/modules/contrib/purl/purl.module on line 591.

Comments

rolando.isidoro’s picture

Status: Active » Needs review

Hi Mark,

I got the same error you described and dug a little bit into the source code and this is what I could figure out. In the file sites/all/modules/contrib/purl/purl.module, at line 582 we have the purl_delete function as follow:

function purl_delete($modifier) {
  if (!empty($modifier['value'])) {
    $param = 'value';
    $where = $modifier['value'];
  }
  else if (!empty($modifier['id'])) {
    $param = 'id';
    $where = $modifier['id'];
  }
  $check = db_result(db_query("SELECT id FROM {purl} WHERE provider = '%s' AND $param = '%s'", $modifier['provider'], $where));
  if ($check) {
    $status = db_query("DELETE FROM {purl} WHERE provider = '%s' AND $param = '%s'", $modifier['provider'], $where);
    purl_modifiers(NULL, TRUE);
    return $status;
  }
  return FALSE;
}

The error "user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= ''' at line 1 query: SELECT id FROM purl WHERE provider = 'vsite_domain' AND = '' in /sites/all/modules/contrib/purl/purl.module on line 591" is thrown when the previous function is called with the following argument:

Array(
  [provider] => vsite_domain
  [id] =>
  [value] =>
)

Following the code we can easily see that with this input, both variables $param and $where aren't set, resulting in the malformed query. From the looks of it, this occurs when we don't set any value in the Your Sites Custom Domain form field.

Backtracing the source code a little more the call to the previous function is made in the /sites/all/modules/openscholar_vsite/vsite_domain/vsite_domain.module file, at line 173 in the vsite_domain_vsite_generic_settings_domain_submit function.

To solve the problem we could reinforce the 1st if statement in this function, changing it from:

if (is_array($value['vsite_domain']))

to:

if (is_array($value['vsite_domain']) && (!empty($value['vsite_domain']['value']) || !empty($value['vsite_domain']['id'])))

Best regards,
Rolando