Add option to set_timeout(0)
smk-ka - February 22, 2007 - 13:45
| Project: | IP to Country |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | sugree |
| Status: | closed |
Description
Now that you've integrated such a neat update page, wouldn't it be easy to add an option to disable the script timeout? This would be useful at least for those people that are not bound to safe_mode, but still suffer from timeouts when importing the whole database at once. It could be implemented as checkbox with a nice hint to safe_mode users that they can't use it.
--
Stefan Kudwien
www.unleashedmind.com

#1
Thanks again! I have solved this problem by providing a page for manually importing given range of ipdb.mysql in `admin/settings/ip2cc/update`. Please take a look and let me know if it helps. I will try to `set_time_limit(0)` in install script.
cvs diff: Diffing .
Index: ip2cc.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ip2cc/ip2cc.install,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 ip2cc.install
--- ip2cc.install 21 Feb 2007 07:41:44 -0000 1.1.2.5
+++ ip2cc.install 23 Feb 2007 07:50:13 -0000
@@ -33,10 +33,15 @@
) TYPE=MyISAM
/*!40100 DEFAULT CHARACTER SET utf8 */ ;");
- ip2cc_insert_batch('iso3166.mysql');
-/*
- ip2cc_insert_batch('ipdb.mysql');
-*/
+ ip2cc_batch_insert('iso3166.mysql');
+ if (!ini_get('safe_mode')) {
+ set_time_limit(0);
+ ip2cc_batch_insert('ipdb.mysql');
+ }
+ else {
+ drupal_set_message(t('Since you are in safe_mode, please manually import IP database by small range at <a href="admin/settings/ip2cc/update">update</a> page to prevent execution timeout issue.'));
+ }
+
break;
}
}
@@ -48,7 +53,7 @@
}
*/
-function ip2cc_insert_batch($filename) {
+function ip2cc_batch_insert($filename) {
if ($fd = fopen(drupal_get_path('module','ip2cc').'/'.$filename, 'r')) {
while (!feof($fd)) {
$line = fgets($fd);
#2
Nice done! And even simpler than what I've thought of... The only thing remaining is two warnings about empty queries, which the attached patch should fix.
#3
committed!
#4