/** * Generates a lock filename using an MD5 hash of the `$id` and * `$path`. Lock files are given a .lock extension * * @param string $id * The name of the lock file to be obfuscated * @param string $path * The path the lock should be written * @return string */ private static function __generateLockFileName($id, $path = null) { // This function is called from all others, so it is a good point to initialize Mutex handling. if (!is_array(self::$lockFiles)) { self::$lockFiles = array(); register_shutdown_function(array(__CLASS__, '__shutdownCleanup')); } if (is_null($path)) { $path = sys_get_temp_dir(); } // Use realpath, because shutdown function may operate in different working directory. // So we need to be sure that path is absolute. return rtrim(realpath($path), '/') . '/' . md5($id) . '.lock'; }