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
#1446932: Improve statistics performance by adding a swappable backend deprecated statistics_get()
before deprecation testing was a thing and it never removed all the usages.
Proposed resolution
- Remove all usages
- Add @trigger_error
- Add a test
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
N/a
Comment | File | Size | Author |
---|---|---|---|
#14 | 3068060-14.patch | 9.22 KB | alexpott |
#14 | 10-14-interdiff.txt | 1.92 KB | alexpott |
#10 | 3068060-10.patch | 8.66 KB | alexpott |
#10 | 6-10-interdiff.txt | 1.86 KB | alexpott |
#6 | 3068060-5.patch | 8.56 KB | alexpott |
Comments
Comment #2
alexpottComment #3
timmillwoodThe long
@expectedDeprecation
feels wrong, but it looks logically correct. 😉Looks fine to me.
Comment #5
timmillwoodAh yes, for backwards compatibility statistics_get returns an array, where as the newer service returns a StatisticsViewsResult object.
Comment #6
alexpottAh the return values are not the same.
Comment #7
andypostExcept nit (which probably out of scope) it looks good
maybe move service access out of loop?
Comment #8
alexpott@timmillwood yep this patch has nothing to do with the
\Drupal::service('date.formatter')->format()
part so shouldn't be touching that. Thanks for the reviews :)Comment #9
catchThis is fetching the statistics for the node up front, even if none of these tokens are used. We should just do a 1-1 replacement of the existing logic instead.
Comment #10
alexpottSure we can do that. I guess it means multiple queries if multiple tokens are used. But that seems an acceptable trade off. And this patch shouldn't be making any changes on that scale.
Comment #11
alexpottNote this doesn't result in any queries - just getting an object from the container.
Comment #12
mikelutzComment #13
BerdirYeah, this is still a tiny overhead since most calls to this probably don't hav statistics tokens, but that's not going to be measurable.
Hm. Feels like it would actually be easier and less code to just drop the foreach and have 3 different xpath + assertFieldByXpath() lines? Was a neat trick when we had an array with (mostly) matching keys/values, but seems weird now.
I also just noticed that there is a second loop below, but that just checks that the fields don't exist at all, so the specific value shouldn't matter and we could simplify that too? Multiple combined contains() for example like https://stackoverflow.com/questions/12152890/xpath-contains-one-of-multi...?
Comment #14
alexpottUpdated the test. It changes the test to be more inline with a functional test and test what the user sees rather than the underlying HTML. Makes for a simpler and easier to grok test.
Comment #15
BerdirWorks for me :)
Comment #16
catchComment #18
catch