Skip to content

Commit fc3a703

Browse files
authored
Remove INET_ATON WordPress dependency (WordPress#485)
## Summary Removes the driver's dependency on WordPress's `absint()` helper in `INET_ATON()`. The replacement uses native PHP logic, allowing the Composer package to run in standalone PHP applications. A regression test covers the function through the public PDO-compatible API. The package test suite and coding-standards check pass. ## Why The standalone Composer package autoloads the driver outside WordPress. Calling `INET_ATON()` previously failed because `absint()` is not available in standalone PHP applications.
1 parent 189322a commit fc3a703

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/mysql-on-sqlite/src/sqlite/class-wp-sqlite-pdo-user-defined-functions.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ public function inet_ntoa( $num ) {
833833
* @return int long integer
834834
*/
835835
public function inet_aton( $addr ) {
836-
return absint( ip2long( $addr ) );
836+
return abs( (int) ip2long( $addr ) );
837837
}
838838

839839
/**

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_PDO_API_Tests.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ public function test_query(): void {
405405
}
406406
}
407407

408+
public function test_inet_aton(): void {
409+
$result = $this->driver->query( "SELECT INET_ATON('1.2.3.4')" );
410+
411+
$this->assertSame( '16909060', $result->fetchColumn() );
412+
}
413+
408414
public function test_statement_query_string(): void {
409415
$query = 'SELECT 1 AS value';
410416
$stmt = $this->driver->query( $query );

0 commit comments

Comments
 (0)