Updated summary: this had an initial commit, and the things left to do are summarized in comment #83.
To be able to update a module's translation, we need to collect the project info. The process is similar to Update module but required additional data for which some changes were made in #1329410: Extend update data collection to support localization update.
This State diagram shows the project info collection process in Localization Update module and how it is related to all other processes.
Comment | File | Size | Author |
---|---|---|---|
#99 | interdiff.txt | 590 bytes | Gábor Hojtsy |
#99 | convert-new-variables-to-cmi-1627006-99.patch | 19.94 KB | Gábor Hojtsy |
#95 | convert-new-variables-to-cmi-1627006-96.patch | 19.94 KB | Gábor Hojtsy |
#95 | interdiff.txt | 688 bytes | Gábor Hojtsy |
#94 | interdiff.txt | 4.89 KB | Gábor Hojtsy |
Comments
Comment #1
Gábor HojtsyLooks great :)
Comment #2
Sutharsan CreditAttribution: Sutharsan commentedThis patch adds a locale_project_list() function including tests. It collects project data for projects which interface translations may be imported automatically including custom modules which have an 'interface translation project' property in their .info file. Other new info file properties included are:
Comment #3
Sutharsan CreditAttribution: Sutharsan commentedComment #4
Gábor HojtsyA quick review of the current patch:
Comment does not match filename.
Comparison tests? The explanation is not very clear to me here.
Certainly not date formats :)
2 empty lines too much?
normale => normal
Need phpdoc for each define separately. Also D8 uses the const keyword now instead of define to define constants.
I don't think we should. Those who use hidden modules to make their modules UI saner should have an alter function for it too :) (like Drupal Gardens). It is not the job of this functionality IMHO. It would be good to be in line with how update module works.
These might be better named locale_translation_* I think that is the variable space (if not locale_translate_*). Something along those lines, there are existing variables.
This is good for now, but I think it should eventually become an optional dependency. So if you have update module enabled, it could do this, but if you disable update module, then locale would not have this feature. :) I think.
Missing newline at end of file.
Comment #5
Sutharsan CreditAttribution: Sutharsan commentedUpdate module is required for
update_process_info_list()
. Without this Locale can not update its project data when new projects are added, module are updated or modules are removed. It can only update translations of existing modules. IMHO this would seriously cripple the functionality.Comment #6
Gábor HojtsyYes, I think it would still be possible to have locale module translate the UI and not update anything. As soon as update module is turned on again, its update functionality would start working again. IMHO. If update module is turned on, it cannot work, so it would not do any project/translation updates. It would "gracefully degrade" so to speak to the base functionality of not doing updates.
Comment #7
Sutharsan CreditAttribution: Sutharsan commentedAgree with the gracefull degradation. But then we should notify the user for example on the translation update page. Since translations of new modules are not imported, which is an unexpected behaviour which can not be predicted.
New patch contains:
locale_get_projects()
function to be called by the 'Get current translation status' in the UML above.Comment #9
Sutharsan CreditAttribution: Sutharsan commentedChanges:
locale_translation_
The interdiff is not complete, but this is the best I can do for now.
Comment #11
Sutharsan CreditAttribution: Sutharsan commentedChanges in this patch:
Comment #12
Peter MajmeskuChanges in this patch:
Commented out definitions for interface translations from in locale_test.info file and moved it into locale_test_locale_translation_additional_project_info();. The assertions for that are passing in the simple test file (= LocaleCompareUnitTest.php).
Furthermore uncommented
Because there is already
Now all tests are passing on my local machine.
Thank's @ Sutharsan! He helped me to understand how to get into testing of the locale module.
Comment #13
Schnitzel CreditAttribution: Schnitzel commentedchecked the locale-project-info-1627006-10.patch looks good to me, one small thing.
This should probably make an "$projects += module_invoke($module, $hook);".
Or why are you not using module_invoke_all() ?
Comment #14
Sutharsan CreditAttribution: Sutharsan commented@jepSter Thanks for stepping up. You have added a patch file to your patch. Please be more carefull next time. Further we use interdiff files to highlight the differences between large patches, that would have helpt greatly to check your work.
Comment #15
Sutharsan CreditAttribution: Sutharsan commented@jepSter, other comments:
Don't comment lines out, just remove any unused code.
Missing documentation for new locale_test_locale_translation_additional_project_info() function.
Comment #16
Sutharsan CreditAttribution: Sutharsan commentedChanges:
Comment #17
Sutharsan CreditAttribution: Sutharsan commentedChanges:
Comment #18
Peter Majmesku@ Sutharsan:
#14
Could you post me please, in which line of the patch I can relocate your mention with the "added patch file to the patch"?
# 15
Which kind of documentation you imageine?
#17
This patch isn't working for me. I get the following:
Comment #19
Sutharsan CreditAttribution: Sutharsan commentedStaring:
+++ b/core/modules/locale/locale-project-info-1627006-10_0.patch
Doxygen comments like
Use a clean 8.x checkout, not a branch, or apply interdiffs.
Comment #20
Gábor HojtsyJust reviewed your patch. Mostly code style and naming comments. The code looks very clean btw, great stuff :)
...UnitTest extends WebTestBase; not the right naming standard(?) We don't name web tests as unit tests. Although you don't use the web UI, you need the database.
I don't think you are actually using the article content type here, are you? Also, you don't seem to need a user or permissions either.
Technically these are not unit tests because you depend on the DB setup with the projects.
Yup :)
Would be good to document the array structure. I see you documented this inside the function, but right here would be better.
Function comments should be on one line.
localize.drupal.org
@attiks asked me about the local file system possibilities, great to see this documented.
Why only in that file?
Wishlist sounds good. In fact the update URL including pattern is in http://localize.drupal.org/l10n_server.xml, but not as separate pieces of data. This is really the server's property, so I agree it would be good to just get it from the server.
@file comments are not indented. Yeah.
This comment should be removed later.
Fantastic.
Hm, why? Are you only getting project data for enabled I assume. Would be good to document IMHO. Any race condition possibilities here?
Specify the return type as array (@return array).
Wrong indent for if().
Not sure if you should indent values for lists like that when wrapping to second line. But in this case, it can even fit on first, as far as I see.
'an url' => 'a url' (I think, sounds like an 'a' independent of how you pronounce url in English :)
Would be good to document the similarities of this table to the update project tables.
You are not using this yet, are you? What do you need it for?
Wrong whitespace.
Do not indent @file comments, also if you need a second line, separate with an empty line.
Comment #21
BerdirQuick re-roll, addressed most of the things in Gabor's review.
Comment #22
BerdirFixed the $modules definition.
Comment #23
Gábor Hojtsy@Berdir: thanks!
Seems like there are still a couple @todos. I don't think it is realistic to expect any major development on localize.d.o in the timeframe left for Drupal 8, so let's work with what we have there :)
Comment #24
Gábor Hojtsy@Berdir: also, can you point out the items you did not cover in your patch? It would be simpler to discuss further :) Thanks!
Comment #25
Gábor HojtsyA deep review once again :)
The test is named LocaleCompareTest, doc does not match name.
- Tests (typo)
- "translation status comparison"
Should have @file level comments explaining what this file is.
I think the first set of comments should be moved to the phpdoc to explain $projects. Also make it "@param array $projects".
Also move the second block of comments to replace the @todo, and explain the keys we add and their roles there. Eg. why do we need the server and server URL separately?
Move this up to the main phpdoc for reference. Also maybe reword a bit to explain the main reason. Something like this to lead it up would be good:
"For modules not hosted on drupal.org, a project definition is not available or discovered by update module. To let translations to be provided for that either on the local file system or in a file structure similar to localize.drupal.org's downloads, we let custom modules provided via this API."
And then explain the specifics of the project key, etc.
Explain here that this is for the "submodule" use case, as in when multiple modules are under the same project/code tree.
We'd need to support module level stuff anyway, so we can add this automation later if we want to. I think this can be a followup easily.
Not sure what you mean by this. What needs to be tested here?
Try and reword these to fit on one line.
Build => Builds
What is the effect of these on the upper layers of the API? What happens if the update module is not enabled? Does the user know they miss functionality? Can we document that?
As said above, the server based sourcing of these values can happen in a followup IMHO. So I'd remove this todo. However, it would be great to get these keys inline with the info file key names. They are totally different now (eg. use underscores).
Same stands above in build projects where these keys are put on projects as well. A little unification would be good.
Sounds like this would be pretty simple to do(?).
Maybe explain a bit more, eg. "Translation status information for projects compared to translation server data." or something along those lines.
Sounds like we can return to this later in a followup.
DO NOT reorder update functions!
Text for @file should be on the same column as the @file comment itself (outdent 2 spaces).
Comment #26
lazysoundsystem CreditAttribution: lazysoundsystem commentedThis patch clears away some of the minor items from Gábor's review in #25.
It hasn't touched the locale.api.php file, so all of the comments relating to that still stand. Plus these three:
What is the effect of these on the upper layers of the API? What happens if the update module is not enabled? Does the user know they miss functionality? Can we document that?
As said above, the server based sourcing of these values can happen in a followup IMHO. So I'd remove this todo. However, it would be great to get these keys inline with the info file key names. They are totally different now (eg. use underscores).
Same stands above in build projects where these keys are put on projects as well. A little unification would be good.
Sounds like we can return to this later in a followup.
Comment #27
lazysoundsystem CreditAttribution: lazysoundsystem commentedHere's a diff of the changes between:
locale-project-information-1627006-22.patch
locale-project-information-1627006-26.patch
Comment #28
Sutharsan CreditAttribution: Sutharsan commented@lazysoundsystem, thanks for the work. Changes look good. An interdiff file is a text file in patch format that shows the changes between subsequent versions of a patch. (see http://drupal.org/node/1488712) not a diff of patches.
New interdiff attached.
Comment #29
lazysoundsystem CreditAttribution: lazysoundsystem commented@Sutharsan - thanks for the clarification. got it.
Comment #30
Gábor HojtsyReviewed this with @webchick just now. She was ok with introducing these as .info file properties, just asked us to vet the items introduced and only include ones we do need in this patch. So looks like tracking it down:
- we need pattern because we want to allow local file storage (eg. in git) and we want to allow other translation sources to use different patterns (eg. if someone uses pootle or something else)
- we need the server url so we can initialize the pattern from the server if we don't find it locally (and it was not provided); however, this requires #1632384: Import available language list from translation server in fact as far as I'm seeing in the patch, so if we want this convenience, we maybe cannot forgo introducing that either, even though we would not use most of it, we'd just use the update url pattern
- we need the project name for custom projects, especially with submodules, so they can be grouped together
- finally, what do we need the server name for?
So looks like if we forgo the pattern automation, then we can skip the server URL and only use the project and download pattern keys. Unless we need the server name for something. Do we want to display it on a nice UI somewhere?
Comment #31
Sutharsan CreditAttribution: Sutharsan commentedI found two places where the server name is used. In the translation update status list and in a message when the l10n_client saves a string to the remote server. The update status page will change and I don't expect that a remote server name is needed. The l10n_client can probably also do without a server name ('You could share your work with !l10n_server if you set your API key at !user_link.').
If we drop the server URL the pattern must be hard coded in the module and can't be set by the server at runtime. I don't expect this to be a problem but it will be a simplification of the code. If a need to alter the patter should arrise, it can stil be implemented using an alter hook.
So, I agree that the minimum requirement is a project name and a po file pattern.
Comment #32
Gábor HojtsyYes, sounds like that would both simplify the code, make it easier to get accepted and still keep the automations implementable in contrib if need be :)
Comment #33
Schnitzel CreditAttribution: Schnitzel commentedworking on this
Comment #34
Schnitzel CreditAttribution: Schnitzel commentedjust discussed with Gabor about the gracefully degradation in locale_translation_build_projects() and locale_translation_project_list().
The function locale_translation_get_projects() calls locale_translation_build_projects() (which will return an empty array if update module is disabled) but then still uses the already existing data in the locale_project table, which is good. But maybe we should document this in the locale_translation_build_projects() and locale_translation_project_list() function, just to not confuse devs :)
and maybe we can extend this:
with
because if the update module was never enabled, the $result will be empty all the time =)
Comment #35
Schnitzel CreditAttribution: Schnitzel commentedunsassigning form me, because sutharsan is working on it.
Comment #36
Sutharsan CreditAttribution: Sutharsan commented@Schnitzel, yes I am ;) but thanks for looking into the degradation issue.
Attached patch contains a first answer to Gabor's comments (#25) on the documentation in locale.api.php. Due to the change (#30) in using the .info file definition (again) the API will change and the documentation with it. So more documentation changes to locale.api.php to follow. Next I will work on bringing back the .info properties and include Schnitzel's degration suggestions.
Comment #37
Sutharsan CreditAttribution: Sutharsan commentedComment #38
Sutharsan CreditAttribution: Sutharsan commentedModifications:
Still needs to do some work on the unifications of key names. I like to get it right, but need some help on it. For example "server_pattern" can not be changed into "server pattern" because it is used as database table name.
Comment #39
Sutharsan CreditAttribution: Sutharsan commentedKeep for getting this ;)
Comment #40
Sutharsan CreditAttribution: Sutharsan commentedSummary of name unification:
.info properties:
- interface translation project
- interface translation server pattern
Corresponding variables:
- project (No subject to change. Also corresponding to project .info file property)
- server_pattern
Correponsing field in {locale_project}:
- n/a
- server_pattern
Comment #41
Gábor HojtsyI think this sounds like a good plan!
Comment #42
Sutharsan CreditAttribution: Sutharsan commentedThis is already the current situation. So plan executed ;)
Small documentation change in attached patch.
Comment #43
webflo CreditAttribution: webflo commentedRemove t() calls from all assertions. see #500866: [META] remove t() from assert message for more information.
Use format_string().
Some whitespace.
A example would be nice.
{system}.name has a length of 255.
{system}.type is equivalent and has a length of 12. I think its better to standardize the column name.
Description is wrong.
Comment #44
MantasK CreditAttribution: MantasK commentedapplied changes from #43
Comment #45
andypost#44 plus a few grammar and schema description
should be int
Comment #46
Sutharsan CreditAttribution: Sutharsan commentedTypo fixed.
Comment #48
andypostSize increased to 15 because we have project-type 'module-disabled' it's not a
{system}.type
is a project type + project statusA fatal error occurred: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'project_type' at row 1: INSERT INTO {locale_project} (name, project_type, core, version, server_pattern, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => locale_test_disabled [:db_insert_placeholder_1] => module-disabled [:db_insert_placeholder_2] => 8.x [:db_insert_placeholder_3] => 8.0-dev [:db_insert_placeholder_4] => http://ftp.drupal.org/files/translations/%core/%project/%project-%version.%language.po [:db_insert_placeholder_5] => 0 )
Comment #49
webflo CreditAttribution: webflo commentedI think it looks good. Just a few minors.
$transaction is never used.
Typo: placeholders
Typo: placeholders
Is it save to call drupal_get_schema_unprocessed() for cache tables in hook_update_N()? I am not sure about this.
Comment #50
Gábor HojtsyYou are right on all your points. Updated.
Comment #52
webflo CreditAttribution: webflo commentedFixed the syntax error.
Comment #53
webflo CreditAttribution: webflo commentedUpdate the last patch and added a @defgroup definition. Moved the big dockblock to the top of locale.api.php.
Comment #54
Gábor HojtsyLooks good to me now!
Comment #55
Gábor HojtsyThis blocks the following things:
- #1742894: Get status of local and remote translation files
- actually downloading the .po files
- displaying all languages and using the above layers downloading translations in the installer
- #1337628: Enhance language select form with textbox and other tools UX work on the installer so it can make sense of 100 languages displayed
- integrating the downloaded translations with CMI so you can download an English Drupal and can still get your default views, vocabularies, etc. configured in your language when you install it
(Edited first wrong link).
Comment #56
webchickHere is some feedback I found while going through. 95% of it is docs changes, which are fine to handle in a follow-up.
A couple of larger things are:
- This introduces (at least) two new variables which need to be converted to CMI. In general, I *really* dont' want to commit anymore patches that do this, because it conflicts with and holds back a separate effort going on to get the number of variable_get()s in core down to 0. I talked with Gábor about it and his stance is that this is work that could happen after feature freeze, which is fair enough, but it'd still be lovely to have a commitment from someone working on D8MI (who is not key to some of these major features) offer to take this on after the sprint. webflo has offered to do this. Yay!
- The logic to add in the cache tables looks like it's doing more work than it needs to, at least when you compare it to http://api.drupal.org/api/drupal/modules%21update%21update.install/funct... and http://api.drupal.org/api/drupal/modules%21update%21update.install/funct... and the like. I'm concerned that the way it is now could cause the locale module's cache tables to get out of sync with system module's cache tables.
Since we have some verbal commitment for the CMI follow-up, and since the cache table getting out of sync is somewhat an edge case that hopefully we can put away with the docs changes in short order after this patch...
Committed and pushed to 8.x. Thanks!!!
Great to see this feature taking off! :D
These comments are very thorough (yay), but need a bit of clean-up. I've outlined a few minor grammar problems below, but in general I feel like I'm being explained something but not given some specific details to help me understand the big picture until a lot later in the text.
Should be "For" or "On" modules hosted on drupal.org...?
list of modules
Either Custom "modules" or "A" custom module which "contains"
Let's add a comma after "Using this hook"
Or to add additional custom/non-Drupal.org modules to it, correct? Might want to point this out.
In general I think we do not use SELECT * because it has bad performance on InnoDB. Can we specify the columns here?
Hm. Is this sufficient to check if the information is out of date? What if update module is enabled, and the row count comes back with 30 rows, but I have 20 more modules I've added? (This is very feasible on sites that aren't running cron.php regularly.)
Does it make sense to abstract this out to some other .inc/.module? Or do you think it's better to hinge it off of Update module because our checkbox on the registration form about privacy is tied to that, and this is a similar deal? I know a lot of sites that keep Update module turned off because it can cause problems with cache rebuild race conditions. OTOH, it seems like this functionality could possibly do that too, so maybe best to leave it where it is. Follow-up, if anything, in any case.
This logic looks like it'd be really nice to pull out into a helper function, since I've seen similar checks both here and in Update module. (Follow-up)
Could we have a comment explaining what preg_match("/HEAD/" is doing?
Should this also be in an isset() check, as the others are?
Won't these two lines cancel each other out? $projects should already have been instantiated as an array(), no?
(nitpick) There should be a newline between these two sentences.
(nitpick) There's some non-standard wrapping here which we should fix.
Though I wonder if we should simply add a @see to the PHPDoc to point people off to the docs which already explain this, rather than doing so here, since the function logic here is actually fairly simple.
This should be moved to CMI; we don't want to introduce more variables to convert, IMO.
The rest of these have been instantiated before it gets to this function (or at least there are no isset() checks), can we do the same for these values?
Project type":"
Could we add a small example of a valid value here? I don't think people will know what this is by reading the schema.
Same here. What possible values are there and what do they mean?
I think this should be using a method similar to http://api.drupal.org/api/drupal/modules%21update%21update.install/funct... rather than re-defining the schema again here.
Just in general, we call these gettext files, .po files, and po files. It'd be nice to standardize on one terminology.
Another variable we need to move to CMI.
"unhidden" rather than "not-disabled"
contrib "module"
Comment #57
BerdirAbout the cache table thing: This is a temporary solution, we hope that this can be updated to use a Key/Value storage just like the update "cache". Sutharsan attempted to re-integrate the update cache handling back into the default cache handling in a separate issue, which I sabotaged (sorry!) because that is IMHO the wrong approach.
Maybe open a follow-up for that, or continue using #1547008: Replace Update's cache system with the (expirable) key value store for that, which is the Issue I mentioned...
Comment #58
rvilar@Sutharsan, if you want, I can help you resolving some webchicks comments, like CMI integration and typo/language specific error. Please, let me know if I can help.
Comment #59
Gábor Hojtsy@rvilar: @webflo is working on a followup as per @webchick's notes above. Please help review those when posted (I heard later today). Thanks everyone for being active!
Comment #60
Gábor HojtsyUpdate: @webflo did not have time for this, @Sutharsan said he would be able to work on fixes for the points mentioned by @webchick over the weekend.
Comment #61
webflo CreditAttribution: webflo commentedI had some time to work on coverting the introduced variables to CMI. Here is a first patch.
Comment #63
webflo CreditAttribution: webflo commentedI forgot the $config->save().
Comment #64
Kristen PolDoes
$config->save();
need to be called after$config->delete(...);
as well?Comment #65
aspilicious CreditAttribution: aspilicious commentedNo it doesn't :)
Comment #66
aspilicious CreditAttribution: aspilicious commented+ test_system_info_alter: false
That should be part of the test module config.
And
check_disabled
Doesn't say anything about the usage.
Can we rename it to
check_disabled_modules
Or something else that explains what it does.
Comment #67
YesCT CreditAttribution: YesCT commentedchecking that I've moved + test_system_info_alter: false out correctly
Comment #68
aspilicious CreditAttribution: aspilicious commentedLooking at the usage of the config variable in the test I would say we should revert that to variable_get/variable_del. This is infact just a "sate" and we should handle that with a key value store which isn't in yet...
So revert all test related stuff and fix the comments.
Comment #69
YesCT CreditAttribution: YesCT commentedchecking that I'm reverting test_system_info_alter: config stuff correctly...
But I figure I should also
do something with the
- variable_del('locale_translation_test_system_info_alter');
that was in /core/modules/locale/locale.install
because it should be in the test and not the locale module
I'm not sure though.
Comment #70
aspilicious CreditAttribution: aspilicious commentedJust leave it like it was before. It will get cleaned up in the future.
Comment #71
YesCT CreditAttribution: YesCT commentedI'm not sure about webchick's comment about non Drupal.org modules related to the addtogroup hooks.
Maybe this will do:
* Modules or distributions that use a dedicated translation server should use
* this hook to specify the interface translation server pattern, or to add
* additional custom/non-Drupal.org modules to the distribution.
Comment #72
Gábor Hojtsyto the distribution => to the list of modules known to locale.
It is really about which modules locale knows about and where it gets the translation files for them.
Comment #73
YesCT CreditAttribution: YesCT commentedThere will be changes needed to this. But here is what I have so far.
This patch addresses #56, #66 and #68.
Some items form webchick's comments in #56 are in the patch as @todo's. I'm not sure of the best way to track that. Others are spelled out below as I have questions about them, or I'll list them as needing their own follow up issues that need to be created. Between the patch, the @todo's and the list below, all of webchick's comments are addressed.
#70 and #72 are not taken into consideration yet.
Questions
Question about HEAD
I dont think I have this comment exactly right:
locale.compare.inc
// HEAD versions are for module maintainers and should not be used.
elseif ($name == "drupal" || preg_match("/HEAD/", $data['info']['version'], $matches)) {
// Pick latest available release.
$release = array_shift($project_updates[$name]['releases']);
}
Question about isset() check
#56 comment
+++ b/core/modules/locale/locale.compare.incundefined
@@ -0,0 +1,265 @@
+ 'status' => $data['project_status'] ? 1 : 0,
Should this also be in an isset() check, as the others are?
Question about lines canceling each other out
#56 comment
+++ b/core/modules/locale/locale.compare.inc
@@ -0,0 +1,265 @@
+ $projects = &drupal_static(__FUNCTION__, array());
...
+ $projects = array();
Won't these two lines cancel each other out? $projects should already have been instantiated as an array(), no?
Question about duplicate comments.
In: locale.compare.inc
// Include interface translation projects. Custom modules can bring their
// own gettext translation file. To enable import of this file the module
// must define 'interface translation project = myproject' in its .info
// file. To allow update_process_info_list() to identify this as a project
// the 'project' property is filled with the 'interface translation project' // value.
this is a lot for inline comments, and is repeating what is in the function header comments.
webchick said: Though I wonder if we should simply add a @see to the PHPDoc to point people off to the docs which already explain this, rather than doing so here, since the function logic here is actually fairly simple.
Follow-up issues Needed
Needs follow-up issue: abstract project data to other module
+++ b/core/modules/locale/locale.compare.inc
@@ -0,0 +1,265 @@
+ * The project data is based on the project list supplied by the Update module.
Does it make sense to abstract this out to some other .inc/.module? Or do you think it's better to hinge it off of Update module because our checkbox on the registration form about privacy is tied to that, and this is a similar deal? I know a lot of sites that keep Update module turned off because it can cause problems with cache rebuild race conditions. OTOH, it seems like this functionality could possibly do that too, so maybe best to leave it where it is. Follow-up, if anything, in any case.
Needs follow-up issue: helper function
+++ b/core/modules/locale/locale.compare.incundefined
@@ -0,0 +1,265 @@
+ // The first release with the same major release number which is not a
+ // dev release is the one. Releases are sorted the most recent first.
This logic looks like it'd be really nice to pull out into a helper function, since I've seen similar checks both here and in Update module. (Follow-up)
Needs follow-up issue: standardize gettext, .po, po terminology
#56 comment
+++ b/core/modules/locale/tests/modules/locale_test/locale_test.module
@@ -0,0 +1,27 @@
+ * Simulate a custom module with a local po file.
Just in general, we call these gettext files, .po files, and po files. It'd be nice to standardize on one terminology.
Comment #74
Gábor HojtsyComment #76
YesCT CreditAttribution: YesCT commentedTest failed because didn't set $config first. Attempts to fix that.
I'm not sure what is the best practice, to do it in both code blocks? Like:
Or just once before both.
Comment #77
YesCT CreditAttribution: YesCT commentedComment #78
Gábor Hojtsy- Question about HEAD: I think "HEAD" is a legacy code piece here, it used to be the "tip of CVS", that is similar to what "master" is now with git; so I'm not sure we need that code even anymore; that is the "|| preg_match("/HEAD/", $data['info']['version'], $matches)" part.
- Question about isset() check: I think it can be az empty() there, that sounds like the best option, so 'status' => !empty($data['project_status']) ? 1 : 0,
- Question about lines canceling each other out: sounds like the second initialization is unneccessary; it would probbaly make sense if someone sets the value to FALSE or '' instead of array() outside this function, but that is broken code, we don't need to necessarily work around it; it would fail here in that case, and that sounds fine
- Question about duplicate comments: if the same concept is explained above in phpdoc (which is preferred to long blocks of inline comments), then we can just remove it; if the phpdoc section is sufficiently far away, we can add a @see *into the phpdoc* of the function housing this code
- Needs follow-up issue: abstract project data to other module: the reason we do tie to update module is not only for the privacy setting checkbox; it is more for the APIs provided by the module to check project versions and get info file data
- Needs follow-up issue: helper function: agree, should be a followup
- Needs follow-up issue: standardize gettext, .po, po terminology: agree, should be followup; this also highly depends on the UX of it, eg. talking about Gettext PO files is simpler for users instead of just Gettext or just PO, however, repeating that in the docs all the time and especially in API function names is painful; anyway, separate issue
The rest are in the code as @todo's as far as I understand, so this should mean we are taking care of everything noted so far somehow :)
Comment #79
YesCT CreditAttribution: YesCT commentedRegarding my question in #76 about what pattern to use with possible repeated $config = config(....);
I did:
762 grep -R config\( * | grep Test.php
and picked this one to look at:
763 vi core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
And the patterns in UserRegistrationTest.php look different like:
It seems there, that the $config = config(...); is just done once. And also that the save is part of the line that does the set.
Comment #80
gddIdeally you only want to instantiate a config object once per function call, to reduce overhead.
As far as chaining, we've typically been doing it as much as possible, because I believe (personally) it makes the code easier to read, but others might disagree and I don't think there is an established standard. So the example in #79 is fine as far as I can see.
Comment #81
YesCT CreditAttribution: YesCT commentedRegarding: Needs follow-up issue: abstract project data to other module,
based on #78, leaving it as is, no follow-up issue is needed.
Regarding: Needs follow-up issue: helper function
#1774024: Create helper function to find release info for a project (follow-up issue to locale collect project information)
Regarding: Needs follow-up issue: standardize gettext, .po, po terminology
#1774032: standardize gettext, .po, po terminology (follow-up issue to locale collect project information)
This patch addresses #78
except, thinking about preg_match("/HEAD/"... still.
Also addresses #76 #79 and #80 about the $config = config(...) pattern.
Does not address #70 which I think is ok. I moved it into an uninstall function in the test module install file before I saw that comment.
Also addresses #71 and #72
Rest of things to address are @todo in the patch.
Comment #82
YesCT CreditAttribution: YesCT commentedcleaned up white space.
Comment #82.0
YesCT CreditAttribution: YesCT commentedImage added
Comment #83
YesCT CreditAttribution: YesCT commentedJust summarizing all the loose ends and loose thoughts before I give this issue a break.
Which columns should be specified?
What else should be checked?
Which columns should be specified?
Just marking the todo that links to the follow-up issue to make a helper function.
Is the HEAD just residual and really can be taken out?
What should these be changed to?
Is this the right type of compatibility string? Where can I find out?
Is this the right version release example? Where can I find out?
I tried to look these up and found some by doing a grep for status in the local.module. I thought that deleted, etc might be defined as int's maybe as a result of:
use Drupal\locale\LocaleLookup;
use Drupal\locale\LocaleConfigSubscriber;
but I didn't see it defined there. What are the possible values? Where is the reference?
Just marking this todo.
[edited: dreditor mistake/repeats]
Comment #84
xjmI'm mystified as to why all this code is in locale at all. Shouldn't we be using API from the update.module for all this version name parsing? Surely this is done already elsewhere.
Comment #85
xjmSorry, dreditor.
Comment #86
Sutharsan CreditAttribution: Sutharsan commented@YesCT
For a start, sites that do not run cron for longer time will fail. Core build in cron trigger fires daily. If the locale_project table is empty Locale module is probably freshly enabled but while Update module is disabled. It would be a bad first experience indeed. We could fall back to the system table which holds most of the data we need, except for the project name. It is not an easy task to extract the project name from the file and module name and the results may not be reliable. If we think this should be solved, make it a separate issue.
See http://drupal.org/node/542202#core
See http://drupal.org/node/467026
Probably a CVS legacy, need to check. This code was originally written for 6.x.
You are right, I did some reverse engineering on this to find these states. Did not search for the source (I think). I'm not sure which module(s) at d.o provides the XML data for update module.
@xjm
This code tries to do a version fallback, a thing that Update module does not provide. But possible reuse of code should be investigated.
Comment #87
Sutharsan CreditAttribution: Sutharsan commented2 x, done.
Comment #88
YesCT CreditAttribution: YesCT commented#1777106: Make check for out of date project update information more robust for sites that are not running cron regularly (follow-up) is the follow up issue about a more robust out-of-date project information check.
#1777126: Have locale and update module share/reuse code for version name parsing is the follow up issue to look into re-using code with the update module.
This patch addresses the examples.
Still left to track down are the source of the states, and the HEAD possible legacy code.
And:
+ // @todo: http://drupal.org/node/1627006#comment-6396658
+ // Can these be instantiated before getting to this function?
'%language' => isset($project->language) ? $project->language : '%language',
'%filename' => isset($project->filename) ? $project->filename : '%filename',
Comment #89
chx CreditAttribution: chx commentedI have no context, but the drupal.org packaging script does not use HEAD when writing out version information http://drupalcode.org/project/drupalorg.git/blob/refs/heads/7.x-3.x:/dru... Does this help anyone?
Comment #90
YesCT CreditAttribution: YesCT commentedAbout the grep for HEAD
I took out the grep for HEAD. Feedback is all supporting that that was legacy code, and we dont have projects with a HEAD version.
While looking into that, I got confused, which might mean that locale_translation_get_projects() needs some better comments, and that I'm not the one to write them, since I couldn't quite sort out what it was trying to accomplish.
(core/modules/locale/locale.compare.inc) locale_translation_get_projects() is only called from the test LocaleCompareTest.php That seemed strange to me.
In function locale_translation_get_projects() it seems to be checking to see if any projects need to be updated: if they have any newer releases. But it seems to be gathering the newer available release info only for projects that have an update status of not-fetched. Within in those not-fetched, it's only gathering the newer release info only for projects that are a dev version, or core. So, why not look at all projects to see if they have a newer recommended version?
status is tricky
. (skip to conclusion if you don't want to see my thought process and investigation)
status investigation
There is a project status which is I think either 1 = enabled or 0 = disabled
see line 84 in core/modules/locale/locale.compare.inc
There is project_status in core/modules/update/update.compare.inc (line 438)
which could be insecure / UPDATE_NOT_SECURE, unpublished, revoked / UPDATE_REVOKED, unsupported / UPDATE_NOT_SUPPORTED, not-fetched / UPDATE_NOT_FETCHED, published
Note core/modules/locale/locale.compare.inc line 107 references the not-fetched project_updates project_status (which is I think different from a project status: enabled or disabled).
core/modules/update/update.compare.inc line 46 defines values for project_status to be TRUE (for enabled projects). This is probably the 1 = enabled.
There are also translation status states with possible values: deleted, updated, created, rebuilt, error. Used in core/modules/locale/locale.module
But regarding status, I conclude
that the answer to webchick's question about the status values is that projects are either 1 = enabled or 0 = disabled.
todo about instantiating %language and %filename
this is regarding function locale_translation_build_server_pattern($project, $template) in core/modules/locale/locale.compare.inc
looks like locale_translation_build_server_pattern() used to be called from locale_translation_build_projects() (see patch 9) but I dont see it being called anymore.
the call is in patch #36 but not #38
about the instantiating, that code comes from http://api.drupalhelp.net/api/l10n_update/l10n_update.inc/function/l10n_...
So, I dont know.
This patch
Cleans up the comments, takes out the grep for HEAD and updates the info about status values.
Next steps
This is about the limit of what I can wrap my head around. I need someone else to pick this up from here, or I need some hand holding.
Comment #92
YesCT CreditAttribution: YesCT commented#90: convert-new-variables-to-cmi-1627006-90.patch queued for re-testing.
Comment #93
Gábor HojtsyI think this should either still be fixed in this patch, or the todo should be removed.
Looking at http://api.drupal.org/api/drupal/modules%21system%21system.install/funct..., it states it was introduced because multiple cache tables were needed (vs. just inlining the cache schema in the update function like we did). We can introduce a similar helper function for the D8 upgrade path with this schema and reuse here. The only question is the right name for that update function :)
However, there is no immediate need to reuse this, so we should put it at a visible place (system module again?) so it is visibly reusable.
I can take a quick stab at this.
Comment #94
Gábor HojtsyRetitled issue to be more precise as to what we are doing.
Attached new patch that introduces system_schema_cache_8001() as a utility function to get a cache table in the D8 upgrade. Not sure about the correct naming, should consult @catch about this. Otherwise I think the patch resolves what was requested.
Comment #95
Gábor HojtsyAsked for feedback on the naming from catch, he pointed out we need a name change to match the system update function where we changed the schema:
Given that outstanding concerns were resolved, this should be at RTBC now :)
Comment #97
Gábor Hojtsy#95: convert-new-variables-to-cmi-1627006-96.patch queued for re-testing.
Comment #99
Gábor HojtsyIt helps if we actually invoke the right function, not just rename it :)
Comment #100
Gábor HojtsySo then should be back on RTBC.
Comment #101
webchickWow, awesome! It looks like this resolves all of my feedback, and then some! :)
Committed and pushed to 8.x. Thanks!
Comment #102
Gábor HojtsyThanks all, this has been a long ride! Removing from sprint.
Comment #104
BerdirSorry for pinging everyone. I was looking for this issue to add a follow-up about the conversion of the cache_locale table to the key value store, see #1801962: [meta] Convert custom non-volatile cache-alike things to k/v store and it took me a while to find it because of the title, restoring that one.
Comment #104.0
Berdirupdating the summary to point to #83