(
So yeah. I wandered into here via DDD Szeged sprinting, drupal8multilingual.org focus issues, which has #2068325: [META] Convert entity SQL queries to the Entity Query API.
I took #2068331: Convert comment SQL queries to the Entity Query API , but until yesterday I hadn't really seen that that one coincides with child issues of #2096923: [meta] Clean-up CommentManager service and deprecate procedural helper functions.
)
I'm trying to split #2068331 out into more manageable chunks. This chunk covers CommentManager as well as CommentStorage... Maybe...
Questions:
- Do we want to deprecate comment_get_display_page() and comment_get_display_ordinal() too?
comment_get_display_page() has 2 callers (CommentForm::save() & CommentController::permaLink())
comment_get_display_ordinal() only gets called by comment_get_display_page(). Thing is, it must be in CommentStorage.
/**
* Gets the display ordinal for a comment, starting from 0. [...]
*/
function comment_get_display_ordinal($cid, $instance) {
[[ SQL gunk that belongs in CommentStorage ]]
return $query->execute()->fetchField();
}
/**
* Returns the page number for a comment. [...]
*/
function comment_get_display_page($cid, $instance) {
$ordinal = comment_get_display_ordinal($cid, $instance);
$comments_per_page = $instance->getSetting('per_page');
return floor($ordinal / $comments_per_page);
}
- If comment_get_display_ordinal() moves to CommentStorage, what do we do with comment_get_display_page()?
- Stick it in CommentManager?
- Delete it altogether and make getDisplayOrdinal have a third argument called 'int $divisor'? That could default to 1. If you pass it the number-of-comments-per-page, you get the output of what is now comment_get_display_page()...
- Do we want to pass the new methods a Comment object instead of a $cid, as the first argument?
My first stab at this, split off from #2068331, kept $cid intact because comment_get_display_page() wants to give it a $cid. But merging comment_get_display_page() into comment_get_display_ordinal() could make it easier to replace the argument with a Comment object...
Comment | File | Size | Author |
---|
Comments
Comment #1
roderik.
Comment #2
roderikComment #3
larowlan+1 to merging
Comment #4
roderikCool.
Updated patch.
(I didn't heed the 80 column boundary where surrounding code didn't.
Plus added a random coment change because I was just disciplined on https://drupal.org/node/1354#order.)
Comment #5
slashrsm CreditAttribution: slashrsm commentedComment #6
slashrsm CreditAttribution: slashrsm commentedReroll.
Comment #7
slashrsm CreditAttribution: slashrsm commentedMerge garbage removed.
Comment #8
marcingy CreditAttribution: marcingy commentedWhy not
Just means the return can be tidied up.
Similar in comment_get_display_page.
This maybe scope creep but user_access is deprecated and we should be using the user service. (\Drupal\Core\Session\AccountInterface::hasPermission().)
Should COMMENT_MODE_FLAT become a defines for the interface?
Comment #9
slashrsm CreditAttribution: slashrsm commentedHere we go.
Comment #11
slashrsm CreditAttribution: slashrsm commentedMeh!
Comment #12
Primsi CreditAttribution: Primsi commentedComment longer than 80 chars. Apart from that looks ok to me.
Comment #13
slashrsm CreditAttribution: slashrsm commentedFixed and re-rolled.
Comment #14
marcingy CreditAttribution: marcingy commentedLooks good
Comment #15
marcingy CreditAttribution: marcingy commented13: 2262407_13.patch queued for re-testing.
Comment #17
slashrsm CreditAttribution: slashrsm commentedReroll.
Comment #18
slashrsm CreditAttribution: slashrsm commentedComment #19
alexpottThis needs a change notice to announce the deprecation and the moving of the constants.
Unnecessary use statements and incorrect spacing.
Comment #20
slashrsm CreditAttribution: slashrsm commentedReroll and fixed.
Comment #21
slashrsm CreditAttribution: slashrsm commentedChange record draft: https://www.drupal.org/node/2299799
Comment #22
roderik@ #19/alexpott: Change record for moving of constants is at https://www.drupal.org/node/2295487
(This was made for #2281475-37: Deprecate comment_new_page_count() and move it functionality into Comment storage controller. Either #228147 or this issue will need a reroll when the other gets committed. I know this isn't ideal but it's better than splitting the constants move out to a separate issue at this point in time...)
--
Many functions in comment.module have been marked @deprecated but are not 'record'ed yet. I think it makes sense (to the reader) to have all these in one change record. (Also all of the issues have seen RTBC already, so I believe the downside for committers to have these in one change record is minimal.)
So I'll go edit slashrsm's change record to add those, and you can tell me to revert/split the text if it must be so.
Meanwhile, this is back to RTBC. (I believe the last interdiff.)
Comment #23
alexpott@roderik yep I agree that once change record for all the removed functions in comment.module is preferable. But each issue needs to be added to this change record - so there is no downside for committers - we just need to see the change record referenced.
Committed 47d6bc0 and pushed to 8.x. Thanks!
Fixed this on commit - the constants COMMENT_MODE_FLAT and COMMENT_MODE_THREADED no longer exist.
Comment #25
andypostneeds follow-up to use $comment_storage consistently