@@ -5,14 +5,15 @@ class BEA_CSF_Relations {
55 const BEA_CSF_RELATIONS_CACHE_GROUP = 'relations-cache-group ' ;
66
77 /**
8- * @return int|mixed
9- *
108 * @param $emitter_blog_id
119 * @param $emitter_id
1210 * @param $receiver_blog_id
1311 * @param $receiver_id
1412 *
1513 * @param $type
14+ *
15+ * @return int|mixed
16+ *
1617 */
1718 public static function merge ( $ type , $ emitter_blog_id , $ emitter_id , $ receiver_blog_id , $ receiver_id , $ strict_mode = false ) {
1819 // Test with right emitter/receiver direction
@@ -33,14 +34,15 @@ public static function merge( $type, $emitter_blog_id, $emitter_id, $receiver_bl
3334 }
3435
3536 /**
36- * @return int
37- *
3837 * @param $emitter_blog_id
3938 * @param $emitter_id
4039 * @param $receiver_blog_id
4140 * @param $receiver_id
4241 *
4342 * @param $type
43+ *
44+ * @return int
45+ *
4446 */
4547 public static function insert ( $ type , $ emitter_blog_id , $ emitter_id , $ receiver_blog_id , $ receiver_id ) {
4648 global $ wpdb ;
@@ -64,10 +66,10 @@ public static function insert( $type, $emitter_blog_id, $emitter_id, $receiver_b
6466 /**
6567 * Delete a row with this primary ID.
6668 *
67- * @return mixed
68- *
6969 * @param $id
7070 *
71+ * @return mixed
72+ *
7173 */
7274 public static function delete ( $ id ) {
7375 global $ wpdb ;
@@ -90,12 +92,13 @@ public static function delete( $id ) {
9092 /**
9193 * Delete relation for an object_id for emitter and receiver context
9294 *
93- * @return true
94- *
9595 * @param integer $blog_id
9696 * @param integer $object_id
9797 *
9898 * @param string $type
99+ *
100+ * @return true
101+ *
99102 */
100103 public static function delete_by_object_id ( $ type , $ blog_id , $ object_id ) {
101104 self ::delete_by_emitter ( $ type , $ blog_id , $ object_id );
@@ -107,10 +110,10 @@ public static function delete_by_object_id( $type, $blog_id, $object_id ) {
107110 /**
108111 * Delete data relation for a blog
109112 *
110- * @return true
111- *
112113 * @param integer $blog_id
113114 *
115+ * @return true
116+ *
114117 */
115118 public static function delete_by_blog_id ( $ blog_id ) {
116119 global $ wpdb ;
@@ -157,12 +160,13 @@ public static function delete_by_blog_id( $blog_id ) {
157160 }
158161
159162 /**
160- * @return false|int
161- *
162163 * @param $emitter_blog_id
163164 * @param $emitter_id
164165 *
165166 * @param $type
167+ *
168+ * @return false|int
169+ *
166170 */
167171 public static function delete_by_emitter ( $ type , $ emitter_blog_id , $ emitter_id ) {
168172 global $ wpdb ;
@@ -196,12 +200,13 @@ public static function delete_by_emitter( $type, $emitter_blog_id, $emitter_id )
196200 }
197201
198202 /**
199- * @return false|int
200- *
201203 * @param $receiver_blog_id
202204 * @param $receiver_id
203205 *
204206 * @param $type
207+ *
208+ * @return false|int
209+ *
205210 */
206211 public static function delete_by_receiver ( $ type , $ receiver_blog_id , $ receiver_id ) {
207212 global $ wpdb ;
@@ -235,14 +240,15 @@ public static function delete_by_receiver( $type, $receiver_blog_id, $receiver_i
235240 }
236241
237242 /**
238- * @return false|int
239- *
240243 * @param $emitter_blog_id
241244 * @param $emitter_id
242245 * @param $receiver_blog_id
243246 * @param $receiver_id
244247 *
245248 * @param $type
249+ *
250+ * @return false|int
251+ *
246252 */
247253 public static function delete_by_emitter_and_receiver ( $ type , $ emitter_blog_id , $ emitter_id , $ receiver_blog_id , $ receiver_id ) {
248254 global $ wpdb ;
@@ -280,10 +286,10 @@ public static function delete_by_emitter_and_receiver( $type, $emitter_blog_id,
280286 }
281287
282288 /**
283- * @return mixed
284- *
285289 * @param $id
286290 *
291+ * @return mixed
292+ *
287293 */
288294 public static function get ( $ id ) {
289295 global $ wpdb ;
@@ -294,15 +300,15 @@ public static function get( $id ) {
294300 }
295301
296302 /**
297- * @return integer|false
298- *
299303 * @param int $emitter_blog_id
300304 * @param int $receiver_blog_id
301305 * @param int $emitter_id
302306 * @param int $receiver_id
303307 *
304308 * @param string|array $type
305309 *
310+ * @return integer|false
311+ *
306312 * @author Alexandre Sadowski
307313 */
308314 public static function get_object_for_any ( $ type , $ emitter_blog_id , $ receiver_blog_id , $ emitter_id , $ receiver_id , $ direct = false ) {
@@ -342,11 +348,12 @@ public static function get_object_for_any( $type, $emitter_blog_id, $receiver_bl
342348 /**
343349 * Get all hierachy of relation for a content
344350 *
345- * @return array
346- *
347351 * @param $emitter_blog_id
348352 * @param $emitter_id
349353 * @param $type
354+ *
355+ * @return array
356+ *
350357 */
351358 public static function get_relations_hierarchy ( $ type , $ emitter_blog_id , $ emitter_id ) {
352359 $ hierarchy = [];
@@ -370,14 +377,14 @@ public static function get_relations_hierarchy( $type, $emitter_blog_id, $emitte
370377 }
371378
372379 /**
373- * @return int
374- *
375380 * @param int $emitter_blog_id
376381 * @param int $receiver_blog_id
377382 * @param int $emitter_id
378383 *
379384 * @param string|array $types
380385 *
386+ * @return int
387+ *
381388 * @author Alexandre Sadowski
382389 */
383390 public static function get_object_id_for_receiver ( $ types , $ emitter_blog_id , $ receiver_blog_id , $ emitter_id ) {
@@ -395,14 +402,14 @@ public static function get_object_id_for_receiver( $types, $emitter_blog_id, $re
395402 }
396403
397404 /**
398- * @return int
399- *
400405 * @param int $emitter_blog_id
401406 * @param int $receiver_blog_id
402407 * @param int $receiver_id
403408 *
404409 * @param string|array $types
405410 *
411+ * @return int
412+ *
406413 * @author Alexandre Sadowski
407414 */
408415 public static function get_object_id_for_emitter ( $ types , $ emitter_blog_id , $ receiver_blog_id , $ receiver_id ) {
@@ -420,18 +427,18 @@ public static function get_object_id_for_emitter( $types, $emitter_blog_id, $rec
420427 }
421428
422429 /**
423- * @return mixed
424- *
425430 * @param int $receiver_blog_id
426431 * @param int $receiver_id
427432 *
428433 * @param string|array $types
429434 *
435+ * @return mixed
436+ *
430437 * @author Alexandre Sadowski
431438 */
432439 public static function current_object_is_synchronized ( $ types , $ receiver_blog_id , $ receiver_id ) {
433440 global $ wpdb ;
434- $ cache_id = self ::get_cache_id ( $ types , $ receiver_blog_id , $ receiver_id );
441+ $ cache_id = self ::get_cache_id ( $ types , ( int ) $ receiver_blog_id , ( int ) $ receiver_id );
435442 $ relation = wp_cache_get ( $ cache_id , self ::BEA_CSF_RELATIONS_CACHE_GROUP , false , $ found );
436443 if ( $ found ) {
437444 return $ relation ;
@@ -448,6 +455,7 @@ public static function current_object_is_synchronized( $types, $receiver_blog_id
448455 if ( null !== $ result ) {
449456 wp_cache_set ( $ cache_id , $ result , self ::BEA_CSF_RELATIONS_CACHE_GROUP );
450457 }
458+
451459 return $ result ;
452460 }
453461
@@ -512,10 +520,10 @@ public static function get_results_by_receiver_blog_id( $blog_id ) {
512520 }
513521
514522 /**
515- * @return mixed
516- *
517523 * @param int $quantity
518524 *
525+ * @return mixed
526+ *
519527 */
520528 public static function get_results ( $ quantity = 100 ) {
521529 global $ wpdb ;
@@ -530,13 +538,14 @@ public static function get_results( $quantity = 100 ) {
530538 *
531539 * @param int $blog_id
532540 * @param array $types_relation
541+ *
542+ * @return mixed
533543 * @example [
534544 * 'taxonomy',
535545 * 'attachment',
536546 * 'posttype',
537547 * ]
538548 *
539- * @return mixed
540549 */
541550 public static function get_types_relation_by_receiver_blog_id ( int $ blog_id , array $ types_relation = [] ) {
542551 if ( empty ( $ types_relation ) ) {
@@ -580,24 +589,27 @@ function ( $v ) {
580589 * @param string|array $types
581590 * @param int $receiver_blog_id
582591 * @param int $receiver_id
592+ *
583593 * @return string
584594 */
585595 private static function get_cache_id ( $ types , int $ receiver_blog_id , int $ receiver_id ): string {
586596 $ type = 'post ' ;
587597 if ( 'taxonomy ' === $ types || ( is_array ( $ types ) && in_array ( 'taxonomy ' , $ types , true ) ) ) {
588598 $ type = 'taxonomy ' ;
589599 }
600+
590601 return $ receiver_blog_id . '- ' . $ receiver_id . '- ' . $ type ;
591602 }
592603
593604 /**
594605 * Delete all relation caches matching query results
595606 *
596607 * @param stdClass $relation
608+ *
597609 * @return void
598610 */
599611 public static function delete_relation_cache ( stdClass $ relation ) {
600- $ cache_id = self ::get_cache_id ( $ relation ->type , $ relation ->receiver_blog_id , $ relation ->receiver_id );
612+ $ cache_id = self ::get_cache_id ( $ relation ->type , ( int ) $ relation ->receiver_blog_id , ( int ) $ relation ->receiver_id );
601613 wp_cache_delete ( $ cache_id , self ::BEA_CSF_RELATIONS_CACHE_GROUP );
602614
603615 }
0 commit comments