Hi, regarding to autolocale, i would like to ask if we have any option to determine language was correctly imported or not. Too many users on drupal.cz reports either their memory or time limit is exceeded or no error is printed and import was unsucessful (= less than 100% was imported). We need some fallback or determine a way how to speed up the process (cron?)
Jakub
100% was imported). We need some fallback or determine a way how to speed up the process (cron?)
I was thinking about options and so far i have found two, both BAD. Ideas please?
In both cases, we determine files needed to be imported and we store their names into database/session/whatever. Pseudo-table: id | filename | lang 1 | modules/node/po/node.cs.po | cs 2 | modules/forum/po/forum.cs.po | cs 3 | modules/comment/... | cs
Current approach is: foreach ($files as $file) { // import file }
One enhancement should be: @ini_set('max_execution_time', 120); // or different number @ini_set('memory_limit_or_whatever_the_name_is', '64M'); // or different number This is forbidden on many hosts, but should help sometimes. AFAIK PHP5.2 or Suhosin patch allows setting longer execution time in some cases.
First VERY BAD solution may be using cron for importing files. One file per cron run. Very slow, very ineffective, very confusing. I don't like it
Second solution may be: (Assuming /import.php is the script)
import.php: // pseudocode list($id, $file) = db_query("SELECT id, filename FROM pseudotable ORDER BY id ASC LIMIT 1"); if (!$id) { Header('Location: ...?ok-imported'); } import_file($file); remove_file_from_db($id); Header('Location: /import.php');
This will redirect and loop import.php until all files are processed. This is BAD solution, but can't think of better one now. Anyone?
Jakub
This will redirect and loop import.php until all files are processed. This is BAD solution, but can't think of better one now. Anyone?
Aah, one more came to me after sending this. We can track execution time when doing autoimport. Something like: $time_taken = 0; $avg = average time needed to import one translation file. computed by us? is it reliable? foreach($files as $file) { $start = microtime(); import_file($file); $stop = microtime(); $time_taken += $stop-$start; if ($time_taken > ($avg_computed - $treshold)) { // print a warning "There is not enough time to import all // translation files. You should <a href="/import-manually-now">run import manually again</a>" } }
This assumes that: 1) We can track modules already imported and not yet imported 2) We are able to determine average time needed to import translation file. One can compare $time_taken to max_execution_time but this is really non-deterministic, one more file can be over limit and you can do nothing...Should be simplier if everybody is using PHP5 with exceptions.
nothing...Should be simplier if everybody is using PHP5 with exceptions.
A little monologue, but too typical for me. I am getting ideas in FIFO :-)
A register_shutdown_function() is called even if Fatal error: max execution time...is thrown. This works for PHP4 too. We can at least print a message to user (not whole page, because register_shutdown_function() is called during the shutdown)
On Sun, 4 Feb 2007, Jakub Suchy wrote:
100% was imported). We need some fallback or determine a way how to speed up the process (cron?)
I was thinking about options and so far i have found two, both BAD. Ideas please?
In both cases, we determine files needed to be imported and we store their names into database/session/whatever.
[...]
This will redirect and loop import.php until all files are processed. This is BAD solution, but can't think of better one now. Anyone?
This is indeed a very real problem. See the update.php solution. It does what you describe. First it collects the updates need to be run, then it pushes that into the session. Then runs update to update, going through the array in the session. It also displays a nice progress bar, so that you see where you are, and that something is happening.
So a solution for such things is already in Drupal. The interesting question is whether we can utilize it somehow, or just need to copy code. This is a problem in install time and later when you go into automatic update. Both places would be better with a step-by-step import process, where memory and runtime is not that big a consern. The update process already solves this a great deal, so no need to reinvent the weel. We just need to reuse of steal code :)
Gabor
This is indeed a very real problem. See the update.php solution. It does what you describe. First it collects the updates need to be run, then it pushes that into the session. Then runs update to update, going through the array in the session. It also displays a nice progress bar, so that you see where you are, and that something is happening.
So a solution for such things is already in Drupal. The interesting question is whether we can utilize it somehow, or just need to copy code. This is a problem in install time and later when you go into automatic update. Both places would be better with a step-by-step import process, where memory and runtime is not that big a consern. The update process already solves this a great deal, so no need to reinvent the weel. We just need to reuse of steal code :)
And it actually works, i never noticed it's done using <meta refresh> :-) (or redirects at all)
Jakub