Closed (fixed)
Project:
Image Field Repair
Version:
8.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
26 Apr 2018 at 14:39 UTC
Updated:
10 Nov 2018 at 20:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedvaplas created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedThere are a couple of minor ideas on how to change
image_field_repair.inc. Changes do not bring significant improvements, so you can ignore them if laziness. Or use only partially.The
interdiff-refactoring.txtis patch withdiff -wfor more readability.Review:
A slight simplification + message for site without images.
Decouple report in a separate function.
Just a little simplified logic.
The biggest change :)
The idea is that instead of a one function with
$dataOrRevisionflag, use two special functions + one general function.Comment #3
fietserwinI don't see much advantage in combining this into 1 function, I find the list() even less readable.
#finished is a number, a fraction between 0 and 1 indicating the percentage completed, it is not a bool. See e.g. #2141221: hook_update_N() should document how to use $sandbox['#finished']. Let's revert all logic around #finished.
Extracting the reporting is a good idea!
I am not sure about this. I think, I prefer to have 1 place to get service classes and from there on pass them around using parameters.
Putting the other parameters and results in the $batch parameter is a good idea though!
Comment #4
Anonymous (not verified) commented#3.1 Full agree.
list($field_ids, $table_info)is not an improvement here, it is rather a side effect :(I just wanted to hide preparation detalis:
But I did not succeed, and now this part has turned into spaghetti. Will be reverted.
#3.2:
If this should be a number, how about a casting?
It just seems to me that here is quite a complicated logic for the initialization phase. Because
$sandbox['processed']is always 0. So, we need check only$sandbox['total'].#3.3: Thanks!
#3.4: One place is really makes sense. Will be reverted.
Comment #5
fietserwinRE #4:3.2: Originally it may have been outside the if and the else, but as it is now, in the if part it indeed doesn't make sense, so let's change it to:
$sandbox['#finished'] = $sandbox['total'] === 0 ? 1 : 0;(I don't want to know (or depend on) how booleans are cast to int)
Comment #6
Anonymous (not verified) commented#5: Even better! Done.
Comment #8
fietserwinCommitted with some minor changes.
Comment #9
Anonymous (not verified) commentedI compared the some minor changes - they all absolutely make sense! Thanks again, @fietserwin!
Also I have been testing the module with this refactoring for a long time. Everything works like a charm!
return $sandbox['#finished'] === 1 ? t('Not found any image records') : NULL;I had a funny case, because of which this is really useful message. When I tried the module on one internal site (for employees), I found that pressing the "Start" button does not lead to any effects - only page relaod. I was very confused, because site contains images.
But debug explained to me that all of them are just part of ckeditor fields in nodes))
So the module worked really well. Just did not bring out the reasons for which so quickly coped :)
@fietserwin, do you have a plan to create a new release? Now the usage part of the module page is oriented to the dev version. But usually everyone downloads the release version.