| @@ -13,9 +13,9 @@ | ||
| 13 | 13 | * This is a trick to force derived classes to define a transient themselves. |
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - const UNINDEXED_COUNT_TRANSIENT = null; | |
| 17 | + public const UNINDEXED_COUNT_TRANSIENT = null; | |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The transient cache key for limited counts. |
| 21 | 21 | * |
| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | * The transient cache key for limited counts. |
| 21 | 21 | * |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - const UNINDEXED_LIMITED_COUNT_TRANSIENT = self::UNINDEXED_COUNT_TRANSIENT . '_limited'; | |
| 24 | + public const UNINDEXED_LIMITED_COUNT_TRANSIENT = self::UNINDEXED_COUNT_TRANSIENT . '_limited'; | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Builds a query for selecting the ID's of unindexed posts. |
| 28 | 28 | * |
| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | |
| 57 | 57 | $query = $this->get_select_query( $limit ); |
| 58 | 58 | |
| 59 | 59 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Function get_count_query returns a prepared query. |
| 60 | - $unindexed_object_ids = $this->wpdb->get_col( $query ); | |
| 60 | + $unindexed_object_ids = ( $query === '' ) ? [] : $this->wpdb->get_col( $query ); | |
| 61 | 61 | $count = (int) \count( $unindexed_object_ids ); |
| 62 | 62 | |
| 63 | 63 | \set_transient( static::UNINDEXED_LIMITED_COUNT_TRANSIENT, $count, ( \MINUTE_IN_SECONDS * 15 ) ); |
| 64 | 64 | |
| @@ -82,15 +82,22 @@ | ||
| 82 | 82 | |
| 83 | 83 | $query = $this->get_count_query(); |
| 84 | 84 | |
| 85 | 85 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Function get_count_query returns a prepared query. |
| 86 | - $count = $this->wpdb->get_var( $query ); | |
| 86 | + $count = ( $query === '' ) ? 0 : $this->wpdb->get_var( $query ); | |
| 87 | 87 | |
| 88 | - if ( \is_null( $count ) ) { | |
| 88 | + if ( $count === null ) { | |
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | \set_transient( static::UNINDEXED_COUNT_TRANSIENT, $count, \DAY_IN_SECONDS ); |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Action: 'wpseo_indexables_unindexed_calculated' - sets an option to timestamp when there are no unindexed indexables left. | |
| 96 | + * | |
| 97 | + * @internal | |
| 98 | + */ | |
| 99 | + \do_action( 'wpseo_indexables_unindexed_calculated', static::UNINDEXED_COUNT_TRANSIENT, $count ); | |
| 93 | 100 | |
| 94 | 101 | return (int) $count; |
| 95 | 102 | } |
| 96 | 103 | } |