From: Sam Reed Date: Thu, 12 Jan 2012 22:10:24 +0000 (+0000) Subject: Add $inputCsllback to sourceStream(), to return full lines back to the calling function X-Git-Tag: 1.31.0-rc.0~25321 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=0a0cff26aad4888a53fa566bd87c067b0abe921a;p=lhc%2Fweb%2Fwiklou.git Add $inputCsllback to sourceStream(), to return full lines back to the calling function Will be used soooon --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 5c186df3b3..2b0aef2672 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -3151,13 +3151,13 @@ abstract class DatabaseBase implements DatabaseType { * @param $lineCallback Callback: Optional function called before reading each line * @param $resultCallback Callback: Optional function called for each MySQL result * @param $fname String: Calling function name + * @param $inputCallback Callback: Optional function called for each complete line (ended with ;) sent * @return bool|string */ function sourceStream( $fp, $lineCallback = false, $resultCallback = false, - $fname = 'DatabaseBase::sourceStream' ) + $fname = 'DatabaseBase::sourceStream', $inputCallback = false ) { $cmd = ''; - $done = false; while ( !feof( $fp ) ) { if ( $lineCallback ) { @@ -3184,6 +3184,9 @@ abstract class DatabaseBase implements DatabaseType { if ( $done || feof( $fp ) ) { $cmd = $this->replaceVars( $cmd ); + if ( $inputCallback ) { + call_user_func( $resultCallback, $cmd ); + } $res = $this->query( $cmd, $fname ); if ( $resultCallback ) { @@ -3196,7 +3199,6 @@ abstract class DatabaseBase implements DatabaseType { } $cmd = ''; - $done = false; } }