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.
General code cleanupAvoid duplicated code in pull form- Currently there are the importChannel and importEntities methods inside the importService (the importChannelPage is currently not implemented because not useful). I think the equivalent of importService and importChannel without being batched will be useful to avoid duplicated code. Or the same methods but with an additional parameter $is_batched or $batched
Comment | File | Size | Author |
---|---|---|---|
#33 | interdiff-3122246_30_33.txt | 809 bytes | ivan.vujovic |
#33 | entity_share-Code_cleanup-3122246_33.patch | 9.08 KB | ivan.vujovic |
#30 | interdiff-3122246_27_30.txt | 7.34 KB | ivan.vujovic |
#30 | entity_share-Code_cleanup-3122246_30.patch | 9.04 KB | ivan.vujovic |
#27 | entity_share-Code_cleanup-3122246_27.patch | 11.58 KB | ivan.vujovic |
Comments
Comment #2
GrimreaperComment #4
GrimreaperComment #5
GrimreaperComment #6
GrimreaperComment #7
GrimreaperComment #8
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPatch looks good to me.
Comment #10
GrimreaperComment #13
GrimreaperThe code refactoring will go in #3157110: Additional/refactor tests for the new architecture
Comment #14
yarik.lutsiuk CreditAttribution: yarik.lutsiuk at Smile commentedComment #15
yarik.lutsiuk CreditAttribution: yarik.lutsiuk at Smile commentedComment #16
ivan.vujovicComment #17
ivan.vujovicHello, @grimreaper
The uploaded patch contains several refactorings of code, mostly in
pullForm
.I have left the usage of GET parameters (such as
$this->query->get('offset')
) as they are, I am not sure if we can simplify this code much. If you have some concrete ideas, please let me know.I will now work on the last point (
importService
andimportChannel
without being batched).Comment #18
GrimreaperThanks for the patch. Will give a look when possible.
Triggering automated tests.
Comment #19
GrimreaperNice. Can we make this method a static one in EntityShareUtility.
Because it is only manipulating data on its own without calling anything else.
Hum as previous code did not handled it. That's ok. But maybe we can add some checks for security in the case of a paragraph entity like on #3162950: Entity import status report broken. And maybe checking if the entity is revisionable for the "->getRevisionId()".
As previous code did not do that. I will not block the patch for that.
Going to test.
Comment #21
GrimreaperTest ok.
Patch from comment 17 merged.
@ivan.vujovic, can you please take my review points into account in your next patch please?
Comment #22
ivan.vujovicThanks @grimreaper for you review and merge!
I totally agree with what you commented.
I think the reason we've never encountered an error with
toUrl
is that Paragraph entities don't have "changed" attribute so for them the status is always Undefined.Here is a patch containing just the fixes related to your comments.
I will not have time to work on the rest next week, the issue can be kept open.
Comment #23
GrimreaperComment #25
GrimreaperPatch merged! Thanks :)
Comment #26
GrimreaperI forgot to update the status back to "Needs work".
Comment #27
ivan.vujovicHello,
I'm uploading the patch which should fix the last point of this issue.
I added the non-batched versions of these methods (using the parameter
$is_batched
), but they are not used anywhere yet.I see a possibility to actually use it in
EntityShareAsyncWorker::processItem()
.Comment #28
GrimreaperComment #29
GrimreaperThanks @ivan.vujovic for the patch.
Really nice work!
Here is my review.
From the comment just above, now that importEntities has a $is_batched parameter, is it possible to use it directly?
I am sorry. I think I was wrong about the usefullness of having the importChannel not batched. Or maybe you see a case where it can be usefull?
As it may be used for a great amount of entities. Without batch, it is timeout or memory_limit errors ensured.
Also, not sure that if not batched, only the first page imported will be appreciated.
If you don't see any usage without batch of importChannel, please revert the changes in this method.
Nice!
I think the importChannelPage method can be removed. This one seems better.
Nice to have adapted code in test classes!
Comment #30
ivan.vujovicHello @grimreaper,
I added the call to
ImportEntities()
in the Async module, the function itself needed a small adaptation to return the array of entities.Also I removed the changes to
importChannel()
, I agree it is not so useful because we cannot guarantee the number of items will be small enough.However, we have only an assumed limit of entities of 50 in
ImportEntities()
because in the BO it is impossible to select more, but otherwise I don't see we have this limit implemented in code. I don't think this is an issue for now, but maybe later if this method becomes more used, we should think about it.Comment #31
GrimreaperThanks @ivan.vujovic for the updated patch!
One last comment. I can make the change myself, only need your opinion.
I think it is "void" and not "NULL".
And you are right about the limit. 50 is the default max of JSON:API. I know that there is a module or patch to be able to control it. But we will see when someone will create an issue.
Comment #32
GrimreaperComment #33
ivan.vujovicHi, adding the small correction of function's comment, it should indeed be
void
.Comment #35
GrimreaperThanks! This is merged now.