Code Duplication    Length = 15-16 lines in 3 locations

packages/sync/src/modules/class-terms.php 1 location

@@ 173-187 (lines=15) @@
170
	 * @param array $config Full sync configuration for this sync module.
171
	 * @return int Number of items yet to be enqueued.
172
	 */
173
	public function estimate_full_sync_actions( $config ) {
174
		global $wpdb;
175
176
		$query = "SELECT count(*) FROM $wpdb->term_taxonomy";
177
178
		$where_sql = $this->get_where_sql( $config );
179
		if ( $where_sql ) {
180
			$query .= ' WHERE ' . $where_sql;
181
		}
182
183
		// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
184
		$count = $wpdb->get_var( $query );
185
186
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
187
	}
188
189
	/**
190
	 * Retrieve the actions that will be sent for this module during a full sync.

packages/sync/src/modules/class-users.php 1 location

@@ 641-655 (lines=15) @@
638
	 * @param array $config Full sync configuration for this sync module.
639
	 * @return array Number of items yet to be enqueued.
640
	 */
641
	public function estimate_full_sync_actions( $config ) {
642
		global $wpdb;
643
644
		$query = "SELECT count(*) FROM $wpdb->usermeta";
645
646
		$where_sql = $this->get_where_sql( $config );
647
		if ( $where_sql ) {
648
			$query .= ' WHERE ' . $where_sql;
649
		}
650
651
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
652
		$count = $wpdb->get_var( $query );
653
654
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
655
	}
656
657
	/**
658
	 * Retrieve the WHERE SQL clause based on the module config.

packages/sync/src/modules/class-comments.php 1 location

@@ 320-335 (lines=16) @@
317
	 * @param array $config Full sync configuration for this sync module.
318
	 * @return int Number of items yet to be enqueued.
319
	 */
320
	public function estimate_full_sync_actions( $config ) {
321
		global $wpdb;
322
323
		$query = "SELECT count(*) FROM $wpdb->comments";
324
325
		$where_sql = $this->get_where_sql( $config );
326
		if ( $where_sql ) {
327
			$query .= ' WHERE ' . $where_sql;
328
		}
329
330
		// TODO: Call $wpdb->prepare on the following query.
331
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
332
		$count = $wpdb->get_var( $query );
333
334
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
335
	}
336
337
	/**
338
	 * Retrieve the WHERE SQL clause based on the module config.