CRM_Queue_Queue - Add 'getStatistic($name)'. Deprecate 'numberOfItems()'
authorTim Otten <totten@civicrm.org>
Sat, 3 Sep 2022 01:55:52 +0000 (18:55 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 3 Sep 2022 03:02:14 +0000 (20:02 -0700)
commit7c516fcf799a8d26381210dcd95a34d9ce69a77b
tree2004223b78e7f895131f7ad30cc09fe2b60315c5
parent37eaf9e7a162d5b30300e9032472f3576290c486
CRM_Queue_Queue - Add 'getStatistic($name)'. Deprecate 'numberOfItems()'

Should `numberOfItems()` tell you the _total_ number of items -- or the
number of _ready_ items?  Trick question.  They can tell you different
things:

* When implementing a task-worker (which should start/stop based
  on available tasks), you'd use _ready_ items.
* When implementing `existsQueue()` (which tells if you the queue
  has anything at all), you'd use _total_ items.

This trick-question is why different implementations have computed
`numberOfItems()` in different ways.

This patch resolves the trick-question by deprecating `numberOfItems()`
and replacing it with `getStatistic($name)`.
CRM/Queue/Queue.php
CRM/Queue/Queue/Memory.php
CRM/Queue/Queue/SqlTrait.php