cardquery: a prop-filter without an actual filter rule means we simply need to ensure the property exists

This guards against a crash when calling ->GetNSTag() on a non-object.

This may need to be refined in case we could be dealing with something
that's not a prop-filter.
This commit is contained in:
Florian Schlichting 2017-04-08 21:42:59 +02:00
parent 06e20e5508
commit 29e2dbfe92

View File

@ -109,13 +109,20 @@ function SqlFilterCardDAV( $filter, $components, $property = null, $parameter =
$sql = "";
$params = array();
// a prop-filter without an actual filter rule means we simply need to ensure the property exists
if ( !is_object($filter) ) {
if ( empty($property) ) return false;
$sql .= $property . ' IS NOT NULL';
return array( 'sql' => $sql, 'params' => $params );
}
$tag = $filter->GetNSTag();
dbg_error_log("cardquery", "Processing $tag into SQL - %d, '%s', %d\n", count($components), $property, isset($parameter) );
$not_defined = "";
switch( $tag ) {
case 'urn:ietf:params:xml:ns:carddav:is-not-defined':
$sql .= $property . 'IS NULL';
$sql .= $property . ' IS NULL';
break;
case 'urn:ietf:params:xml:ns:carddav:text-match':