Page MenuHomePhabricator

Special:Version can warn about '#' comments in .git/config
Open, LowPublic

Description

I upgraded to MediaWiki wmf/1.20wmf10 and now Special:Version prints the following deprecation warning, one I don't recall seeing before, about my .git/config file in one of my extensions:

Deprecated: Comments starting with '#' are deprecated in  .../extensions/E3Experiments/.git//config on line 6 in .../includes/GitInfo.php on line 139".

I do have a # comment line in that config file. But '#' is a completely legit comment symbol in .git/config [1]. GitInfo.php invokes PHP's parse_ini_file() which in PHP 5.3 deprecates '#'.[2]

The workaround is to use ';' for comments in .git/config.

[1] http://www.kernel.org/pub/software/scm/git/docs/git-config.html#_syntax
[2] http://php.net/manual/en/function.parse-ini-file.php


Version: 1.20.x
Severity: minor

Details

Reference
bz39825

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:52 AM
bzimport set Reference to bz39825.

karun.84 wrote:

Normally the git files should not be a part of the extensions installation, and this is not an issue with Mediawiki. So closing as invalid.

(In reply to comment #1)

Normally the git files should not be a part of the extensions installation,

If someone follows instructions such as http://www.mediawiki.org/wiki/Download_from_Git to download an extension from git, they will in fact have a .git/config file. If they then make modifications to it, they can encounter this error when they visit Special:Version

and this is not an issue with Mediawiki.

This is a real, although minor, bug in the way GitInfo.php works. I don't mind if a developer (FWIW git blame suggests Alexandre Emsenhuber wrote the code) chooses to close this as WONTFIX, but it's not invalid. So reopening.

karun.84 wrote:

(In reply to comment #0)

I upgraded to MediaWiki wmf/1.20wmf10 and now Special:Version prints the
following deprecation warning, one I don't recall seeing before, about my
.git/config file in one of my extensions:

Deprecated: Comments starting with '#' are deprecated in

.../extensions/E3Experiments/.git//config on line 6 in
.../includes/GitInfo.php
on line 139".

I do have a # comment line in that config file. But '#' is a completely
legit
comment symbol in .git/config [1]. GitInfo.php invokes PHP's
parse_ini_file()
which in PHP 5.3 deprecates '#'.[2]

The workaround is to use ';' for comments in .git/config.

[1] http://www.kernel.org/pub/software/scm/git/docs/git-config.html#_syntax
[2] http://php.net/manual/en/function.parse-ini-file.php

Hello,
I am trying to reproduce this problem with PHP 5.4 and MediaWiki, but I dont get this error. Do you have any further details on how to reproduce it?

karun.84 wrote:

Unable to reproduce the problem, and no further response has been received.

Steps to Reproduce:

  1. Clone the mediawiki/core Git repo, and install MediaWiki
  2. Add the line "# testing 123" to .git/config
  3. In php.ini, set error_reporting = E_ALL
  4. Visit Special:Version

Actual Results:

I get this error message:

Deprecated: Comments starting with '#' are deprecated in /home/ki/Projects/mediawiki/core/.git/config on line 27 in /home/ki/Projects/mediawiki/core/includes/GitInfo.php on line 173

Expected Results:

No error message should appear. Comments beginning with '#' are not
described as "deprecated" in the git-config(1) manual page.

https://www.kernel.org/pub/software/scm/git/docs/git-config.html#_syntax

karun.84 wrote:

As we use the php_parse_ini method to read the git configuration file, we always throw a deprecation error if a # is encountered.

Due to this change to the PHP method in 5.3.0.

5.3.0 Added optional scanner_mode parameter. Single quotes may now be used around variable assignments. Hash marks (#) may no longer be used as comments and will throw a deprecation warning if used.

Therefore we need to look at some other method of parsing the file, or ignoring this error.