Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Replicastore often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Replicastore, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 18 | class Replicastore implements Replicastore_Interface { |
||
| 19 | /** |
||
| 20 | * Empty and reset the replicastore. |
||
| 21 | * |
||
| 22 | * @access public |
||
| 23 | */ |
||
| 24 | public function reset() { |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Ran when full sync has just started. |
||
| 54 | * |
||
| 55 | * @access public |
||
| 56 | * |
||
| 57 | * @param array $config Full sync configuration for this sync module. |
||
| 58 | */ |
||
| 59 | public function full_sync_start( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Ran when full sync has just finished. |
||
| 65 | * |
||
| 66 | * @access public |
||
| 67 | * |
||
| 68 | * @param string $checksum Deprecated since 7.3.0. |
||
| 69 | */ |
||
| 70 | public function full_sync_end( $checksum ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Retrieve the number of terms. |
||
| 76 | * |
||
| 77 | * @access public |
||
| 78 | * |
||
| 79 | * @return int Number of terms. |
||
| 80 | */ |
||
| 81 | public function term_count() { |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Retrieve the number of rows in the `term_taxonomy` table. |
||
| 88 | * |
||
| 89 | * @access public |
||
| 90 | * |
||
| 91 | * @return int Number of terms. |
||
| 92 | */ |
||
| 93 | public function term_taxonomy_count() { |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Retrieve the number of term relationships. |
||
| 100 | * |
||
| 101 | * @access public |
||
| 102 | * |
||
| 103 | * @return int Number of rows in the term relationships table. |
||
| 104 | */ |
||
| 105 | public function term_relationship_count() { |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Retrieve the number of posts with a particular post status within a certain range. |
||
| 112 | * |
||
| 113 | * @access public |
||
| 114 | * |
||
| 115 | * @todo Prepare the SQL query before executing it. |
||
| 116 | * |
||
| 117 | * @param string $status Post status. |
||
|
|
|||
| 118 | * @param int $min_id Minimum post ID. |
||
| 119 | * @param int $max_id Maximum post ID. |
||
| 120 | * @return int Number of posts. |
||
| 121 | */ |
||
| 122 | View Code Duplication | public function post_count( $status = null, $min_id = null, $max_id = null ) { |
|
| 144 | |||
| 145 | /** |
||
| 146 | * Retrieve the posts with a particular post status. |
||
| 147 | * |
||
| 148 | * @access public |
||
| 149 | * |
||
| 150 | * @todo Implement range and actually use max_id/min_id arguments. |
||
| 151 | * |
||
| 152 | * @param string $status Post status. |
||
| 153 | * @param int $min_id Minimum post ID. |
||
| 154 | * @param int $max_id Maximum post ID. |
||
| 155 | * @return array Array of posts. |
||
| 156 | */ |
||
| 157 | public function get_posts( $status = null, $min_id = null, $max_id = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Retrieve a post object by the post ID. |
||
| 174 | * |
||
| 175 | * @access public |
||
| 176 | * |
||
| 177 | * @param int $id Post ID. |
||
| 178 | * @return \WP_Post Post object. |
||
| 179 | */ |
||
| 180 | public function get_post( $id ) { |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Update or insert a post. |
||
| 186 | * |
||
| 187 | * @access public |
||
| 188 | * |
||
| 189 | * @param \WP_Post $post Post object. |
||
| 190 | * @param bool $silent Whether to perform a silent action. Not used in this implementation. |
||
| 191 | */ |
||
| 192 | public function upsert_post( $post, $silent = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Delete a post by the post ID. |
||
| 254 | * |
||
| 255 | * @access public |
||
| 256 | * |
||
| 257 | * @param int $post_id Post ID. |
||
| 258 | */ |
||
| 259 | public function delete_post( $post_id ) { |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Retrieve the checksum for posts within a range. |
||
| 265 | * |
||
| 266 | * @access public |
||
| 267 | * |
||
| 268 | * @param int $min_id Minimum post ID. |
||
| 269 | * @param int $max_id Maximum post ID. |
||
| 270 | * @return int The checksum. |
||
| 271 | */ |
||
| 272 | public function posts_checksum( $min_id = null, $max_id = null ) { |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Retrieve the checksum for post meta within a range. |
||
| 278 | * |
||
| 279 | * @access public |
||
| 280 | * |
||
| 281 | * @param int $min_id Minimum post meta ID. |
||
| 282 | * @param int $max_id Maximum post meta ID. |
||
| 283 | * @return int The checksum. |
||
| 284 | */ |
||
| 285 | public function post_meta_checksum( $min_id = null, $max_id = null ) { |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Retrieve the number of comments with a particular comment status within a certain range. |
||
| 291 | * |
||
| 292 | * @access public |
||
| 293 | * |
||
| 294 | * @todo Prepare the SQL query before executing it. |
||
| 295 | * |
||
| 296 | * @param string $status Comment status. |
||
| 297 | * @param int $min_id Minimum comment ID. |
||
| 298 | * @param int $max_id Maximum comment ID. |
||
| 299 | * @return int Number of comments. |
||
| 300 | */ |
||
| 301 | View Code Duplication | public function comment_count( $status = null, $min_id = null, $max_id = null ) { |
|
| 323 | |||
| 324 | /** |
||
| 325 | * Translate a comment status to a value of the comment_approved field. |
||
| 326 | * |
||
| 327 | * @access protected |
||
| 328 | * |
||
| 329 | * @param string $status Comment status. |
||
| 330 | * @return string|bool New comment_approved value, false if the status doesn't affect it. |
||
| 331 | */ |
||
| 332 | protected function comment_status_to_approval_value( $status ) { |
||
| 352 | |||
| 353 | /** |
||
| 354 | * Retrieve the comments with a particular comment status. |
||
| 355 | * |
||
| 356 | * @access public |
||
| 357 | * |
||
| 358 | * @todo Implement range and actually use max_id/min_id arguments. |
||
| 359 | * |
||
| 360 | * @param string $status Comment status. |
||
| 361 | * @param int $min_id Minimum comment ID. |
||
| 362 | * @param int $max_id Maximum comment ID. |
||
| 363 | * @return array Array of comments. |
||
| 364 | */ |
||
| 365 | public function get_comments( $status = null, $min_id = null, $max_id = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 377 | |||
| 378 | /** |
||
| 379 | * Retrieve a comment object by the comment ID. |
||
| 380 | * |
||
| 381 | * @access public |
||
| 382 | * |
||
| 383 | * @param int $id Comment ID. |
||
| 384 | * @return \WP_Comment Comment object. |
||
| 385 | */ |
||
| 386 | public function get_comment( $id ) { |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Update or insert a comment. |
||
| 392 | * |
||
| 393 | * @access public |
||
| 394 | * |
||
| 395 | * @param \WP_Comment $comment Comment object. |
||
| 396 | */ |
||
| 397 | public function upsert_comment( $comment ) { |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Trash a comment by the comment ID. |
||
| 447 | * |
||
| 448 | * @access public |
||
| 449 | * |
||
| 450 | * @param int $comment_id Comment ID. |
||
| 451 | */ |
||
| 452 | public function trash_comment( $comment_id ) { |
||
| 455 | |||
| 456 | /** |
||
| 457 | * Delete a comment by the comment ID. |
||
| 458 | * |
||
| 459 | * @access public |
||
| 460 | * |
||
| 461 | * @param int $comment_id Comment ID. |
||
| 462 | */ |
||
| 463 | public function delete_comment( $comment_id ) { |
||
| 466 | |||
| 467 | /** |
||
| 468 | * Mark a comment by the comment ID as spam. |
||
| 469 | * |
||
| 470 | * @access public |
||
| 471 | * |
||
| 472 | * @param int $comment_id Comment ID. |
||
| 473 | */ |
||
| 474 | public function spam_comment( $comment_id ) { |
||
| 477 | |||
| 478 | /** |
||
| 479 | * Trash the comments of a post. |
||
| 480 | * |
||
| 481 | * @access public |
||
| 482 | * |
||
| 483 | * @param int $post_id Post ID. |
||
| 484 | * @param array $statuses Post statuses. Not used in this implementation. |
||
| 485 | */ |
||
| 486 | public function trashed_post_comments( $post_id, $statuses ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Untrash the comments of a post. |
||
| 492 | * |
||
| 493 | * @access public |
||
| 494 | * |
||
| 495 | * @param int $post_id Post ID. |
||
| 496 | */ |
||
| 497 | public function untrashed_post_comments( $post_id ) { |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Retrieve the checksum for comments within a range. |
||
| 503 | * |
||
| 504 | * @access public |
||
| 505 | * |
||
| 506 | * @param int $min_id Minimum comment ID. |
||
| 507 | * @param int $max_id Maximum comment ID. |
||
| 508 | * @return int The checksum. |
||
| 509 | */ |
||
| 510 | public function comments_checksum( $min_id = null, $max_id = null ) { |
||
| 513 | |||
| 514 | /** |
||
| 515 | * Retrieve the checksum for comment meta within a range. |
||
| 516 | * |
||
| 517 | * @access public |
||
| 518 | * |
||
| 519 | * @param int $min_id Minimum comment meta ID. |
||
| 520 | * @param int $max_id Maximum comment meta ID. |
||
| 521 | * @return int The checksum. |
||
| 522 | */ |
||
| 523 | public function comment_meta_checksum( $min_id = null, $max_id = null ) { |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Update the value of an option. |
||
| 529 | * |
||
| 530 | * @access public |
||
| 531 | * |
||
| 532 | * @param string $option Option name. |
||
| 533 | * @param mixed $value Option value. |
||
| 534 | * @return bool False if value was not updated and true if value was updated. |
||
| 535 | */ |
||
| 536 | public function update_option( $option, $value ) { |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Retrieve an option value based on an option name. |
||
| 542 | * |
||
| 543 | * @access public |
||
| 544 | * |
||
| 545 | * @param string $option Name of option to retrieve. |
||
| 546 | * @param mixed $default Optional. Default value to return if the option does not exist. |
||
| 547 | * @return mixed Value set for the option. |
||
| 548 | */ |
||
| 549 | public function get_option( $option, $default = false ) { |
||
| 552 | |||
| 553 | /** |
||
| 554 | * Remove an option by name. |
||
| 555 | * |
||
| 556 | * @access public |
||
| 557 | * |
||
| 558 | * @param string $option Name of option to remove. |
||
| 559 | * @return bool True, if option is successfully deleted. False on failure. |
||
| 560 | */ |
||
| 561 | public function delete_option( $option ) { |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Change the info of the current theme. |
||
| 567 | * |
||
| 568 | * @access public |
||
| 569 | * |
||
| 570 | * @param array $theme_info Theme info array. |
||
| 571 | */ |
||
| 572 | public function set_theme_info( $theme_info ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 575 | |||
| 576 | /** |
||
| 577 | * Whether the current theme supports a certain feature. |
||
| 578 | * |
||
| 579 | * @access public |
||
| 580 | * |
||
| 581 | * @param string $feature Name of the feature. |
||
| 582 | */ |
||
| 583 | public function current_theme_supports( $feature ) { |
||
| 586 | |||
| 587 | /** |
||
| 588 | * Retrieve metadata for the specified object. |
||
| 589 | * |
||
| 590 | * @access public |
||
| 591 | * |
||
| 592 | * @param string $type Meta type. |
||
| 593 | * @param int $object_id ID of the object. |
||
| 594 | * @param string $meta_key Meta key. |
||
| 595 | * @param bool $single If true, return only the first value of the specified meta_key. |
||
| 596 | * |
||
| 597 | * @return mixed Single metadata value, or array of values. |
||
| 598 | */ |
||
| 599 | public function get_metadata( $type, $object_id, $meta_key = '', $single = false ) { |
||
| 602 | |||
| 603 | /** |
||
| 604 | * Stores remote meta key/values alongside an ID mapping key. |
||
| 605 | * |
||
| 606 | * @access public |
||
| 607 | * |
||
| 608 | * @todo Refactor to not use interpolated values when preparing the SQL query. |
||
| 609 | * |
||
| 610 | * @param string $type Meta type. |
||
| 611 | * @param int $object_id ID of the object. |
||
| 612 | * @param string $meta_key Meta key. |
||
| 613 | * @param mixed $meta_value Meta value. |
||
| 614 | * @param int $meta_id ID of the meta. |
||
| 615 | * |
||
| 616 | * @return bool False if meta table does not exist, true otherwise. |
||
| 617 | */ |
||
| 618 | public function upsert_metadata( $type, $object_id, $meta_key, $meta_value, $meta_id ) { |
||
| 660 | |||
| 661 | /** |
||
| 662 | * Delete metadata for the specified object. |
||
| 663 | * |
||
| 664 | * @access public |
||
| 665 | * |
||
| 666 | * @todo Refactor to not use interpolated values when preparing the SQL query. |
||
| 667 | * |
||
| 668 | * @param string $type Meta type. |
||
| 669 | * @param int $object_id ID of the object. |
||
| 670 | * @param array $meta_ids IDs of the meta objects to delete. |
||
| 671 | */ |
||
| 672 | public function delete_metadata( $type, $object_id, $meta_ids ) { |
||
| 690 | |||
| 691 | /** |
||
| 692 | * Delete metadata with a certain key for the specified objects. |
||
| 693 | * |
||
| 694 | * @access public |
||
| 695 | * |
||
| 696 | * @todo Test this out to make sure it works as expected. |
||
| 697 | * @todo Refactor to not use interpolated values when preparing the SQL query. |
||
| 698 | * |
||
| 699 | * @param string $type Meta type. |
||
| 700 | * @param array $object_ids IDs of the objects. |
||
| 701 | * @param string $meta_key Meta key. |
||
| 702 | */ |
||
| 703 | public function delete_batch_metadata( $type, $object_ids, $meta_key ) { |
||
| 719 | |||
| 720 | /** |
||
| 721 | * Retrieve value of a constant based on the constant name. |
||
| 722 | * |
||
| 723 | * We explicitly return null instead of false if the constant doesn't exist. |
||
| 724 | * |
||
| 725 | * @access public |
||
| 726 | * |
||
| 727 | * @param string $constant Name of constant to retrieve. |
||
| 728 | * @return mixed Value set for the constant. |
||
| 729 | */ |
||
| 730 | public function get_constant( $constant ) { |
||
| 739 | |||
| 740 | /** |
||
| 741 | * Set the value of a constant. |
||
| 742 | * |
||
| 743 | * @access public |
||
| 744 | * |
||
| 745 | * @param string $constant Name of constant to retrieve. |
||
| 746 | * @param mixed $value Value set for the constant. |
||
| 747 | */ |
||
| 748 | public function set_constant( $constant, $value ) { |
||
| 751 | |||
| 752 | /** |
||
| 753 | * Retrieve the number of the available updates of a certain type. |
||
| 754 | * Type is one of: `plugins`, `themes`, `wordpress`, `translations`, `total`, `wp_update_version`. |
||
| 755 | * |
||
| 756 | * @access public |
||
| 757 | * |
||
| 758 | * @param string $type Type of updates to retrieve. |
||
| 759 | * @return int|null Number of updates available, `null` if type is invalid or missing. |
||
| 760 | */ |
||
| 761 | public function get_updates( $type ) { |
||
| 770 | |||
| 771 | /** |
||
| 772 | * Set the available updates of a certain type. |
||
| 773 | * Type is one of: `plugins`, `themes`, `wordpress`, `translations`, `total`, `wp_update_version`. |
||
| 774 | * |
||
| 775 | * @access public |
||
| 776 | * |
||
| 777 | * @param string $type Type of updates to set. |
||
| 778 | * @param int $updates Total number of updates. |
||
| 779 | */ |
||
| 780 | public function set_updates( $type, $updates ) { |
||
| 785 | |||
| 786 | /** |
||
| 787 | * Retrieve a callable value based on its name. |
||
| 788 | * |
||
| 789 | * @access public |
||
| 790 | * |
||
| 791 | * @param string $name Name of the callable to retrieve. |
||
| 792 | * @return mixed Value of the callable. |
||
| 793 | */ |
||
| 794 | public function get_callable( $name ) { |
||
| 803 | |||
| 804 | /** |
||
| 805 | * Update the value of a callable. |
||
| 806 | * |
||
| 807 | * @access public |
||
| 808 | * |
||
| 809 | * @param string $name Callable name. |
||
| 810 | * @param mixed $value Callable value. |
||
| 811 | */ |
||
| 812 | public function set_callable( $name, $value ) { |
||
| 815 | |||
| 816 | /** |
||
| 817 | * Retrieve a network option value based on a network option name. |
||
| 818 | * |
||
| 819 | * @access public |
||
| 820 | * |
||
| 821 | * @param string $option Name of network option to retrieve. |
||
| 822 | * @return mixed Value set for the network option. |
||
| 823 | */ |
||
| 824 | public function get_site_option( $option ) { |
||
| 827 | |||
| 828 | /** |
||
| 829 | * Update the value of a network option. |
||
| 830 | * |
||
| 831 | * @access public |
||
| 832 | * |
||
| 833 | * @param string $option Network option name. |
||
| 834 | * @param mixed $value Network option value. |
||
| 835 | * @return bool False if value was not updated and true if value was updated. |
||
| 836 | */ |
||
| 837 | public function update_site_option( $option, $value ) { |
||
| 840 | |||
| 841 | /** |
||
| 842 | * Remove a network option by name. |
||
| 843 | * |
||
| 844 | * @access public |
||
| 845 | * |
||
| 846 | * @param string $option Name of option to remove. |
||
| 847 | * @return bool True, if option is successfully deleted. False on failure. |
||
| 848 | */ |
||
| 849 | public function delete_site_option( $option ) { |
||
| 852 | |||
| 853 | /** |
||
| 854 | * Retrieve the terms from a particular taxonomy. |
||
| 855 | * |
||
| 856 | * @access public |
||
| 857 | * |
||
| 858 | * @param string $taxonomy Taxonomy slug. |
||
| 859 | * @return array|\WP_Error Array of terms or WP_Error object on failure. |
||
| 860 | */ |
||
| 861 | public function get_terms( $taxonomy ) { |
||
| 868 | |||
| 869 | /** |
||
| 870 | * Retrieve a particular term. |
||
| 871 | * |
||
| 872 | * @access public |
||
| 873 | * |
||
| 874 | * @param string $taxonomy Taxonomy slug. |
||
| 875 | * @param int $term_id ID of the term. |
||
| 876 | * @param string $term_key ID Field `term_id` or `term_taxonomy_id`. |
||
| 877 | * @return \WP_Term|\WP_Error Term object on success, \WP_Error object on failure. |
||
| 878 | */ |
||
| 879 | public function get_term( $taxonomy, $term_id, $term_key = 'term_id' ) { |
||
| 893 | |||
| 894 | /** |
||
| 895 | * Verify a taxonomy is legitimate and register it if necessary. |
||
| 896 | * |
||
| 897 | * @access private |
||
| 898 | * |
||
| 899 | * @param string $taxonomy Taxonomy slug. |
||
| 900 | * @return bool|void|\WP_Error True if already exists; void if it was registered; \WP_Error on error. |
||
| 901 | */ |
||
| 902 | private function ensure_taxonomy( $taxonomy ) { |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Retrieve all terms from a taxonomy that are related to an object with a particular ID. |
||
| 924 | * |
||
| 925 | * @access public |
||
| 926 | * |
||
| 927 | * @param int $object_id Object ID. |
||
| 928 | * @param string $taxonomy Taxonomy slug. |
||
| 929 | * @return array|bool|\WP_Error Array of terms on success, `false` if no terms or post doesn't exist, \WP_Error on failure. |
||
| 930 | */ |
||
| 931 | public function get_the_terms( $object_id, $taxonomy ) { |
||
| 934 | |||
| 935 | /** |
||
| 936 | * Insert or update a term. |
||
| 937 | * |
||
| 938 | * @access public |
||
| 939 | * |
||
| 940 | * @param \WP_Term $term_object Term object. |
||
| 941 | * @return array|bool|\WP_Error Array of term_id and term_taxonomy_id if updated, true if inserted, \WP_Error on failure. |
||
| 942 | */ |
||
| 943 | public function update_term( $term_object ) { |
||
| 976 | |||
| 977 | /** |
||
| 978 | * Delete a term by the term ID and its corresponding taxonomy. |
||
| 979 | * |
||
| 980 | * @access public |
||
| 981 | * |
||
| 982 | * @param int $term_id Term ID. |
||
| 983 | * @param string $taxonomy Taxonomy slug. |
||
| 984 | * @return bool|int|\WP_Error True on success, false if term doesn't exist. Zero if trying with default category. \WP_Error on invalid taxonomy. |
||
| 985 | */ |
||
| 986 | public function delete_term( $term_id, $taxonomy ) { |
||
| 990 | |||
| 991 | /** |
||
| 992 | * Add/update terms of a particular taxonomy of an object with the specified ID. |
||
| 993 | * |
||
| 994 | * @access public |
||
| 995 | * |
||
| 996 | * @param int $object_id The object to relate to. |
||
| 997 | * @param string $taxonomy The context in which to relate the term to the object. |
||
| 998 | * @param string|int|array $terms A single term slug, single term id, or array of either term slugs or ids. |
||
| 999 | * @param bool $append Optional. If false will delete difference of terms. Default false. |
||
| 1000 | */ |
||
| 1001 | public function update_object_terms( $object_id, $taxonomy, $terms, $append ) { |
||
| 1005 | |||
| 1006 | /** |
||
| 1007 | * Remove certain term relationships from the specified object. |
||
| 1008 | * |
||
| 1009 | * @access public |
||
| 1010 | * |
||
| 1011 | * @todo Refactor to not use interpolated values when preparing the SQL query. |
||
| 1012 | * |
||
| 1013 | * @param int $object_id ID of the object. |
||
| 1014 | * @param array $tt_ids Term taxonomy IDs. |
||
| 1015 | * @return bool True on success, false on failure. |
||
| 1016 | */ |
||
| 1017 | public function delete_object_terms( $object_id, $tt_ids ) { |
||
| 1062 | |||
| 1063 | /** |
||
| 1064 | * Retrieve the number of users. |
||
| 1065 | * Not supported in this replicastore. |
||
| 1066 | * |
||
| 1067 | * @access public |
||
| 1068 | */ |
||
| 1069 | public function user_count() { |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * Retrieve a user object by the user ID. |
||
| 1075 | * |
||
| 1076 | * @access public |
||
| 1077 | * |
||
| 1078 | * @param int $user_id User ID. |
||
| 1079 | * @return \WP_User User object. |
||
| 1080 | */ |
||
| 1081 | public function get_user( $user_id ) { |
||
| 1084 | |||
| 1085 | /** |
||
| 1086 | * Insert or update a user. |
||
| 1087 | * Not supported in this replicastore. |
||
| 1088 | * |
||
| 1089 | * @access public |
||
| 1090 | * @throws Exception If this method is invoked. |
||
| 1091 | * |
||
| 1092 | * @param \WP_User $user User object. |
||
| 1093 | */ |
||
| 1094 | public function upsert_user( $user ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * Delete a user. |
||
| 1100 | * Not supported in this replicastore. |
||
| 1101 | * |
||
| 1102 | * @access public |
||
| 1103 | * @throws Exception If this method is invoked. |
||
| 1104 | * |
||
| 1105 | * @param int $user_id User ID. |
||
| 1106 | */ |
||
| 1107 | public function delete_user( $user_id ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 1110 | |||
| 1111 | /** |
||
| 1112 | * Update/insert user locale. |
||
| 1113 | * Not supported in this replicastore. |
||
| 1114 | * |
||
| 1115 | * @access public |
||
| 1116 | * @throws Exception If this method is invoked. |
||
| 1117 | * |
||
| 1118 | * @param int $user_id User ID. |
||
| 1119 | * @param string $local The user locale. |
||
| 1120 | */ |
||
| 1121 | public function upsert_user_locale( $user_id, $local ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 1124 | |||
| 1125 | /** |
||
| 1126 | * Delete user locale. |
||
| 1127 | * Not supported in this replicastore. |
||
| 1128 | * |
||
| 1129 | * @access public |
||
| 1130 | * @throws Exception If this method is invoked. |
||
| 1131 | * |
||
| 1132 | * @param int $user_id User ID. |
||
| 1133 | */ |
||
| 1134 | public function delete_user_locale( $user_id ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * Retrieve the user locale. |
||
| 1140 | * |
||
| 1141 | * @access public |
||
| 1142 | * |
||
| 1143 | * @param int $user_id User ID. |
||
| 1144 | * @return string The user locale. |
||
| 1145 | */ |
||
| 1146 | public function get_user_locale( $user_id ) { |
||
| 1149 | |||
| 1150 | /** |
||
| 1151 | * Retrieve the allowed mime types for the user. |
||
| 1152 | * Not supported in this replicastore. |
||
| 1153 | * |
||
| 1154 | * @access public |
||
| 1155 | * |
||
| 1156 | * @param int $user_id User ID. |
||
| 1157 | */ |
||
| 1158 | public function get_allowed_mime_types( $user_id ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
||
| 1161 | |||
| 1162 | /** |
||
| 1163 | * Retrieve all the checksums we are interested in. |
||
| 1164 | * Currently that is posts, comments, post meta and comment meta. |
||
| 1165 | * |
||
| 1166 | * @access public |
||
| 1167 | * |
||
| 1168 | * @return array Checksums. |
||
| 1169 | */ |
||
| 1170 | public function checksum_all() { |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Return the summarized checksum from buckets or the WP_Error. |
||
| 1192 | * |
||
| 1193 | * @param array $histogram checksum_histogram result. |
||
| 1194 | * |
||
| 1195 | * @return int|WP_Error checksum or Error. |
||
| 1196 | */ |
||
| 1197 | protected function summarize_checksum_histogram( $histogram ) { |
||
| 1204 | |||
| 1205 | /** |
||
| 1206 | * Grabs the minimum and maximum object ids for the given parameters. |
||
| 1207 | * |
||
| 1208 | * @access public |
||
| 1209 | * |
||
| 1210 | * @param string $id_field The id column in the table to query. |
||
| 1211 | * @param string $object_table The table to query. |
||
| 1212 | * @param string $where A sql where clause without 'WHERE'. |
||
| 1213 | * @param int $bucket_size The maximum amount of objects to include in the query. |
||
| 1214 | * For `term_relationships` table, the bucket size will refer to the amount |
||
| 1215 | * of distinct object ids. This will likely include more database rows than |
||
| 1216 | * the bucket size implies. |
||
| 1217 | * |
||
| 1218 | * @return object An object with min_id and max_id properties. |
||
| 1219 | */ |
||
| 1220 | public function get_min_max_object_id( $id_field, $object_table, $where, $bucket_size ) { |
||
| 1239 | |||
| 1240 | /** |
||
| 1241 | * Retrieve the checksum histogram for a specific object type. |
||
| 1242 | * |
||
| 1243 | * @access public |
||
| 1244 | * |
||
| 1245 | * @param string $table Object type. |
||
| 1246 | * @param null $buckets Number of buckets to split the objects to. |
||
| 1247 | * @param null $start_id Minimum object ID. |
||
| 1248 | * @param null $end_id Maximum object ID. |
||
| 1249 | * @param null $columns Table columns to calculate the checksum from. |
||
| 1250 | * @param bool $strip_non_ascii Whether to strip non-ASCII characters. |
||
| 1251 | * @param string $salt Salt, used for $wpdb->prepare()'s args. |
||
| 1252 | * @param bool $only_range_edges Only return the range edges and not the actual checksums. |
||
| 1253 | * @param bool $detailed_drilldown If the call should return a detailed drilldown for the checksum or only the checksum. |
||
| 1254 | * |
||
| 1255 | * @return array|WP_Error The checksum histogram. |
||
| 1256 | * @throws Exception Throws an exception if data validation fails inside `Table_Checksum` calls. |
||
| 1257 | */ |
||
| 1258 | public function checksum_histogram( $table, $buckets = null, $start_id = null, $end_id = null, $columns = null, $strip_non_ascii = true, $salt = '', $only_range_edges = false, $detailed_drilldown = false ) { |
||
| 1322 | |||
| 1323 | /** |
||
| 1324 | * Retrieve the type of the checksum. |
||
| 1325 | * |
||
| 1326 | * @access public |
||
| 1327 | * |
||
| 1328 | * @return string Type of the checksum. |
||
| 1329 | */ |
||
| 1330 | public function get_checksum_type() { |
||
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Used in methods that are not implemented and shouldn't be invoked. |
||
| 1336 | * |
||
| 1337 | * @access private |
||
| 1338 | * @throws Exception If this method is invoked. |
||
| 1339 | */ |
||
| 1340 | private function invalid_call() { |
||
| 1346 | |||
| 1347 | /** |
||
| 1348 | * Determine number of buckets to use in full table checksum. |
||
| 1349 | * |
||
| 1350 | * @param string $table Object Type. |
||
| 1351 | * @param int $start_id Min Object ID. |
||
| 1352 | * @param int $end_id Max Object ID. |
||
| 1353 | * @return int|WP_Error Number of Buckets to use. |
||
| 1354 | */ |
||
| 1355 | private function calculate_buckets( $table, $start_id = null, $end_id = null ) { |
||
| 1380 | } |
||
| 1381 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.