Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
#2044435: Convert pager.inc to a service introduced the DeprecatedArray class to allow throwing deprecation error when accessing the legacy pager global variables.
However, this class only implements \ArrayAccess, the array eleemnts can not be traversed with foreach, nor casted to 'real' arrays.
Unfortunately this is going to break the Pagerer module in contrib, that is inspecting the $pager* array variables, and no longer can.
Proposed resolution
Implement some sort of iteration to the DeprecatedArray class (?)
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#10 | 3087602_10.patch | 3.31 KB | Ghost of Drupal Past |
#6 | 3087602_6.patch | 2.67 KB | Ghost of Drupal Past |
#3 | 3087602-3.patch | 1.78 KB | kim.pepper |
Comments
Comment #2
larowlanIterator aggregate would be simplest
Comment #3
kim.pepperUpdated so that
DeprecatedArray implements \ArrayAccess, \IteratorAggregate
Comment #4
mondrakeThanks a lot!!
Comment #5
Ghost of Drupal PastThis works but wouldn't https://www.php.net/arrayobject be better?
Comment #6
Ghost of Drupal PastLike this. Significantly simpler, isn't it? (I hope it works, too.)
Comment #7
kim.pepperI like your version better @chx 🙂
Comment #8
mondrakeWow!
Would this also work with array functions? For instance,
array_keys
? ATM doingarray_keys($pager*)
fails because the variable is no longer strictly an array. Also, would it work while asserting equality in tests, e.g.assertEquals([5, 3], $pager_total)
?Comment #9
Ghost of Drupal PastNope. An ArrayObject is, well, an ArrayObject and those functions require an array. It's sad.
Comment #10
Ghost of Drupal PastI realize AO now implements four interfaces (ArrayAccess,IteratorAggregate,Serializeable,Countable) which all should throw deprecation notices. The patch is longer but equally boring.
Arguably it's a bug in core that offsetSet has a return value when the signature requires a void. I fixed this (and offsetUnset and added unserialize w/o a return).
Comment #11
larowlanComment #12
alexpottCommitted and pushed 31314fca7d to 9.0.x and e4fe714f5f to 8.9.x and d371e9cf36 to 8.8.x. Thanks!
Fixed coding standards on commit.