Comments

sdboyer’s picture

Status: Needs review » Needs work
Issue tags: +git sprint 8

I'm not comfortable with this failing silently. Let's fix the problem, but make it error out if an empty value is passed.

marvil07’s picture

Status: Needs work » Needs review
StatusFileSize
new649 bytes
sdboyer’s picture

Status: Needs review » Needs work

Let's improve the error message a bit by adding the name of the field that the empty condition is trying to be attached to. It'll make debugging a lot easier. With that change, it's RTBC.

marvil07’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.16 KB

Better exception message:

          throw new Exception(t('Attempted to attach an empty condition on field @field with the controller @controller.', array('@field' => $field, '@controller' => get_class($this))), E_ERROR);

Changing status as #3. I'mg going to commit this now.

marvil07’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

sigveio’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Needs work

In the table versioncontrol_repositories you have a field called update_method - which will be either 0 or 1, as per these:

define('VERSIONCONTROL_UPDATE_LOG_PARSE_ON_CRON', 0);
define('VERSIONCONTROL_UPDATE_INDEPENDENT_EXTERNAL_SCRIPTS', 1);

Setting the update method to parse on cron, value 0, leads to the check introduced in the above patch failing and throwing the exception:

if (!empty($value)) {
  $this->attachCondition($query, $field, $value);
}
else {
  throw new Exception(t('Attempted to attach an empty condition on field @field with the controller @controller.', array('@field' => $field, '@controller' => get_class($this))), E_ERROR);
}

Which in turn leads to an uncaught exception and breaks the entire cron.php run completely. I'm assuming that is not intentional?

A caveat with with empty() is that is considers the following to be "empty":

"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

It's therefore not suitable for checking if a mixed variable is "empty", where 0 is considered an acceptable "non-empty" value.

sdboyer’s picture

ahh, good call, that should be an isset().

this'll be a problem with versioncontrol_git's cron hook...crap. i need to roll a new release before we deploy this to d.o.

sdboyer’s picture

Status: Needs work » Fixed

k, pushed a fix, and tagging a new release. thanks for the report, hoesi.

marvil07’s picture

I guess this appeared after the change on vc_git hook_cron to use controller condition to load only update-on-cron repositories instead of manual query(which was coherent and needed ;-)).

Sadly isset() does not handle the original case in this issue, so I am changing it a little an adding the attached patch to D6 and D7.

Thanks for reporting!

Status: Fixed » Closed (fixed)
Issue tags: -git phase 2, -git sprint 8

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

  • Commit d9b347e on repository-families, drush-vc-sync-unlock by marvil07:
    bug #1001480 by marvil07 | sdboyer: Prevent empty values to be attached...
  • Commit 452426d on 7.x-1.x, repository-families, drush-vc-sync-unlock by marvil07:
    Issue #1001480 follow-up by marvil07 | hoesi: Let pseudo-empty non-array...

  • Commit d9b347e on repository-families by marvil07:
    bug #1001480 by marvil07 | sdboyer: Prevent empty values to be attached...
  • Commit 452426d on 7.x-1.x, repository-families by marvil07:
    Issue #1001480 follow-up by marvil07 | hoesi: Let pseudo-empty non-array...