Skip to content
Permalink
Browse files

MDL-41146 Backup: backup_includes_files can leak memory

  • Loading branch information...
sammarshallou committed Aug 12, 2013
1 parent 50ff861 commit 07e720010a16ec3dcca51c8b5728ad5351188b6d
Showing with 23 additions and 2 deletions.
  1. +23 −2 backup/util/dbops/backup_controller_dbops.class.php
@@ -32,6 +32,16 @@
*/
abstract class backup_controller_dbops extends backup_dbops {
/**
* @var string Backup id for cached backup_includes_files result.
*/
protected static $includesfilescachebackupid;
/**
* @var int Cached backup_includes_files result
*/
protected static $includesfilescache;
/**
* Send one backup controller to DB
*
@@ -441,9 +451,20 @@ public static function backup_includes_mnet_remote_users($backupid) {
* @return int Indicates whether files should be included in backups.
*/
public static function backup_includes_files($backupid) {
// Load controller
// This function is called repeatedly in a backup with many files.
// Loading the controller is a nontrivial operation (in a large test
// backup it took 0.3 seconds), so we do a temporary cache of it within
// this request.
if (self::$includesfilescachebackupid === $backupid) {
return self::$includesfilescache;
}
// Load controller, get value, then destroy controller and return result.
self::$includesfilescachebackupid = $backupid;
$bc = self::load_controller($backupid);
return $bc->get_include_files();
self::$includesfilescache = $bc->get_include_files();
$bc->destroy();
return self::$includesfilescache;
}
/**

0 comments on commit 07e7200

Please sign in to comment.
You can’t perform that action at this time.