Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
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.
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.
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.
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.
Comments
Comment #1
sdboyer commentedI'm not comfortable with this failing silently. Let's fix the problem, but make it error out if an empty value is passed.
Comment #2
marvil07 commentedComment #3
sdboyer commentedLet'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.
Comment #4
marvil07 commentedBetter exception message:
Changing status as #3. I'mg going to commit this now.
Comment #5
marvil07 commentedCommitted!
Comment #7
sigveio commentedIn the table versioncontrol_repositories you have a field called update_method - which will be either 0 or 1, as per these:
Setting the update method to parse on cron, value 0, leads to the check introduced in the above patch failing and throwing the exception:
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":
It's therefore not suitable for checking if a mixed variable is "empty", where 0 is considered an acceptable "non-empty" value.
Comment #8
sdboyer commentedahh, 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.
Comment #9
sdboyer commentedk, pushed a fix, and tagging a new release. thanks for the report, hoesi.
Comment #10
marvil07 commentedI 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!