]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_14_STABLE: Fixing handling of empty memory_limit for PHP without...
authormartinlanghoff <martinlanghoff>
Sat, 20 Nov 2004 10:38:43 +0000 (10:38 +0000)
committermartinlanghoff <martinlanghoff>
Sat, 20 Nov 2004 10:38:43 +0000 (10:38 +0000)
auth/ldap/auth_ldap_sync_users.php [new file with mode: 0755]
lib/moodlelib.php

diff --git a/auth/ldap/auth_ldap_sync_users.php b/auth/ldap/auth_ldap_sync_users.php
new file mode 100755 (executable)
index 0000000..1696b12
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/** auth_ldap_sync_users.php
+ * 
+ * This script is meant to be called from a cronjob to sync moodle with the LDAP 
+ * backend in those setups where the LDAP backend acts as 'master'.
+ * 
+ * Recommended cron entry:
+ * # 5 minutes past 4am
+ * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
+ * 
+ * Notes: 
+ *   - If you have a large number of users, you may want to raise the memory limits
+ *     by passing -d momory_limit=256M
+ *   - For debugging & better logging, you are encouraged to use in the command line:
+ *     -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
+ *     
+ * Performance notes:
+ * We have optimized it as best as we could for Postgres and mySQL, with 27K students
+ * we have seen this take 10 minutes. 
+ *    
+ */
+
+
+if(!empty($_SERVER['GATEWAY_INTERFACE'])){
+    error_log("should not be called from apache!");
+    exit;
+}
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
+
+require_once($CFG->dirroot.'/course/lib.php');
+require_once($CFG->dirroot.'/lib/blocklib.php');
+require_once($CFG->dirroot.'/mod/resource/lib.php');
+require_once($CFG->dirroot.'/auth/ldap/lib.php');
+require_once($CFG->dirroot.'/mod/forum/lib.php');
+$CFG->debug=10;
+auth_sync_users(1000, true  );
+
+?>
\ No newline at end of file
index 215481fbed81afc8830cb8fffbb14a3c14be3f0a..0506d0370a7c5158e44736cede80e2a2fe8586d9 100644 (file)
@@ -3254,9 +3254,19 @@ function raise_memory_limit ($newlimit) {
         return false;
     }
     
-    $cur = return_bytes(@ini_get('memory_limit'));
-    $new = return_bytes($newlimit);
+    $cur = @ini_get('memory_limit');
+    if (empty($cur)) {
+        // if php is compiled without --enable-memory-limits
+        // apparently memory_limit is set to ''
+        $cur=0;
+    } else {
+        if ($cur == -1){
+            return true; // unlimited mem!
+        }
+      $cur = return_bytes($cur);
+    }
     
+    $new = return_bytes($newlimit);
     if ($new > $cur) {
         ini_set('memory_limit', $newlimit);
         return true;