Skip to content
  • Alex Vandiver's avatar
    Avoid warnings and build better queries on CF limits with role rights · a4c8bfa4
    Alex Vandiver authored
    It is possible to create limits on custom fields which you don't have
    global rights on, only role rights (via a queue, for instance).  Due to
    the lack of context object when loading CFs in a search context (as
    there is no clear queue/ticket to use), a simple ->Load returns an
    object which the current user has no rights on.  This causes warnings
    when attempting to inspect properties of the CF to determine how to
    build the query.
    
    As $cf never escapes beyond _LimitCustomField and _CustomFieldJoin, and
    is only used to better be able to build optimal queries, simply load as
    the system user.  This does not impact the results returned, but merely
    allows more optimal queries to be generated.
    
    The other possibility would be to switch to calling ->__Value() for all
    accesses, to skip access control.  However, this is complicated by calls
    to non-column methods such as ->SingleValue; as such, loading as the
    system user was deemed a cleaner solution.
    a4c8bfa4