@@ -766,13 +766,11 @@ public function error_insert(array $error_array): void
766766 $ this ->connection ,
767767 'INSERT INTO ' . $ this ->prefix . 'log_errors
768768 (id_member, log_time, ip, url, message, session, error_type, file, line, backtrace)
769- VALUES( ?, ?, unhex (?), ?, ?, ?, ?, ?, ?, ?) ' ,
769+ VALUES( ?, ?, INET6_ATON (?), ?, ?, ?, ?, ?, ?, ?) ' ,
770770 );
771771 }
772772
773- if (filter_var ($ error_array ['ip ' ], FILTER_VALIDATE_IP ) !== false ) {
774- $ error_array ['ip ' ] = bin2hex (inet_pton ($ error_array ['ip ' ]));
775- } else {
773+ if (filter_var ($ error_array ['ip ' ], FILTER_VALIDATE_IP ) === false ) {
776774 $ error_array ['ip ' ] = null ;
777775 }
778776
@@ -2808,8 +2806,7 @@ protected function replacement__callback(array $matches, array $db_values, objec
28082806 $ this ->error_backtrace ('Wrong value type sent to the database. IPv4 or IPv6 expected. ( ' . $ matches [2 ] . ') ' , '' , E_USER_ERROR , __FILE__ , __LINE__ );
28092807 }
28102808
2811- // We don't use the native support of mysql > 5.6.2
2812- return \sprintf ('unhex( \'%1$s \') ' , $ ip ->toHex ());
2809+ return \sprintf ('INET6_ATON( \'%1$s \') ' , $ ip );
28132810
28142811 case 'array_inet ' :
28152812 if (\is_array ($ replacement )) {
@@ -2828,7 +2825,7 @@ protected function replacement__callback(array $matches, array $db_values, objec
28282825 $ this ->error_backtrace ('Wrong value type sent to the database. IPv4 or IPv6 expected. ( ' . $ matches [2 ] . ') ' , '' , E_USER_ERROR , __FILE__ , __LINE__ );
28292826 }
28302827
2831- $ replacement [$ key ] = \sprintf ('unhex ( \'%1$s \') ' , $ ip-> toHex () );
2828+ $ replacement [$ key ] = \sprintf ('INET6_ATON ( \'%1$s \') ' , $ ip );
28322829 }
28332830
28342831 return implode (', ' , $ replacement );
0 commit comments