Changeset 742
- Timestamp:
- 12/05/06 02:57:11 (2 years ago)
- Files:
-
- devel/includes.php (modified) (1 diff)
- devel/lib/cache (added)
- devel/lib/cache/engine.memcache.php (added)
- devel/lib/cache/engine.noop.php (added)
- devel/lib/cache/lib.php (added)
- devel/lib/datalib.php (modified) (11 diffs)
- devel/lib/setup.php (modified) (1 diff)
- devel/units/weblogs/weblogs_text_process.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/includes.php
r630 r742 21 21 * HELPER LIBRARIES 22 22 ****************************************************************************/ 23 24 // Load cache lib 25 require_once($CFG->dirroot.'lib/cache/lib.php'); 23 26 24 27 // Load datalib devel/lib/datalib.php
r708 r742 41 41 42 42 if ($result) { 43 // elggcache_purge(); // TODO - should probably be here, given function can do anything, but very inefficient 43 44 if ($feedback) { 44 45 notify(__gettext('Success'), 'notifysuccess'); … … 196 197 197 198 $METATABLES = $db->Metatables(); 199 elggcache_purge(); 198 200 199 201 return $success; … … 222 224 $signed='unsigned', $default='0', $null='not null', $after='') { 223 225 global $CFG, $db; 226 227 elggcache_cachepurgetype($table); 224 228 225 229 if (empty($oldfield) && !empty($field)) { //adding … … 435 439 436 440 $values = where_values_prepared($value1, $value2, $value3); 437 441 438 442 return record_exists_sql('SELECT * FROM '. $CFG->prefix . $table .' '. $select .' LIMIT 1',$values); 439 440 443 } 441 444 … … 597 600 598 601 global $CFG; 602 $trycache = false; 603 604 //just cache things by primary key for now 605 if ($field1 == "ident" && $value1 == intval($value1) && empty($field2) && empty($value2) && empty($field3) && empty($value3) && $fields == "*") { 606 $trycache = true; 607 $cacheval = elggcache_get($table, $field1 . "_" . intval($value1)); 608 if (!is_null($cacheval)) { 609 return $cacheval; 610 } else { 611 612 } 613 } 599 614 600 615 $select = where_clause_prepared($field1, $field2, $field3); … … 602 617 $values = where_values_prepared($value1, $value2, $value3); 603 618 604 return get_record_sql('SELECT '.$fields.' FROM '. $CFG->prefix . $table .' '. $select, $values); 619 $returnvalue = get_record_sql('SELECT '.$fields.' FROM '. $CFG->prefix . $table .' '. $select, $values); 620 621 if ($trycache) { 622 $setres = elggcache_set($table, $field1 . "_" . $value1, $returnvalue); 623 } 624 625 return $returnvalue; 605 626 } 606 627 … … 1166 1187 $select = where_clause_prepared($field1, $field2, $field3); 1167 1188 $values = where_values_prepared($newvalue, $value1, $value2, $value3); 1168 1189 1169 1190 $stmt = $db->Prepare('UPDATE '. $CFG->prefix . $table .' SET '. $newfield .' = ? '. $select); 1170 return $db->Execute($stmt,$values); 1191 $returnvalue = $db->Execute($stmt,$values); 1192 1193 if ($field1 == "ident") { 1194 // updating by primary key 1195 elggcache_delete($table, $field1 . "_" . $value1); 1196 } else { 1197 // sledgehammer :( 1198 elggcache_cachepurgetype($table); 1199 } 1200 1201 return $returnvalue; 1171 1202 } 1172 1203 … … 1195 1226 1196 1227 $stmt = $db->Prepare('DELETE FROM '. $CFG->prefix . $table .' '. $select); 1197 return $db->Execute($stmt,$values); 1228 $returnvalue = $db->Execute($stmt,$values); 1229 1230 if ($field1 == "ident") { 1231 // updating by primary key 1232 elggcache_delete($table, $field1 . "_" . $value1); 1233 } else { 1234 // sledgehammer :( 1235 elggcache_cachepurgetype($table); 1236 } 1237 1238 return $returnvalue; 1198 1239 } 1199 1240 … … 1225 1266 $result = $db->Execute('DELETE FROM '. $CFG->prefix . $table .' '. $select); 1226 1267 } 1268 1269 elggcache_cachepurgetype($table); 1270 1227 1271 return $result; 1228 1272 } … … 1269 1313 if ($nextval = (int)get_field_sql("SELECT NEXTVAL('{$CFG->prefix}{$table}_{$primarykey}_seq')")) { 1270 1314 $setfromseq = true; 1271 $dataobject->{$primarykey} = $nextval; 1315 $dataobject->{$primarykey} = $nextval; 1272 1316 } 1273 1317 } … … 1433 1477 $stmt = $db->Prepare('UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE ident = \''. $dataobject->ident .'\''); 1434 1478 if ($rs = $db->Execute($stmt,$ddd)) { 1479 elggcache_delete($table, "ident_" . $dataobject->ident); 1435 1480 return true; 1436 1481 } else { devel/lib/setup.php
r729 r742 14 14 15 15 // set up perf. 16 init_performance_info(); 16 init_performance_info(); 17 17 18 18 /// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others) devel/units/weblogs/weblogs_text_process.php
r716 r742 12 12 } 13 13 14 //check for mismatched <>s and force escaping if necessary 15 $numlt = substr_count($run_result, "<"); 16 $numgt = substr_count($run_result, ">"); 17 if ($numlt != $numgt) { 18 $run_result = htmlspecialchars($run_result, ENT_COMPAT, 'utf-8'); 19 } 20 21 // Videos 22 23 $functionbody = <<< END 14 $cachekey = sha1($addrelnofollow . "_" . $run_result); 15 if($cached = elggcache_get("weblogs_text_process:weblogs", $cachekey)) { 16 $run_result = $cached; 17 } else { 24 18 25 \$matches[1] = str_replace("&","&",\$matches[1]);26 return "<embed style=\"width:400px; height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"\$matches[1]\" />";27 19 20 21 22 //check for mismatched <>s and force escaping if necessary 23 $numlt = substr_count($run_result, "<"); 24 $numgt = substr_count($run_result, ">"); 25 if ($numlt != $numgt) { 26 $run_result = htmlspecialchars($run_result, ENT_COMPAT, 'utf-8'); 27 } 28 29 // Videos 30 31 $functionbody = <<< END 32 33 \$matches[1] = str_replace("&","&",\$matches[1]); 34 return "<embed style=\"width:400px; height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"\$matches[1]\" />"; 35 28 36 END; 29 30 // $run_result = preg_replace_callback("/\{\{video:([A-Za-z0-9\.\:\_\-\/\\?\=\&\+]+)\}\}/i",create_function('$matches',$functionbody),$run_result); 31 $run_result = preg_replace_callback("/\{\{video:(.+)\}\}/i",create_function('$matches',$functionbody),$run_result); 32 33 34 // URLs to links 35 $run_result = run("weblogs:html_activate_urls", $run_result); 36 37 // Remove the evil font tag 38 $run_result = preg_replace("/<font[^>]*>/i","",$run_result); 39 $run_result = preg_replace("/<\/font>/i","",$run_result); 40 41 // add rel="nofollow" to any links 42 if ($addrelnofollow) { 43 $run_result = preg_replace('/<a\s+([^>]*)\s+rel=/i', '<a $1 ', $run_result); 44 $run_result = preg_replace('/<a\s+/i', '<a rel="nofollow" ', $run_result); 45 } 46 47 // Text cutting 48 // Commented out for the moment as it seems to disproportionately increase 49 // memory usage / load 50 51 /* 52 global $individual; 53 54 if (!isset($individual) || $individual != 1) { 55 $run_result = preg_replace("/\{\{cut\}\}(.|\n)*(\{\{uncut\}\})?/","{{more}}",$run_result); 56 } else { 57 // $run_result = preg_replace("/\{\{cut\}\}/","",$run_result); 58 $run_result = str_replace("{{cut}}","",$run_result); 59 $run_result = str_replace("{{uncut}}","",$run_result); 60 } 61 */ 37 38 // $run_result = preg_replace_callback("/\{\{video:([A-Za-z0-9\.\:\_\-\/\\?\=\&\+]+)\}\}/i",create_function('$matches',$functionbody),$run_result); 39 $run_result = preg_replace_callback("/\{\{video:(.+)\}\}/i",create_function('$matches',$functionbody),$run_result); 40 41 42 // URLs to links 43 $run_result = run("weblogs:html_activate_urls", $run_result); 44 45 // Remove the evil font tag 46 $run_result = preg_replace("/<font[^>]*>/i","",$run_result); 47 $run_result = preg_replace("/<\/font>/i","",$run_result); 48 49 // add rel="nofollow" to any links 50 if ($addrelnofollow) { 51 $run_result = preg_replace('/<a\s+([^>]*)\s+rel=/i', '<a $1 ', $run_result); 52 $run_result = preg_replace('/<a\s+/i', '<a rel="nofollow" ', $run_result); 53 } 54 55 // Text cutting 56 // Commented out for the moment as it seems to disproportionately increase 57 // memory usage / load 58 59 /* 60 global $individual; 61 62 if (!isset($individual) || $individual != 1) { 63 $run_result = preg_replace("/\{\{cut\}\}(.|\n)*(\{\{uncut\}\})?/","{{more}}",$run_result); 64 } else { 65 // $run_result = preg_replace("/\{\{cut\}\}/","",$run_result); 66 $run_result = str_replace("{{cut}}","",$run_result); 67 $run_result = str_replace("{{uncut}}","",$run_result); 68 } 69 */ 70 71 $setresult = elggcache_set("weblogs_text_process:weblogs", $cachekey, $run_result); 72 } 62 73 } 63 74
