DatabaseQueue::numberOfItems returns the result of a database query to count the number of rows in the the queue table.

The query returns a string. The method should cast to an int before returning.

(The method name numberOfItems suggests that an int will be returned.)

Comments

gwagroves created an issue. See original summary.

gwagroves’s picture

StatusFileSize
new1.24 KB
darrenwh’s picture

Status: Active » Needs review

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

This is a good idea, but the patch no longer applies, so this needs a reroll.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.23 KB

Re-rolled.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

I don't think we need a specific test for this.

alexpott’s picture

Given that the catch does

      // If there is no table there cannot be any items.
      return 0;

Yeah why not. Maybe once we're PHP7 only then we can use return type coercion.

Also the MemoryQueue implementation does

  /**
   * {@inheritdoc}
   */
  public function numberOfItems() {
    return count($this->queue);
  }

So that's already compliant.

alexpott’s picture

Category: Bug report » Task
StatusFileSize
new1.15 KB
new2.52 KB

Think we should have a test though and also imo this is just a task.

borisson_’s picture

Oh, that testchange is very elegant. Great job @alexpott, just reconfirming my earlier rtbc for the new patch.

alexpott’s picture

Committed bb5c5a3 and pushed to 8.6.x. Thanks!

  • alexpott committed bb5c5a3 on 8.6.x
    Issue #2835989 by gwagroves, Jo Fitzgerald, alexpott: DatabaseQueue::...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.