protected static function generalizeSQL( $sql ) {
		// This does the same as the regexp below would do, but in such a way
		// as to avoid crashing php on some large strings.
		# $sql = preg_replace( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql );

		$sql = str_replace( "\\\\", '', $sql );
		$sql = str_replace( "\\'", '', $sql );
		$sql = str_replace( "\\\"", '', $sql );
		$sql = preg_replace( "/'.*'/s", "'X'", $sql );
		$sql = preg_replace( '/".*"/s', "'X'", $sql );

		// All newlines, tabs, etc replaced by single space
		$sql = preg_replace( '/\s+/', ' ', $sql );

		// All numbers => N
		$sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
		$sql = preg_replace( '/-?\d+/s', 'N', $sql );

		return $sql;
	}
protected static function generalizeSQL( $sql ) {
		// This does the same as the regexp below would do, but in such a way
		// as to avoid crashing php on some large strings.
		# $sql = preg_replace( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql );

		$sql = str_replace( "\\\\", '', $sql );
		$sql = str_replace( "\\'", '', $sql );
		$sql = str_replace( "\\\"", '', $sql );
		$sql = preg_replace( "/'.*'/s", "'X'", $sql );
		$sql = preg_replace( '/".*"/s', "'X'", $sql );

		// All newlines, tabs, etc replaced by single space
		$sql = preg_replace( '/\s+/', ' ', $sql );

		// All numbers => N
		$sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
		$sql = preg_replace( '/-?\d+/s', 'N', $sql );

		return $sql;
	}
protected static function generalizeSQL ( $ sql ) { // This does the same as the regexp below would do, but in such a way // as to avoid crashing php on some large strings. # $sql = preg_replace( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql ); $ sql = str_replace ( "\\\\" , '' , $ sql ) ; $ sql = str_replace ( "\\'" , '' , $ sql ) ; $ sql = str_replace ( "\\\"" , '' , $ sql ) ; $ sql = preg_replace ( "/'.*'/s" , "'X'" , $ sql ) ; $ sql = preg_replace ( '/".*"/s' , "'X'" , $ sql ) ; // All newlines, tabs, etc replaced by single space $ sql = preg_replace ( '/\s+/' , ' ' , $ sql ) ; // All numbers => N $ sql = preg_replace ( '/-?\d+(,-?\d+)+/s' , 'N,...,N' , $ sql ) ; $ sql = preg_replace ( '/-?\d+/s' , 'N' , $ sql ) ; return $ sql ; }
Remove most variables from an SQL query and replace them with X or N markers.

Based on Database.php of mediawik-core 1.24-alpha

@param string $sql
@return string
Remove most variables from an SQL query and replace them with X or N markers .