@@ -74,24 +74,30 @@ public static function call(OkapiRequest $request)
74
74
array ('caches.wp_oc is not null ' ),
75
75
$ search_params ['where_conds ' ]
76
76
);
77
+
78
+ if (isset ($ search_params ['extra_joins ' ]) && is_array ($ search_params ['extra_joins ' ]))
79
+ $ joins = $ search_params ['extra_joins ' ];
80
+ else
81
+ $ joins = array ();
82
+
77
83
unset($ search_params );
78
84
79
85
# Generate, or retrieve an existing set, and return the result.
80
86
# All user-supplied data in $tables and $where_conds MUST be escaped!
81
87
82
- $ result = self ::get_set ($ tables , $ where_conds , $ min_store , $ ref_max_age );
88
+ $ result = self ::get_set ($ tables , $ joins , $ where_conds , $ min_store , $ ref_max_age );
83
89
return Okapi::formatted_response ($ request , $ result );
84
90
}
85
91
86
92
/**
87
93
* Important: YOU HAVE TO make sure $tables and $where_conds don't contain
88
94
* unescaped user-supplied data!
89
95
*/
90
- public static function get_set ($ tables , $ where_conds , $ min_store , $ ref_max_age )
96
+ public static function get_set ($ tables , $ joins , $ where_conds , $ min_store , $ ref_max_age )
91
97
{
92
98
# Compute the "params hash".
93
99
94
- $ params_hash = md5 (serialize (array ($ tables , $ where_conds )));
100
+ $ params_hash = md5 (serialize (array ($ tables , $ joins , $ where_conds )));
95
101
96
102
# Check if there exists an entry for this hash, which also meets the
97
103
# given freshness criteria.
@@ -133,7 +139,9 @@ public static function get_set($tables, $where_conds, $min_store, $ref_max_age)
133
139
select distinct
134
140
' " .mysql_real_escape_string ($ set_id )."',
135
141
caches.cache_id
136
- from " .implode (", " , $ tables )."
142
+ from
143
+ " .implode (", " , $ tables )."
144
+ " .implode (" " , $ joins )."
137
145
where ( " .implode (") and ( " , $ where_conds ).")
138
146
" );
139
147
0 commit comments