Page MenuHomePhabricator

phplint fails on paths containing a space
Closed, ResolvedPublic

Description

For changes to a file with the path 'Database scripts/Convenience/addcollection.php' jenkins generated the following commands for running lint, which are wrong:

php -l Database
Could not open input file: Database
php -l scripts/Convenience/addcollection.php
Could not open input file: scripts/Convenience/addcollection.php

https://gerrit.wikimedia.org/r/#/c/157125/
https://integration.wikimedia.org/ci/job/mwext-WikiLexicalData-lint/129/console

Event Timeline

Umherirrender raised the priority of this task from to Needs Triage.
Umherirrender updated the task description. (Show Details)
Umherirrender added subscribers: Umherirrender, hashar.

The Jenkins script (in integration/jenkins.git) runs:

/bin/git-changed-in-head php php5 inc phtml module install

Which yields modified files matching file extensions ending with the list of args given.

Then it is passed to xargs -n1 -t php -l

https://gerrit.wikimedia.org/r/#/c/157125/ modify a file that has a space in its name: Database scripts/Convenience/addcollection.php. The scripts yields

Database scripts/Convenience/addcollection.php
        ^
        \--- space!

Since xargs split per newline or space, it considers two arguments: Database and scripts/Convenience/addcollection.php.

xargs can be main to split based on null terminated string. git-changed-in-head internally uses git show to generate the list of files. Not sure how we can fix that, maybe replace newlines with null ?

Use the -z option. Many git commands (especially those meant for machine reading) support it. Including git-show as used in git-changed-in-head:

mediawiki-core
$ git show 5f25ba1 --name-only --diff-filter=ACM -m --first-parent --format=format: -z -- "*.php" "*.css" "*.js"
resources/Resources.php^@resources/lib/qunitjs/qunit.css^@resources/lib/qunitjs/qunit.js^@
Krinkle renamed this task from jenkins fails for calling lint on folders with a space in its name to phplint fails on paths containing a space.Feb 22 2015, 6:20 PM
Krinkle triaged this task as High priority.
Krinkle set Security to None.
Krinkle lowered the priority of this task from High to Medium.Mar 2 2015, 2:48 PM

jakub-onderka/php-parallel-lint is not affected I believe.

hashar claimed this task.

The PHP package jakub-onderka/php-parallel-lint is not affected. Any repo suffering from that issue should be migrated to use the composer entry point as described at https://www.mediawiki.org/wiki/Continuous_integration/Entry_points#PHP

A minimal boiler plate would be:

{
	"require-dev": {
		"jakub-onderka/php-parallel-lint": "0.9"
	},
	"scripts": {
		"test": [
			"parallel-lint . --exclude vendor"
		]
	}
}

Use the -z option.

This seems a trivial and appropriate solution.

The PHP package jakub-onderka/php-parallel-lint is not affected. Any repo suffering from that issue should be migrated to use the composer entry point

If I understand correctly, this message was intended as a "Declined", not a "Resolved". However, actually fixing the bug seems easier than working around it.

Yeah the bug has always been there and is not fixed. I dont want to fix it either in favor of having repositories to transition to use composer and jakub-onderka/php-parallel-lint.

If that needs assistance, I am happy to help though https://www.mediawiki.org/wiki/Continuous_integration/Entry_points#PHP should covers everything.

Change 330058 had a related patch set uploaded (by Umherirrender):
Add composer.json for php-parallel-lint

https://gerrit.wikimedia.org/r/330058

Change 330058 merged by jenkins-bot:
Add composer.json for php-parallel-lint

https://gerrit.wikimedia.org/r/330058