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
This is a follow-up to #2500521: Upgrade path for Statistics 7.x and 6.x where we identified that StatisticsViewsResult was (sometimes) returning strings when it should only ever return integers.
Proposed resolution
Cast the inputs to integer in the constructor.
Remaining tasks
Write patch.
Review patch.
etc.
Removes @todo from Drupal\Tests\statistics\Kernel\Migrate\d6\MigrateNodeCounterTest and Drupal\Tests\statistics\Kernel\Migrate\d7\MigrateNodeCounterTest (assuming #2500521: Upgrade path for Statistics 7.x and 6.x lands first).
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#20 | 2926069-20.patch | 2.71 KB | jofitz |
#20 | interdiff-16-20.txt | 1.67 KB | jofitz |
#16 | 2926069-16.patch | 3.14 KB | Dinesh18 |
#16 | interdiff.txt | 474 bytes | Dinesh18 |
#14 | interdiff-11-14.txt | 1.58 KB | jofitz |
Comments
Comment #2
jofitz CreditAttribution: jofitz at ComputerMinds commentedCast the inputs to StatisticsViewsResult to integer in the constructor.
Comment #3
timmillwoodWorks for me.
Comment #4
xjmThanks! It's updating one assertion, but can we also add an explicit test that we always get integer output even when the input is strings?
Comment #5
jofitz CreditAttribution: jofitz at ComputerMinds commented@xjm Can you explain a little more, please? I'm sorry, I don't understand what you are asking for.
Comment #7
Wim Leers@xjm means: construct a
StatisticsViewsResult
object, pass 3 strings, verify you get back 3 integers when you use the 3 getters.My inclination is that that seems a disproportionate amount of testing for the bugfix. OTOH, this appears to not be a problem in core, only with migrate? Then isn't this a bug in migrate?
Comment #8
heddnRe #7: it isn't so much a bug in migrate as a bug in the statistics API that migrate is using in a test. Back to NW for #4.
Comment #9
heddnThis will also need a re-roll if/when #2930101: i18n / statistics - node counter not updated for translations lands. Since it is critical, let's soft-block here. Or get this in super fast. Here's a patch with the added tests.
Comment #11
heddnComment #12
timmillwoodLGTM
Comment #13
alexpottint|string right? as that's the point of the test to assert that if strings are input then ints are output.
Also I think this test would be better as a data provider rather than a single test.
This param is not passed.
Comment #14
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddressed both of @alexpott's comments in #13.
I'm not sure if there's any point in retaining assertNodeCounter(), but I've left it for now.
Comment #15
borisson_Should be only one empty line
I don't think assertNodeCounter is needed as it's used only once.
Comment #16
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedremoved the extra empty line as per comment #15.
Here is the patch and interdiff.
Comment #17
dawehnerWhat about providing also the expected values?
Comment #18
jofitz CreditAttribution: jofitz at ComputerMinds commentedWhat do you mean, @dawehner?
Comment #19
borisson_I'm not sure about adding
assertNodeCounter
as a seperate method, it doesn't add any value to extract this, as it's only used in one place. I already mentioned this in #15. If we do that, I feel like @dawehner's remark will be resolved as well.Comment #20
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #21
borisson_Awesome, looks great!
Comment #23
MixologicTestbot Snafu.
Comment #25
bibliophileaxeTestbot issue.
Comment #26
alexpottCommitted and pushed c01bed2b2d to 8.6.x and c71f50f5ad to 8.5.x. Thanks!