| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Return the strategy used for storing user engagements |
| 18 | 18 | * |
| 19 | - * @since 2.6.0 bbPress (r6722) | |
| 19 | + * @since 2.6.0 bbPress (r6723) | |
| 20 | 20 | * |
| 21 | 21 | * @param string $rel_key The key used to index this relationship |
| 22 | 22 | * @param string $rel_type The type of meta to look in |
| 23 | 23 | * |
| @@ -30,9 +30,9 @@ | ||
| 30 | 30 | /** |
| 31 | 31 | * Base strategy class for interfacing with User Engagements, which other |
| 32 | 32 | * classes will extend. |
| 33 | 33 | * |
| 34 | - * @since 2.6.0 bbPress (r6722) | |
| 34 | + * @since 2.6.0 bbPress (r6739) | |
| 35 | 35 | */ |
| 36 | 36 | class BBP_User_Engagements_Base { |
| 37 | 37 | |
| 38 | 38 | /** |
| @@ -37,9 +37,9 @@ | ||
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Type of strategy being used. |
| 40 | 40 | * |
| 41 | - * @since 2.6.0 bbPress (r6737) | |
| 41 | + * @since 2.6.0 bbPress (r6739) | |
| 42 | 42 | * |
| 43 | 43 | * @var string |
| 44 | 44 | */ |
| 45 | 45 | public $type = ''; |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Add a user id to an object |
| 49 | 49 | * |
| 50 | - * @since 2.6.0 bbPress (r6722) | |
| 50 | + * @since 2.6.0 bbPress (r6739) | |
| 51 | 51 | * |
| 52 | 52 | * @param int $object_id The object id |
| 53 | 53 | * @param int $user_id The user id |
| 54 | 54 | * @param string $meta_key The relationship key |
| @@ -63,9 +63,9 @@ | ||
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Remove a user id from an object |
| 66 | 66 | * |
| 67 | - * @since 2.6.0 bbPress (r6722) | |
| 67 | + * @since 2.6.0 bbPress (r6739) | |
| 68 | 68 | * |
| 69 | 69 | * @param int $object_id The object id |
| 70 | 70 | * @param int $user_id The user id |
| 71 | 71 | * @param string $meta_key The relationship key |
| @@ -79,9 +79,9 @@ | ||
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Remove a user id from all objects |
| 82 | 82 | * |
| 83 | - * @since 2.6.0 bbPress (r6722) | |
| 83 | + * @since 2.6.0 bbPress (r6739) | |
| 84 | 84 | * |
| 85 | 85 | * @param int $user_id The user id |
| 86 | 86 | * @param string $meta_key The relationship key |
| 87 | 87 | * @param string $meta_type The relationship type (usually 'post') |
| @@ -94,9 +94,9 @@ | ||
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * Remove an object from all users |
| 97 | 97 | * |
| 98 | - * @since 2.6.0 bbPress (r6722) | |
| 98 | + * @since 2.6.0 bbPress (r6739) | |
| 99 | 99 | * |
| 100 | 100 | * @param int $object_id The object id |
| 101 | 101 | * @param int $user_id The user id |
| 102 | 102 | * @param string $meta_key The relationship key |
| @@ -110,9 +110,9 @@ | ||
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Remove all users from all objects |
| 113 | 113 | * |
| 114 | - * @since 2.6.0 bbPress (r6722) | |
| 114 | + * @since 2.6.0 bbPress (r6739) | |
| 115 | 115 | * |
| 116 | 116 | * @param string $meta_key The relationship key |
| 117 | 117 | * @param string $meta_type The relationship type (usually 'post') |
| 118 | 118 | * |
| @@ -124,9 +124,9 @@ | ||
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Get users of an object |
| 127 | 127 | * |
| 128 | - * @since 2.6.0 bbPress (r6722) | |
| 128 | + * @since 2.6.0 bbPress (r6739) | |
| 129 | 129 | * |
| 130 | 130 | * @param int $object_id The object id |
| 131 | 131 | * @param string $meta_key The key used to index this relationship |
| 132 | 132 | * @param string $meta_type The type of meta to look in |
| @@ -139,9 +139,9 @@ | ||
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Get the part of the query responsible for JOINing objects to relationships. |
| 142 | 142 | * |
| 143 | - * @since 2.6.0 bbPress (r6737) | |
| 143 | + * @since 2.6.0 bbPress (r6739) | |
| 144 | 144 | * |
| 145 | 145 | * @param array $args |
| 146 | 146 | * @param string $meta_key |
| 147 | 147 | * @param string $meta_type |
| @@ -155,9 +155,9 @@ | ||
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Meta strategy for interfacing with User Engagements |
| 158 | 158 | * |
| 159 | - * @since 2.6.0 bbPress (r6722) | |
| 159 | + * @since 2.6.0 bbPress (r6723) | |
| 160 | 160 | */ |
| 161 | 161 | class BBP_User_Engagements_Meta extends BBP_User_Engagements_Base { |
| 162 | 162 | |
| 163 | 163 | /** |
| @@ -162,9 +162,9 @@ | ||
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * Type of strategy being used. |
| 165 | 165 | * |
| 166 | - * @since 2.6.0 bbPress (r6737) | |
| 166 | + * @since 2.6.0 bbPress (r6739) | |
| 167 | 167 | * |
| 168 | 168 | * @var string |
| 169 | 169 | */ |
| 170 | 170 | public $type = 'meta'; |
| @@ -171,9 +171,9 @@ | ||
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Add a user id to an object |
| 174 | 174 | * |
| 175 | - * @since 2.6.0 bbPress (r6722) | |
| 175 | + * @since 2.6.0 bbPress (r6723) | |
| 176 | 176 | * |
| 177 | 177 | * @param int $object_id The object id |
| 178 | 178 | * @param int $user_id The user id |
| 179 | 179 | * @param string $meta_key The relationship key |
| @@ -188,9 +188,9 @@ | ||
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Remove a user id from an object |
| 191 | 191 | * |
| 192 | - * @since 2.6.0 bbPress (r6722) | |
| 192 | + * @since 2.6.0 bbPress (r6723) | |
| 193 | 193 | * |
| 194 | 194 | * @param int $object_id The object id |
| 195 | 195 | * @param int $user_id The user id |
| 196 | 196 | * @param string $meta_key The relationship key |
| @@ -204,9 +204,9 @@ | ||
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Remove a user id from all objects |
| 207 | 207 | * |
| 208 | - * @since 2.6.0 bbPress (r6722) | |
| 208 | + * @since 2.6.0 bbPress (r6723) | |
| 209 | 209 | * |
| 210 | 210 | * @param int $user_id The user id |
| 211 | 211 | * @param string $meta_key The relationship key |
| 212 | 212 | * @param string $meta_type The relationship type (usually 'post') |
| @@ -219,9 +219,9 @@ | ||
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * Remove an object from all users |
| 222 | 222 | * |
| 223 | - * @since 2.6.0 bbPress (r6722) | |
| 223 | + * @since 2.6.0 bbPress (r6723) | |
| 224 | 224 | * |
| 225 | 225 | * @param int $object_id The object id |
| 226 | 226 | * @param int $user_id The user id |
| 227 | 227 | * @param string $meta_key The relationship key |
| @@ -235,9 +235,9 @@ | ||
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * Remove all users from all objects |
| 238 | 238 | * |
| 239 | - * @since 2.6.0 bbPress (r6722) | |
| 239 | + * @since 2.6.0 bbPress (r6723) | |
| 240 | 240 | * |
| 241 | 241 | * @param string $meta_key The relationship key |
| 242 | 242 | * @param string $meta_type The relationship type (usually 'post') |
| 243 | 243 | * |
| @@ -249,9 +249,9 @@ | ||
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * Get users of an object |
| 252 | 252 | * |
| 253 | - * @since 2.6.0 bbPress (r6722) | |
| 253 | + * @since 2.6.0 bbPress (r6723) | |
| 254 | 254 | * |
| 255 | 255 | * @param int $object_id The object id |
| 256 | 256 | * @param string $meta_key The key used to index this relationship |
| 257 | 257 | * @param string $meta_type The type of meta to look in |
| @@ -264,9 +264,9 @@ | ||
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Get the part of the query responsible for JOINing objects to relationships. |
| 267 | 267 | * |
| 268 | - * @since 2.6.0 bbPress (r6737) | |
| 268 | + * @since 2.6.0 bbPress (r6739) | |
| 269 | 269 | * |
| 270 | 270 | * @param array $args |
| 271 | 271 | * @param string $meta_key |
| 272 | 272 | * @param string $meta_type |
| @@ -306,9 +306,9 @@ | ||
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | 308 | * Term strategy for interfacing with User Engagements |
| 309 | 309 | * |
| 310 | - * @since 2.6.0 bbPress (r6737) | |
| 310 | + * @since 2.6.0 bbPress (r6739) | |
| 311 | 311 | */ |
| 312 | 312 | class BBP_User_Engagements_Term extends BBP_User_Engagements_Base { |
| 313 | 313 | |
| 314 | 314 | /** |
| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | |
| 314 | 314 | /** |
| 315 | 315 | * Type of strategy being used. |
| 316 | 316 | * |
| 317 | - * @since 2.6.0 bbPress (r6737) | |
| 317 | + * @since 2.6.0 bbPress (r6739) | |
| 318 | 318 | * |
| 319 | 319 | * @var string |
| 320 | 320 | */ |
| 321 | 321 | public $type = 'term'; |
| @@ -322,9 +322,9 @@ | ||
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | 324 | * Register an engagement taxonomy just-in-time for immediate use |
| 325 | 325 | * |
| 326 | - * @since 2.6.0 bbPress (r6737) | |
| 326 | + * @since 2.6.0 bbPress (r6739) | |
| 327 | 327 | * |
| 328 | 328 | * @param string $tax_key |
| 329 | 329 | * @param string $object_type |
| 330 | 330 | */ |
| @@ -366,9 +366,9 @@ | ||
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * Add a user id to an object |
| 369 | 369 | * |
| 370 | - * @since 2.6.0 bbPress (r6737) | |
| 370 | + * @since 2.6.0 bbPress (r6739) | |
| 371 | 371 | * |
| 372 | 372 | * @param int $object_id The object id |
| 373 | 373 | * @param int $user_id The user id |
| 374 | 374 | * @param string $meta_key The relationship key |
| @@ -387,9 +387,9 @@ | ||
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | 389 | * Remove a user id from an object |
| 390 | 390 | * |
| 391 | - * @since 2.6.0 bbPress (r6737) | |
| 391 | + * @since 2.6.0 bbPress (r6739) | |
| 392 | 392 | * |
| 393 | 393 | * @param int $object_id The object id |
| 394 | 394 | * @param int $user_id The user id |
| 395 | 395 | * @param string $meta_key The relationship key |
| @@ -407,9 +407,9 @@ | ||
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * Remove a user id from all objects |
| 410 | 410 | * |
| 411 | - * @since 2.6.0 bbPress (r6737) | |
| 411 | + * @since 2.6.0 bbPress (r6739) | |
| 412 | 412 | * |
| 413 | 413 | * @param int $user_id The user id |
| 414 | 414 | * @param string $meta_key The relationship key |
| 415 | 415 | * @param string $meta_type The relationship type (usually 'post') |
| @@ -427,10 +427,10 @@ | ||
| 427 | 427 | |
| 428 | 428 | /** |
| 429 | 429 | * Remove an object from all users |
| 430 | 430 | * |
| 431 | - * @since 2.6.0 bbPress (r6737) | |
| 432 | - * @since 2.6.17 Limit removal to the requested relationship taxonomy. | |
| 431 | + * @since 2.6.0 bbPress (r6739) | |
| 432 | + * @since 2.6.17 bbPress (r7468) Limit removal to the requested relationship taxonomy. | |
| 433 | 433 | * |
| 434 | 434 | * @param int $object_id The object id |
| 435 | 435 | * @param int $user_id The user id |
| 436 | 436 | * @param string $meta_key The relationship key |
| @@ -447,9 +447,9 @@ | ||
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | 449 | * Remove all users from all objects |
| 450 | 450 | * |
| 451 | - * @since 2.6.0 bbPress (r6737) | |
| 451 | + * @since 2.6.0 bbPress (r6739) | |
| 452 | 452 | * |
| 453 | 453 | * @param string $meta_key The relationship key |
| 454 | 454 | * @param string $meta_type The relationship type (usually 'post') |
| 455 | 455 | * |
| @@ -461,9 +461,9 @@ | ||
| 461 | 461 | |
| 462 | 462 | /** |
| 463 | 463 | * Get users of an object |
| 464 | 464 | * |
| 465 | - * @since 2.6.0 bbPress (r6737) | |
| 465 | + * @since 2.6.0 bbPress (r6739) | |
| 466 | 466 | * |
| 467 | 467 | * @param int $object_id The object id |
| 468 | 468 | * @param string $meta_key The key used to index this relationship |
| 469 | 469 | * @param string $meta_type The type of meta to look in |
| @@ -497,9 +497,9 @@ | ||
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | 499 | * Get the part of the query responsible for JOINing objects to relationships. |
| 500 | 500 | * |
| 501 | - * @since 2.6.0 bbPress (r6737) | |
| 501 | + * @since 2.6.0 bbPress (r6739) | |
| 502 | 502 | * |
| 503 | 503 | * @param array $args |
| 504 | 504 | * @param string $meta_key |
| 505 | 505 | * @param string $meta_type |
| @@ -551,9 +551,9 @@ | ||
| 551 | 551 | * Note: this strategy is going to be a bit less tidy than the others, because |
| 552 | 552 | * it needs to do weird things to maintain the 2.5 status-quo. Do not use this |
| 553 | 553 | * strategy as an example when building your own. |
| 554 | 554 | * |
| 555 | - * @since 2.6.0 bbPress (r6844) | |
| 555 | + * @since 2.6.0 bbPress (r6876) | |
| 556 | 556 | */ |
| 557 | 557 | class BBP_User_Engagements_User extends BBP_User_Engagements_Base { |
| 558 | 558 | |
| 559 | 559 | /** |
| @@ -558,9 +558,9 @@ | ||
| 558 | 558 | |
| 559 | 559 | /** |
| 560 | 560 | * Type of strategy being used. |
| 561 | 561 | * |
| 562 | - * @since 2.6.0 bbPress (r6844) | |
| 562 | + * @since 2.6.0 bbPress (r6876) | |
| 563 | 563 | * |
| 564 | 564 | * @var string |
| 565 | 565 | */ |
| 566 | 566 | public $type = 'user'; |
| @@ -567,9 +567,9 @@ | ||
| 567 | 567 | |
| 568 | 568 | /** |
| 569 | 569 | * Private function to map 2.6 meta keys to 2.5 user-option keys. |
| 570 | 570 | * |
| 571 | - * @since 2.6.0 bbPress (r6844) | |
| 571 | + * @since 2.6.0 bbPress (r6876) | |
| 572 | 572 | * |
| 573 | 573 | * @param string $meta_key |
| 574 | 574 | * @param int $object_id |
| 575 | 575 | * @param bool $prefix |
| @@ -619,9 +619,9 @@ | ||
| 619 | 619 | * |
| 620 | 620 | * This method exists to provide backwards compatibility with bbPress 2.5, |
| 621 | 621 | * which had caching surrounding the FIND_IN_SET usermeta queries. |
| 622 | 622 | * |
| 623 | - * @since 2.6.3 bbPress (r6991) | |
| 623 | + * @since 2.6.3 bbPress (r6992) | |
| 624 | 624 | * |
| 625 | 625 | * @param string $meta_key |
| 626 | 626 | * @param int $object_id |
| 627 | 627 | * |
| @@ -670,9 +670,9 @@ | ||
| 670 | 670 | * |
| 671 | 671 | * This method exists to provide backwards compatibility with bbPress 2.5, |
| 672 | 672 | * which had caching surrounding the FIND_IN_SET queries in usermeta. |
| 673 | 673 | * |
| 674 | - * @since 2.6.3 bbPress (r6991) | |
| 674 | + * @since 2.6.3 bbPress (r6992) | |
| 675 | 675 | * |
| 676 | 676 | * @param string $meta_key |
| 677 | 677 | * @param int $object_id |
| 678 | 678 | * |
| @@ -689,9 +689,9 @@ | ||
| 689 | 689 | * |
| 690 | 690 | * This method exists to provide backwards compatibility with bbPress 2.5, |
| 691 | 691 | * which had caching surrounding the FIND_IN_SET queries in usermeta. |
| 692 | 692 | * |
| 693 | - * @since 2.6.3 bbPress (r6991) | |
| 693 | + * @since 2.6.3 bbPress (r6992) | |
| 694 | 694 | * |
| 695 | 695 | * @param string $meta_key |
| 696 | 696 | * @param int $object_id |
| 697 | 697 | * |
| @@ -709,9 +709,9 @@ | ||
| 709 | 709 | * |
| 710 | 710 | * This method exists to provide backwards compatibility with bbPress 2.5, |
| 711 | 711 | * which had caching surrounding the FIND_IN_SET queries in usermeta. |
| 712 | 712 | * |
| 713 | - * @since 2.6.3 bbPress (r6991) | |
| 713 | + * @since 2.6.3 bbPress (r6992) | |
| 714 | 714 | * |
| 715 | 715 | * @param string $meta_key |
| 716 | 716 | * @param int $object_id |
| 717 | 717 | * |
| @@ -725,9 +725,9 @@ | ||
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | 727 | * Turn a comma-separated string into an array of integers |
| 728 | 728 | * |
| 729 | - * @since 2.6.0 bbPress (r6844) | |
| 729 | + * @since 2.6.0 bbPress (r6876) | |
| 730 | 730 | * |
| 731 | 731 | * @param string $results |
| 732 | 732 | * @return array |
| 733 | 733 | */ |
| @@ -892,9 +892,9 @@ | ||
| 892 | 892 | |
| 893 | 893 | // Query for users |
| 894 | 894 | $option_key = $this->get_user_option_key( $meta_key, 0, true ); |
| 895 | 895 | $bbp_db = bbp_db(); |
| 896 | - $user_ids = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$option_key}'" ); | |
| 896 | + $user_ids = $bbp_db->get_col( $bbp_db->prepare( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = %s", $option_key ) ); | |
| 897 | 897 | $u_count = count( $user_ids ); |
| 898 | 898 | |
| 899 | 899 | // Count number of removals |
| 900 | 900 | $removed = array(); |
| @@ -938,9 +938,9 @@ | ||
| 938 | 938 | // Cache is empty, so hit the database |
| 939 | 939 | if ( false === $user_ids ) { |
| 940 | 940 | $option_key = $this->get_user_option_key( $meta_key, $object_id, true ); |
| 941 | 941 | $bbp_db = bbp_db(); |
| 942 | - $user_ids = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$option_key}' and FIND_IN_SET('{$object_id}', meta_value) > 0" ); | |
| 942 | + $user_ids = $bbp_db->get_col( $bbp_db->prepare( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = %s AND FIND_IN_SET( %d, meta_value ) > 0", $option_key, $object_id ) ); | |
| 943 | 943 | |
| 944 | 944 | // Always cache results (even if empty, to prevent multiple misses) |
| 945 | 945 | $this->cache_set( $meta_key, $object_id, $user_ids ); |
| 946 | 946 | } |