From 5dff6311f57bebf391647b3f3d1a67ffe01c5e75 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 9 Apr 2012 11:27:53 -0400 Subject: [PATCH] Avoid too-strict controller checks when fleshing for cstore, reporter-store Move controller-verificiation from the beginning of recursive doFieldmapperSearch() to nearer the end, right before we recurse, so we only check the child class's controller if we're pcrud. If we're not pcrud, code that calls doFieldmapperSearch() from the outside will have already done appropriate testing of the controller. Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Thomas Berezansky --- Open-ILS/src/c-apps/oils_sql.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index 24795b0ed0..902a4e04c2 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -5585,27 +5585,10 @@ static jsonObject* doFieldmapperSearch( osrfMethodContext* ctx, osrfHash* class_ char *methodtype = osrfHashGet( (osrfHash *) ctx->method->userData, "methodtype" ); char *inside_verify = osrfHashGet( (osrfHash*) ctx->session->userData, "inside_verify" ); int need_to_verify = (inside_verify ? !atoi(inside_verify) : 1); - int has_controller = osrfStringArrayContains(osrfHashGet(class_meta, "controller"), modulename); int i_respond_directly = 0; int flesh_depth = 0; - // XXX This can be redundant with another instance of the same test that happens - // within the functions that call doFieldmapperSearch(), but we have it here to - // prevent any non-pcrud-controlled classes from being fleshed on. - // - // TODO To avoid redundancy, move this block to right before we recurse, - // and change the class we're checking to the one we're /about/ to search for, - // not the one we're currently searching for. - if ( - (!has_controller && !enforce_pcrud) // cstore client-level case: we require the controller, period - || (!has_controller && enforce_pcrud && need_to_verify) // pcrud case: we require the controller in need_to_verify mode - ) { - osrfLogInfo(OSRF_LOG_MARK, "%s is not listed as a controller for %s, moving on", - modulename, core_class); - return jsonNewObjectType( JSON_ARRAY ); /* empty */ - } - char* sql = buildSELECT( where_hash, query_hash, class_meta, ctx ); if( !sql ) { osrfLogDebug( OSRF_LOG_MARK, "Problem building query, returning NULL" ); @@ -5782,6 +5765,21 @@ static jsonObject* doFieldmapperSearch( osrfMethodContext* ctx, osrfHash* class_ fields, osrfHashGet( class_meta, "primarykey" ) ); } + int kid_has_controller = osrfStringArrayContains( osrfHashGet(kid_idl, "controller"), modulename ); + // fleshing pcrud case: we require the controller in need_to_verify mode + if ( !kid_has_controller && enforce_pcrud && need_to_verify ) { + osrfLogInfo( OSRF_LOG_MARK, "%s is not listed as a controller for %s; moving on", modulename, core_class ); + + jsonObjectSetIndex( + cur, + (unsigned long) atoi( osrfHashGet(field, "array_position") ), + jsonNewObjectType( + !strcmp( reltype, "has_many" ) ? JSON_ARRAY : JSON_NULL + ) + ); + continue; + } + osrfStringArray* link_map = osrfHashGet( kid_link, "map" ); if( link_map->size > 0 ) { -- 2.11.0