[Fusionforge-commits] FusionForge branch 6.0 updated. v6.0-79-g369f176

Sylvain Beucler beuc-inria at libremir.placard.fr.eu.org
Fri Jun 19 17:18:36 CEST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, 6.0 has been updated
       via  369f17609e87bbb63fcc9e4c8cbb55f1dfdeeb04 (commit)
      from  3094df86c1f748b7b97734586fb85f9a5155af81 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=369f17609e87bbb63fcc9e4c8cbb55f1dfdeeb04

commit 369f17609e87bbb63fcc9e4c8cbb55f1dfdeeb04
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Fri Jun 19 17:06:56 2015 +0200

    activity: parse XML on the fly again, rather than in a temporary file (+ fix error handling)

diff --git a/src/plugins/scmsvn/common/SVNPlugin.class.php b/src/plugins/scmsvn/common/SVNPlugin.class.php
index cac89de..f218463 100644
--- a/src/plugins/scmsvn/common/SVNPlugin.class.php
+++ b/src/plugins/scmsvn/common/SVNPlugin.class.php
@@ -552,7 +552,7 @@ some control over it to the project's administrator.");
 	function activity($params) {
 		global $last_user, $last_time, $last_tag, $time_ok, $start_time, $end_time,
 			$adds, $deletes, $updates, $commits, $date_key,
-			$messages, $last_message, $times, $revisions, $users;
+			$messages, $last_message, $times, $revisions, $users, $xml_parser;
 		$group_id = $params['group'];
 		$project = group_get_object($group_id);
 		if (! $project->usesPlugin($this->name)) {
@@ -563,7 +563,11 @@ some control over it to the project's administrator.");
 			$start_time = $params['begin'];
 			$end_time = $params['end'];
 			
-			// Grab commit log
+			$xml_parser = xml_parser_create();
+			xml_set_element_handler($xml_parser, "SVNPluginStartElement", "SVNPluginEndElement");
+			xml_set_character_data_handler($xml_parser, "SVNPluginCharData");
+
+			// Grab&parse commit log
 			$protocol = forge_get_config('use_ssl', 'scmsvn') ? 'https://' : 'http://';
 			$u = session_get_user();
 			if ($project->enableAnonSCM())
@@ -575,11 +579,9 @@ some control over it to the project's administrator.");
 				.'?unix_group_name='.$project->getUnixName()
 				.'&begin='.$params['begin']
 				.'&end='.$params['end'];
-			$filename = tempnam('/tmp', 'svnlog');
-			$f = fopen($filename, 'w');
 			$ch = curl_init();
 			curl_setopt($ch, CURLOPT_URL, $script_url);
- 			curl_setopt($ch, CURLOPT_FILE, $f);
+			curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'curl2xml');
 			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 			curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']);  // for session validation
@@ -591,27 +593,15 @@ some control over it to the project's administrator.");
 				$this->setError(curl_error($ch));
 			}
 			curl_close($ch);
-			fclose($f); // flush buffer
-			$f = fopen($filename, 'r');
-			unlink($filename);
-						
-			$xml_parser = xml_parser_create();
-			xml_set_element_handler($xml_parser, "SVNPluginStartElement", "SVNPluginEndElement");
-			xml_set_character_data_handler($xml_parser, "SVNPluginCharData");
-			
-			while (!feof($f) && $data = fgets($f, 4096)) {
-				if (!xml_parse($xml_parser, $data, feof ($f))) {
-					debug("Unable to parse XML with error " .
-						  xml_error_string(xml_get_error_code($xml_parser)) .
-						  " on line " .
-						  xml_get_current_line_number($xml_parser));
-					fclose($f);
-					return false;
-					break;
-				}
-			}
+
+			// final checks
+			if (!xml_parse($xml_parser, '', true))
+				exit_error('Unable to parse XML with error '
+						   . xml_error_string(xml_get_error_code($xml_parser))
+						   . ' on line ' . xml_get_current_line_number($xml_parser),
+					'activity');
 			xml_parser_free($xml_parser);
-			fclose($f);
+
 			if ($adds > 0 || $updates > 0 || $commits > 0 || $deletes > 0) {
 				$i = 0;
 				foreach ($messages as $message) {
@@ -794,6 +784,16 @@ function SVNPluginEndElement($parser, $name) {
 	$last_tag = "";
 }
 
+function curl2xml($ch, $data) {
+	global $xml_parser;
+	if (!xml_parse($xml_parser, $data, false))
+		exit_error('Unable to parse XML with error '
+				   . xml_error_string(xml_get_error_code($xml_parser))
+				   . ' on line ' . xml_get_current_line_number($xml_parser),
+				   'activity');
+	return strlen($data);
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

-----------------------------------------------------------------------

Summary of changes:
 src/plugins/scmsvn/common/SVNPlugin.class.php | 50 +++++++++++++--------------
 1 file changed, 25 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list