Fix PHP notice when logging the result of a DNS blacklist check.
authorSkizzerz <skizzerz@gmail.com>
Wed, 4 Jun 2014 02:40:03 +0000 (21:40 -0500)
committerReedy <reedy@wikimedia.org>
Wed, 23 Sep 2015 13:28:01 +0000 (13:28 +0000)
When the array syntax is used for the DNS blacklist, PHP throws a notice about array to string
conversion. This change ensures that the correct string name is used regardless of what type of
blacklist entry is used.

Change-Id: I2511a8320474a02d8f321d04f005bb9d18fb15b3

includes/User.php

index 22c90cd..d57dfaa 100644 (file)
@@ -1694,6 +1694,7 @@ class User implements IDBAccessObject {
                        foreach ( (array)$bases as $base ) {
                                // Make hostname
                                // If we have an access key, use that too (ProjectHoneypot, etc.)
+                               $basename = $base;
                                if ( is_array( $base ) ) {
                                        if ( count( $base ) >= 2 ) {
                                                // Access key is 1, base URL is 0
@@ -1701,6 +1702,7 @@ class User implements IDBAccessObject {
                                        } else {
                                                $host = "$ipReversed.{$base[0]}";
                                        }
+                                       $basename = $base[0];
                                } else {
                                        $host = "$ipReversed.$base";
                                }
@@ -1709,11 +1711,11 @@ class User implements IDBAccessObject {
                                $ipList = gethostbynamel( $host );
 
                                if ( $ipList ) {
-                                       wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $base!" );
+                                       wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
                                        $found = true;
                                        break;
                                } else {
-                                       wfDebugLog( 'dnsblacklist', "Requested $host, not found in $base." );
+                                       wfDebugLog( 'dnsblacklist', "Requested $host, not found in $basename." );
                                }
                        }
                }