For various reasons I have noticed that several files independently compute the value of $IP. For example, maintenance/Command.inc and includes/WebStart.php both calculate its value. One would expect this value to be computed in one place only and used globally. The logical place is LocalSettings.php.
Sprinkling the computation of $IP all over the place is just looking for trouble. At some point the code used to make this computation may diverge and you will have bugs introduced. My first reaction to this problem was to wonder why these files didn't just require LocalSettings.php. However, since it is a fairly complex file doing so might not be desirable because: 1) there are values in LocalSettings.php that would interfere with values in these files, 2) there is some ordering problem that might occur, or 3) there are performance considerations.
If it isn't possible and or desirable to replace the distributed computation of $IP with require_once('LocalSettings.php'), then I suggest breaking LocalSettings into two parts, say LocalSettingsCore.php and LocalSettingsNonCore.php (I am sure someone can come up with better names). LocalSettingsCore.php would contain only those calculations and definitions that do not interfere with the core MW files. LocalSettingsNonCore.php would contain everything else now in LocalSettings.php. Obviously, the first candidate for inclusion in LocalSettingsCore.php is the computation of $IP. Once such a separation is carried out, files like maintenance/Command.inc and includes/WebStart.php can require_once('LocalSettingsCore.php') instead of independently computing $IP.