- global $IP, $wgCacheDirectory;
- if ( $wgCacheDirectory ) {
- // Transform path to git repo to something we can safely embed in a filename
- $repoName = $repoDir;
- if ( strpos( $repoName, $IP ) === 0 ) {
+ global $IP, $wgGitInfoCacheDirectory;
+
+ if ( $wgGitInfoCacheDirectory ) {
+ // Convert both $IP and $repoDir to canonical paths to protect against
+ // $IP having changed between the settings files and runtime.
+ $realIP = realpath( $IP );
+ $repoName = realpath( $repoDir );
+ if ( $repoName === false ) {
+ // Unit tests use fake path names
+ $repoName = $repoDir;
+ }
+ if ( strpos( $repoName, $realIP ) === 0 ) {