Installer translation was introduced in Drupal 5. The brand new installer only had database setup features back then, but now we have a much more powerful install system:

- it does reuse functions from the big Drupal API (form validation functions, password confirm widgets)
- it does use JavaScript to build up some components
- it is much more extensible, and people will use other parts of the API in installer scripts

Installer localization in Drupal 5 was built around the idea that we can contain the parts of code used in the installer, but with the above changes, this is practically not possible anymore. We can still identify interface text *only used* in the installer (we mark these with st()), and interface text always also used in the installer (we mark these with $t = get_t() and then $t()). But we cannot wrap every possible string in Drupal into $t() instead of t() just so they are usable in the installer.

A good thing about the Drupal 6 installer still is that it is very controlled up to the point when the configuration form is displayed. That's when hell breaks loose, a full bootstrap is done, form elements are reused, etc. But that is also after the required modules are all enabled, so we can have locale module with its database fully set up.

(1) This basically means that the translation imports should move to before the configuration form. So part of this patch is moving the locale import batch to before the config form, and stepping forward to the config form after that. This means that stuff reused from Drupal in the config form will magically be translatable. Previous state machine was:

database - configure - locale-import - locale-batch - finished - done

The new state order is:

database - locale-import - locale-batch - configure - finished - done

So basically, the locale import comes earlier, but is otherwise the same.

(2) This patch also includes notice fixes for the JavaScript file generator, which also happen in install time. So the default language and the language saved when locale_add_language() is called now has the javascript property.

(3) I intentionally left some debug code in t(), so you see how I debugged t() usage in the installer. That is how I realized that _form_validate() and theme_form_element() should use $t, as these two functions are the ones displaying interface text and used before the database is set up. Unfortunately we cannot do better to enable proper install form localization (with the required stars and error messages on required for elements), but to use $t here.

(4) Last, I also included a drupal_init_language() call at the start, which sets up the global $language. This is for functions still calling t() before the language system is properly initialized. The only such functions are all hook_schema() implementations for default modules, as those call t() when they set up their schema right after the database setup but before the strings imports. These are not stored in the database and will not display on the page(), so are fine with t()-ing in English. On pages, where a full bootstrap is done (anything after the database config form), the language will be overwritten properly later in install.php.

There are still two problems which this patch does not solve:

(A) The JavaScript localizer tries to create the JavaScript files repeatedly, but it is not possible, as the "files" folder is not there. I think we should make this mandatory as the CSS and JS preprocessors will also put their files there. Even if we silence the JS localizer to not create its files in the installer, it will show up errors in the watchdog and on screen once Drupal is set up, as it will try to create the files anyway later. So IMHO the "files" folder should be required to be in place and writable to start the installation.

(B) Now that the import is moved before the config form and the profile forms, any module enabled on the config form or through the profile forms will not have its localization imported. A core use case is the update module. So we should abstract the locale import a bit, remember what was imported first and import the remaining stuff at the end, before the final screens.

Anyways, there is already some meat here to discuss, so let's start!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

BTW I toyed with the idea to only use t() after the database is set up and strings are imported, but ended up reverting to st(), as

- it is still a good idea to be consistent in what we do in install scripts, so people don't need to think about whether that code runs after or before DB setup
- and also these st()-ed strings will not clutter up the runtime database (although this means a small amount of strings really)

meba’s picture

Subscribing. Will test tomorrow.

meba’s picture

I patched and started to install. After choosing Czech language, "Database configuration" appears immediatelly. So I wonder:
- Was the import so fast I even hadn't a chance to notice it?
- Did it even work as expected?

Gábor Hojtsy’s picture

We can only import *after* database setup as explained above, but before the site configuration screen, that's the change. There is nowhere to import before the database is set up.

JirkaRybka’s picture

FileSize
17.78 KB

OK, I finally found a bit of time. (This is *big* for testing, took me quite a while to set up a reasonable install profile, translations etc.)

Basically, the patch works fine for me. Applied with just a tiny offset, everything works, nothing broken. I read through the initial explanation here, and through the code, and it all seems reasonable to me (within the limits of my limited experience).

The functionality: I see that the points A. and B. are probably valid, but I didn't have any trouble with that, given that I didn't enable modules that late. JavaScript didn't throw any errors too, which I don't understand though (there's no 'files' directory). I played quite a bit with adding translations into my testing .po files (strategic sample-strings of different nature, not a full translation), and didn't find anything untranslatable past the language selection page, so this seems good too. The strings for final pages are sprawled between installer and regular translation files, but given the re-using of some regular Drupal strings, this is correct IMO.

My proposals: (And forgive me for being a bit broader, I understand this issue as a bit of general install.php cleanup)

-- While going through the code, I noticed quite inaccurate (previously existing) code comment for st() function, so correcting in the attached patch.

-- The default install profile had quite a bit of inaccurate comments inside. Especially, it mentioned the exact order of the tasks, and explicitly required $task to be set to 'locale-import' at the end of profile tasks - neither is true anymore with this patch.
I corrected the listed order, but I feel really uneasy to have hardcoded 'locale-import' (needs to be changed to 'finished' now) as the end-of-custom-tasks flag. This is a new API as far as I can see, which should be a bit more abstracting - otherwise any change in the tasks order in future might break install profiles or else introduce fake task names or the like.
So I added a placeholder (invisible to user) task 'profile-finished', which seems to me a reasonable solution. Install profiles should advance to this one, which then only just fire next task (whichever it may be in future versions). I know we're in freeze, but I hope this doesn't apply to the new installer profiles so strictly. No one seem to use it yet.

-- I was figuring out how to set up a (testing) multi-step install profile my first time - and got stuck/confused again in the same comment block: There's very little about the return HTML from hook_profile_tasks(), perhaps a bit misleading too. In fact, once we move to any custom task, the return HTML is no more optional. It's truly required, and must contain a link/form-action with correct URL back to the page, otherwise it'll end with just a white screen and no way to continue.
So I reworded that description a bit, although I doubt this is final version. For one thing, I'm really unsure about the suggestion to variable_set('install_task', 'new_task') - seems to me like some cruft. install.php itself doesn't do forms that way, and once the HTML is returned, install.php will set the variable for us anyway. But I can't be so sure, so I left that bit untouched for now.

-- The above means, that every single profile with custom pages needs the URL (like www.example.com/somedirectory/install.php?profile=default&locale=en ) for providing a link to proceed. So I propose to give it as a second parameter to hook_profile_tasks(), to avoid having the global variables and path building hardcoded repeatedly in profiles (possibly buggy, too).

-- I also noticed that, unless drupal_set_title() used in the profile, first custom page shows the title "Configure site" inherited from previous step. Although it might be fitting in some cases, it's a leak from previous step, so I cleared it for consistency. Profiles may/should set own titles for new pages, not relying on leaks.

-- If we're pursuing maximum of the installer being translated, I propose to add a possibility to bypass the language selection entirely, from the install profile. The "Choose language" page is always English, and in some cases makes little sense. Look at the projects for 5.x install profiles: Hebrew, French, German, Japanese, Russian (I found even Czech on Drupal.cz site) - half of the available profiles are language-focused. If I choose German profile for instance, why would I choose to install in English?
While having only just one profile bypasses the profile selection page, language can't do the same. There's always English plus the other one, never just one language, and no way to tell in the code whether the profile is language-oriented.
So I propose to have a setting possible in the profile, to inject language selection and so skip the UI page. If I have a specialized Drupal package with Czech installation profile and translations, it'll start in Czech straight away, without annoying English selections. If I have a multilingual / config focused profile, It'll start with the selection, just like now.
I just added a new possible array key to hook_profile_details() for this. It was somehow possible already via hacking global variables at the begin of profile file, but my version is probably cleaner, and also have a check for validity (so if the pre-selected language is malformed or missing .po file, language selection re-appears showing which other options are left).

Another question is how all the files (install profile, translations) will get into place, but that's another issue (packaging policy - I had quite a difficulty to merge downloaded Czech translations into Drupal release, the 'unpack tarball into Drupal root' suggestion didn't work: It created a subdirectory 'archive_name-FILES', and I had to merge translations to all module's directories manually. So if local Drupal communities choose to maintain already-merged tarballs, big +1 from me. And - my point here - then it might contain only single profile (default removed), and so start installation in the local language straight away. This works for me with the patch below and reasonably prepared package.)

Attaching a patch with all the above included (and t() debug code gone, sorry). Feel free to choose how much is able to go into 6.x and into this issue.

Gábor Hojtsy’s picture

Great, thanks for contributing.

- Language selection less localized profiles seem to be a very good usability enhancement.
- We would need some task anyway to pass on to between "configure" and "finished", as we *need* to run through the imports of remaining modules anyway.
- You don't need a contrib use case for running the locale import again, core itself allows you to disable or enable the update module on the configure form. It is preferable to do the second pass import after the profile though, as it allows the profile to turn on modules on demand.
- Passing on the URL for the profile tasks function is a small API improvement, which we could add IMHO.

I will look into this more deeply later this weekend.

JirkaRybka’s picture

A few thoughts to: (A) - JavaScript

The JavaScript localizer (as well as JS preprocessor, luckily disabled by default) gets most probably called via theme_maintenance_page() and drupal_get_js(), which I discovered in update.php issue: http://drupal.org/node/179143 - My patch in there introduces a global flag usable for external scripts to suppress dangerous hook invokes and the like.
I wonder whether that flag is also suitable for install.php: Once we have modules installed, do we *need* their hook_init(), hook_exit(), and JS preprocessing to fire, or do we rather *fear* it? We probably don't want the JS stuff, but I'm a bit unsure about the rest. (Already discovered cases are Statistics module logging page visits and blogapi module injecting RSD link, not to mention nearly all modules adding their CSS, so I'm inclined to say that we don't want these hooks to fire.)

As for the files directory, my opinion is that we should distribute it just like sites/all, i.e. included into the tarball and containing a simple README.txt inside, to explain what to do with it. I believe most sites are going to have their files there anyway, so requiring the user to create directory manually as soon as the first error message pops up is not too nice. Sure, he'll still need to make it writable, but that's no different from the config file (consistency really helps to avoid confusion here, I think).

Another question is whether the files directory should be better placed somewhere inside sites tree, but that's definitely out of scope for this issue. It's discussed at http://drupal.org/node/98824 and related. But simply just having the (default, for multisite setups just installer-temporary) files directory inside tarball for now might be helpful for us here.

Gábor Hojtsy’s picture

The JS stuff used in the installer still does drupal_add_js('setting', ... t()...) (in effect JS string translation moved to PHP) to overcome the perceived impossibility of using JS translation in the installer. But frankly, JS translation is only not possible in the installer, because the files directory is not there. But as soon as the installer finishes, and the user visits the site, JS translation should work (JS stuff will run on settings pages and elsewhere in Drupal core itself, which requires JS translation). But it will not work still, as the files directory is still not set up. So the localization experience will be broken (now Drupal also throws warnings all around, when trying to parse JS files but not saving the translation files). That said, we need the files directory right after the installation, so we could just as well have it at the beginning (checked in requirements).

http://factoryjoe.pbwiki.com/FeedbackForDrupal6 also includes negative notes on the big red error box because of the missing files directory, which Drupal outputs after being installed. So we can fix Drupal being "in error" right after a standard installation here.

JirkaRybka’s picture

FileSize
23 KB

OK, what about this one:

- Added files directory. Includes a README.txt file with suggestions.

- Changed the check in system.install, to work on install too, resulting in files directory being required by the installer. (The patch seems big here, but it's mostly just indentation change. However, there's a separate description for install case, to make the wording a bit sensible, and to avoid one url() call.)

- Modified the requirements error page in install.php, to show another title and exclude version info if necessary, to accomplish sensibly looking output in the 'files' directory case.

So now, Drupal shows *no* errors on files directory, the status report is nicely green on fresh install. (Apart from cron never run, discussed elsewhere, I believe - and settings.php unprotected (sites/default writable), which is probably unsolvable, given that Apache doesn't own the directory.)

What I don't understand though, is why the sites/default writable requirement doesn't show on the "verify requirements" page too. It shows on database settings page.

Gábor Hojtsy’s picture

Assigned: Gábor Hojtsy » Unassigned
FileSize
7.33 KB

Well, now committed the obvious and well tested parts of the patch:

- adding the JS keys to language objects, where missing
- documenting st() better
- using get_t() in two pre-database setup functions

This makes the patch smaller and leaves the to be tested and discussed pieces intact, so we can focus on them more. I'd also love to have the files directory issue broken out to another critical D6 issue, so we can discuss and fix it on its own (it seems to be much easier to get people to jump on patch reviews, if localization is not in connection with the patch :). Here we still need to work on generalizing the string import batch building code and reusing it at profile-finished, so this patch gets bigger, while already covering too much.

The committed patch attached. If you update your working copy, I think the patch will only get smaller, you should not have any conflicts as I committed a subset of the patch.

Gábor Hojtsy’s picture

I am breaking out the requirements part of the patch to another issue, will be back with the issue number soon.

Gábor Hojtsy’s picture

OK, broken out the files directory issue to http://drupal.org/node/191310 and will soon get a shortened patch rolled here with stuff not committed yet and not moved to the files issue.

Gábor Hojtsy’s picture

So, here is the patch without the files directory issue and without the previously committed parts. I modified the code slightly from JirkaRybka's latest incarnation though:

- removed "cancelling" of the "Configure site" title as I think this could be suitable for configure wizard profiles, which is a valid use case, so why not make their life easier... but documented this in the profile task function docs
- removed commented language key on the profile info array, we don't do these kind of sample codes inline anywhere in Drupal AFAIK
- also added one little whitespace fix and fixed some grammar in comments

Otherwise the patch is not new, so it still suffers from not doing a locale import after the profile tasks are done (profile-finished state), so the modules enabled since the original database/profile setup don't get their translations imported yet. Also attached a tarball with a Hungarian D6 translation package, which can be used for testing. This should be easy to uncompress to a D6 installation, and files should fall into place (file extension was modified in upload, remember to set it back when downloaded).

wmostrey’s picture

Patch applies cleanly, good work all!

Gábor Hojtsy’s picture

OK, here is the update which gets this patch functionally complete as far as I am concerned. In this patch we have a locale import batch right after the database import and before the configure and profile screens and we have a locale batch right after the profile screens (if any) and before the finished screen.

To reiterate the point, we need two batches because Drupal APIs are used even on the built-in "configure site" page, which require t() to be available with full functionality. (The concrete example is the password form element). And we can be pretty sure that install profiles will use Drupal APIs to build the profile screens. Since after the database imports, we are already fully bootstrapped, there is no reason not to support t(), but we need to import the data first. That's what the patch does.

Then again, the configure screen allows users to enable update module as they wish. So it was not enabled before, and no translation was imported for it, which means we need to import some stuff again before the installer is finished. Install profiles might also enable modules depending on direct or indirect user choices, so we need to have the second import done before the installer is done. That's what the new patch includes too. We remember the components (modules, themes) we already imported translations for and only import new active components translations at the end. If enabling the update module, this makes for another .po file import at the end of the installer by default.

I think this patch is feature complete as far as locale imports go. Testing and any other kind of input welcome. Also attached an image shot with the above Hungarian package while the first import batch was running. Note the two "import translations" items in the task list.

JirkaRybka’s picture

I was hoping to give it a look today, but my time went elsewhere, so just quick comments:

- I would rather add the second import only if needed, not from the start (to be discussed)

- I would add it with other title, probably "Import additional translations", otherwise the two identical phases are giving an impression of a nasty bug occuring (definitely, as far as I can tell)

- Tasks order is mentioned in default.profile comments, needs update (can wait until we're done with substantial changes)

- My own little TODO: I need to try a multistep install profile with a form. I suspect that there's no need to variable_set() from profile function, in which case that comment chunk should go.

- The page title "Configure site" is only set if the profile function is called as a fall-through in the same page request as previous phase, i.e. only the first time (not on page reloads!). So the title should be either removed (as I suggested previously), or set explicitly and always, or required to be set from the profile. Otherwise it'll disappear if the user hits reload.

- I'm not entirely sure if I like the idea of two different callbacks for batch ending, with installer phases hardcoded inside locale.inc (not too obvious place to look, if patching install.php in future). Can we rather have a single callback, and variable_set() the installer phase to be used there? We're going to remove these temporary variables anyway...

Gábor Hojtsy’s picture

- I am not sure that jumping in the import in the middle is a good idea.
- I was unsure about this. Unfortunately all the other titles are slick and short. I agree that it looks somewhat buggy now.
- Indeed.
- Go, go :)
- Can we find another more specific place to set the title then, instead of unsetting it later. Unsetting looks very hackish to me.
- Well, we can do variable set, yes.

JirkaRybka’s picture

Attaching a new patch (also removing offset).

- Titles for the two imports changed to: 'Set up translations' and 'Finish translations'. Feel free to further change, I'm still unsure...

- The title "Configure site" now set on two different places, one explicitly for the form-page, other explicitly as default for profile-tasks. The initially existing one is now moved to a place only executed if really going to print that page, so no more "leaks".

- The comments in default.profile further changed:
* List of installer tasks updated, and expanded to show ALL the tasks. From install.php perspective, the initial tasks are entirely different, but if a profile developer should see some list, then a full list. From this perspective, the initial tasks are no different than 'configure' - already executed ones simply.
* The bit about displaying forms and using variable_set() completely rewritten. The originally suggested way with variable_set(), avoiding drupal_get_form(), and pasting hackish code from install.php is complicated and entirely not necessary. I tried it, and unless I'm missing something, drupal_get_form() works pretty fine here, we only just need to avoid redirecting; it results in much shorter and cleaner code.
variable_set() is still useful for remembering other data between custom tasks, though.
* Also included some pitfalls I encountered, specifically pages re-loading reminder, and removing temporary variables.

- I'm unsure whether this allows for some simplification in install.php itself or not, but I let it alone for now.

Attaching also my testing profile file (tweaked file extension as usual) as a proof of concept - enforces Czech language (won't work unless some cs.po supplied), and adds three tasks - two simple forms, and a page showing entered values. Perhaps the forms bit might be turned into an example snippet for some documentation page, too. (?)

- Nothing done about variable_set() the batch ending phase, yet...

Along the way, I tested a bit more, and I can confirm that the translations are imported correctly, including the additional part (i.e. update module).

Gábor Hojtsy’s picture

First, and foremost, it is a great idea to improve the documentation here. Indeed, since the configure site screen, Drupal is fully bootstrapped (even in the installer tasks) and working, so there should be no reason not to use the normal FormAPI functions. Some comments on the code:

- I said it is acceptable as a side effect to have the 'Configure site' title fall through, but I don't think it is a requirement to preset this title for the profile tasks... Require them to set their own title then, it is cleaner, now that we don't have the fall through. (This should also be removed from the phpdoc).
- The database task title uses "Setup" not "Set up", so the translations title should use the same word too.
- "Any temporary variables must be removed" is imho "Any temporary variables should be removed", as it is not a showstopper if temp variables are not removed, it "just" leaves some junk. "Must" means otherwise it is broken, "should" means it is a strong suggestion.

Related note, but does not affect the patch:

- The example profile looks good, but better variable_set()/_get() names would make it better understandable... This kind of example profile would be great for people developing their custom profiles, so after some polish, we should really keep this and commit to contrib/docs. In fact I only understood how it works after I read the docs on the default profile :)

Good work!

JirkaRybka’s picture

The example profile *definitely* needs *a lot of* polish, currently it's a combination of old version default.profile, Czech profile for 5.x, quick hacks, and no code comments updated. I didn't mean it to go anywhere in this form, except some testing and your quick look for reference. ;)

I hope to look into the rest this weekend. Generally I agree with all the above, but time is pressing on me :-/

JirkaRybka’s picture

FileSize
16.63 KB

(My personal schedule always changes...) Now attaching a new patch, with the following changes:

- No page title pre-set for custom tasks (per #19)
- "Setup translations" title (per #19)
- documentation fixes in default.profile ("should" and the title, per #19)

- Temporary variable for locale batches (already processed files) renamed, because I believe the convention requires us to have "install" as the first part here, rather than "locale". This is installer temporary variable.

- Batch ending callbacks sorted out. Finally, I decided not to do variable_set() (as I suggested earlier). I just moved these callback functions to install.php, because they are only used there, and contain installer-specific data (names of installer tasks). This is also a bit of cleanup of locale.inc (although it's not much of code, really), and consistency of having all the occurences of installer task names in the same file.

I would also like to draw attention to one theoretical security problem, which I discovered along the way and fixed with this patch:

With the previous patches, the function locale_batch_by_language() had '_locale_batch_installer_initial_finished' as default callback, with that function really present in runtime code. So, if anyone (contrib) wanted to use the function, for whatever reason without ending callback, it will work as expected (seemingly), and it may be unnoticed that a grave security hole was opened as a side effect: The default installer callback actually used, setting the installer task variable silently back to "configure". Then, any anonymous user will be able to access install.php, and set up a new UID1 user through a nice simple UI, overwriting the previously existing UID1, and so gaining full control over the site, kicking the true owner out at the same time. (I tested, this really worked!)

Now, locale_batch_by_language() have no default callback, and all installer variable_set() are inside install.php only, so this problem no more exists.

JirkaRybka’s picture

FileSize
20.63 KB

The installer is tempting for cleanup nearly everywhere I look...

Attaching a new patch:

- I really don't see, why the Site configuration form was done in such a strange way. drupal_get_form() works pretty fine there, as well as inside custom profile-tasks. I even see, that drupal_get_form() is already successfully used for all three pre-database forms! (profile, language, database settings)
Because the existing code inside install.php was A LOT of a FAPI hack (I had really a difficulty to understand how it works), I tried to implement the simple way from my testing profile here. And it seems to work pretty fine; only thing I can't test (without extensive Apache config research at least) is clean URL's check (no clean URL's on my system, entirely), but I think it should work too, as two other JS things on the same form are OK.
* This bit definitely needs some review. The patch file, unfortunately, mixed lines a bit, so better see the change in final un-/patched install.php.

- Quite a few code comments improvements, including:
* Added missing (minimal) comments to several functions. There were functions separated only by a single blank line from each other, not very nice for quick scanning the file visually.
* Fixed a mention of "profile-custom" install task, which doesn't exist. Some cruft, probably.
* Removed a comment on install_configure_form(), about adding the installer task to $_GET data - really a nonsense, as far as I see, probably another cruft.

Now, I'm done with all the things I wanted to check and do in the installer, except that I don't know how the 'files' directory issue is playing together with this. Do we still need to translate JS inline? My install seems to do no js translation/parsing on/after install, still, although 'files' is there OK.

JirkaRybka’s picture

I wondered, where that hackish FAPI code came from, in the first place... Did some searching:

It came from http://drupal.org/node/141637 along with the initial commit of the 'Configure site' form, and it's history is unclear even there:
- Initially, it was (a bit more simple) in the patch, inside default.profile
- In #2, the author removed it in favor of drupal_get_form() just like we're doing here, stating that his previous problems were elsewhere.
- It stayed so until #16, first the old way commented out, then removed entirely. Seems no-one mentioned any problems on the following 8 patches.
- Then, #28 moved the form into install.php (BTW - along with the nonsense comment I'm removing now; seems like this patch was not that much carefully reviewed back then), re-introducing the hackish "form breaking". The author only said Because of the way FAPI is structured, there is a small bit of extra work to do multi-step forms without using $_SESSION glue., although I see no really multi-step form here, and it seems no-one ever mentioned this bit ever since. Also note, that this was the *old* FAPI back then.
- Shortly after commit, http://drupal.org/node/138706 updated the code to new FAPI3 ( #88 ) without much of a notice. It's only now, that it got so complicated and hackish, and it seems that no one re-considered whether it's still necessary, unless I'm missing something.

Conclusion: I'm unable to find any sensible reasoning or previous attention given to that bit of code, and given that drupal_get_form() works fine for me, I assume it was really just cruft.

JirkaRybka’s picture

Title: beta 3 breaker: several parts of the installer are not translatable » beta 3 breaker: Installer translation and other cleanup

Hopefully better title...

JirkaRybka’s picture

FileSize
23.51 KB

More ideas came overnight...

- Further changed the submit-detection on site configuration form. In the previous patch I used a new temporary variable, being afraid to touch the existing data variables (site name, mail...). The reason was that I saw the form being pre-populated from these variables, which meant there might be some values already in them, breaking my submit-detection.

But after more research it turned out, that there are NEVER pre-populated values, that code (setting defaults from variables on the form) is just another cruft from early phases of http://drupal.org/node/141637 , when the installer was intended to be $_GET driven. The only use case of pre-populated values now is an attack after 'install_task' variable blown away somehow (see #21), revealing the email to attacker additionally (and yes, it worked this way when I tested...) We don't want this.

So I removed the variable-based defaults, used the data variables for submit detection (simplification), and added a check for pre-existing values, which is an indicator of installer re-run and therefore of possible attack. With this change, installer no more allows for UID1 resetting, even if the task variable got blown somehow (after pointless profile/language selections, it'll show "already installed" page now). Now, you'll need to blow THREE variables to open that security hole, which is unlikely to happen due to just a bug somewhere.

- I came across an interesting hook_form_alter() feature allowing the profile to alter the site configuration form. This is quite nice, but I have cleanups there too:
* The call was incompatible to standard hook_form_alter() specification. Although this is a special case, called outside FAPI, for one special form only, and so there's no $form_state yet, I think it's still correct for consistency to provide the parameter. Empty array() added.
* This should be also shown in the default profile somehow IMO. A nice use case here is the default site name in the form, which may be well profile-driven; so I moved the default 'Drupal' site name to the default profile, demonstrating the use of hook_form_alter() at the same time.

Attaching the new patch, and digging further (JS translations are not working for me, mysteriously, yet)

JirkaRybka’s picture

Ah, now I see... The JS translations were not saved only just because my testing .po's didn't have any translations for JS strings yet (5.x files, just tweaked a bit). Silly mistake.

Now it works, although I'm unsure about st()ing the clean URL strings, given that t() should contain a translation anyway (double translations for the same).

So I guess I'm done here (again ;) and hopefully it's true now)

Gábor Hojtsy’s picture

This is all looking great (I'll look into this in more detail later). But, let's slow down a bit and stabilize / test what is there, leaving cleanup for other issues. Adding more cleanup stuff endangers the fixes which absolutely need to be committed. Anyway, good stuff.

JirkaRybka’s picture

Fair enough. The trouble is, that I discover things along the way, too related - but I already thought about splitting this patch. Anyway, I already stopped here. Going to open a new issue soon for some less related things :)

Gábor Hojtsy’s picture

Status: Needs review » Fixed

OK, tested this extensively with both localized (with language pack) installs (with or without update module) and with an English install. All seems to work nicely. Also read through the patch line by line (fixed a few code comment typos) and I think everything is fine. The awkward forms API usage was introduced long ago, when Drupal was not yet fully bootstrapped for the configuration form, but now that it is, there is no reason not to use the cleaner approach.

Thanks for working on this, now committed.

It would be great to have the example profile polished a bit and committed to contrib/docs.

keith.smith’s picture

Status: Fixed » Needs review
FileSize
869 bytes

One very very small followup patch that I just noticed while reading this patch:

The patch introduced two steps labeled "Setup database" and "Setup translations". Or maybe these were already there, I didn't really go back and look.

Anyway, technically, that should be "Set up database" or "Set up translations", or, alternatively, "Database setup" and "Translations setup."

The former looks kinda' weird and the latter is not parallel with the other options.

So the attached patch changes these to "Configure database", and "Configure translations".

Gábor Hojtsy’s picture

Status: Needs review » Fixed

Eh, let's discuss this elsewhere (open a new issue please). I'll reply there.

JirkaRybka’s picture

The example installer profile now polished with extra code comments, and submitted to http://drupal.org/node/196928 for future use in documentation.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.