Skip to content

Commit 123d53f

Browse files
committed
Improved project user detection.
1 parent ccdf89e commit 123d53f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,15 @@ function main($request, $compiler_config)
117117

118118
// Log the names of the project files and the libraries used in it.
119119
if ($format != "autocomplete") {
120-
$user_id = "";
121-
$sketch_id = "";
122-
$req_elements = array();
123-
$req_elements[] = "Files: ";
120+
$user_id = $sketch_id = "null";
121+
$req_elements = array("Files: ");
122+
124123
foreach ($request["files"] as $file) {
125124
$req_elements[] = $file["filename"];
126125
if (strpos($file["filename"], ".txt") !== false) {
127-
if (strpos($file["filename"], "user_") !== false)
128-
$user_id = str_replace(".txt", "", str_replace("user_", "", $file["filename"]));
129-
else
130-
$sketch_id = str_replace(".txt", "", $file["filename"]);
126+
if (preg_match('/(?<=user_)[\d]+/', $file['filename'], $match)) $user_id = $match[0];
127+
if (preg_match('/(?<=project_)[\d]+/', $file['filename'], $match)) $sketch_id = $match[0];
128+
131129
}
132130
}
133131

0 commit comments

Comments
 (0)