Php short tags

bradymiller wrote on Saturday, August 18, 2012:

Hi,

is anybody up for fixing all the php short tags in the codebase. This was actually dealt with about a year ago, but somehow some code with short tags seems to have gotten back into the codebase. Also may make sense to ensure the form scripts aren’t producing forms with short tags. This is important because having short tags off has been the default action of php for some time and is a common gotcha for new OpenEMR installations.

-brady
OpenEMR

fndtn357 wrote on Sunday, August 19, 2012:

I’ll be glad to. Sorry I have been out of the loop for a bit.

~ James

fndtn357 wrote on Sunday, August 19, 2012:

done : https://github.com/fndtn357/openemr

bradymiller wrote on Sunday, August 19, 2012:

Hi James,

There’s a lot of whitespace changes (ie. pseudochanges) that will dirty up the repo history (especially prevalent in the <?echo cleanup commit). Is there a way to not include that.

thanks,
-brady
OpenEMR

fndtn357 wrote on Sunday, August 19, 2012:

Sure, I’ll roll back the <?php echo to <?echo   Is this what you want?

bradymiller wrote on Sunday, August 19, 2012:

Hi,

Didn’t mean that. Check out the commit:
http://github.com/fndtn357/openemr/commit/06239d0fe5ad9a4fbcb36f32812202d3d3c394ab
(note a lot more lines are being modified than the ones that are being converted; for example, the first modified line)
Note how more smaller the commit gets if don’t show the whitespace changes:
http://github.com/fndtn357/openemr/commit/06239d0fe5ad9a4fbcb36f32812202d3d3c394ab?w=0

I think your conversion script is also removing space at the end of lines, perhaps.

-brady
OpenEMR

fndtn357 wrote on Sunday, August 19, 2012:

I am using a simple find and replace function within PhpStorm. I am not aware of removing anything else. I’ll check again. I do have Php CodeSniffer being applied as a work.

bradymiller wrote on Sunday, August 19, 2012:

It should be fine then. I’ll just use some git magic to remove the whitespace changes.
-brady

fndtn357 wrote on Sunday, August 19, 2012:

Maybe you can tell me how to do that so I can learn some “git magic” as well ?

fndtn357 wrote on Sunday, August 19, 2012:

just a diff and … I see -ignore-space-at-eol Ignore changes in whitespace at EOL.
-b, -ignore-space-change Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
-w, -ignore-all-space Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
and this
Add ?w=1 to the URL to see the diff with whitespace ignored.

fndtn357 wrote on Sunday, August 19, 2012:

should I recommit it with a something set for ignoring it in my pre-commit hook

bradymiller wrote on Sunday, August 19, 2012:

Hi James,

Here’s what I did:

# Go to my local updated master branch
git checkout master
# Create a working branch
git checkout -b php-short-tags_1
# Bring your commits into the working branch
git cherry-pick 06239d0fe5ad9a4fbcb36f32812202d3d3c394ab
git cherry-pick 88da5839dbd803399bdbafea6ac384c76b830703
# Check out another working branch (from master)
git checkout master
git checkout -b php-short-tags_2
# Make a patch file via diff command with the -w switch
# (the diff is between master and the first working branch with your commits in it)
git diff -w master..php-short-tags_1 > patch_file
# Now gonna cheat and not use git
patch -p 1 < patch_file
rm patch_file
# Now gonna make the new commit
git commit -a --author="fndtn357 <fndtn357@gmail.com>"
(create the commit message and save it)
# Now push the branch with the new commit to github
git push origin php-short-tags_2

Here’s the created branch on github:
http://github.com/bradymiller/openemr/commits/php-short-tags_2

Thanks for doing this. Gonna test it a little and then commit it to sourceforge (both master and rel-411)

-brady
OpenEMR

bradymiller wrote on Sunday, August 19, 2012:

Hi,

Committed above and also cleaned the codebase up a bit more with the following additional commit:
https://github.com/openemr/openemr/commit/7b5eb5bb5c59e9901edee105195d9c6788c50472

Now the codebase (both master and rel-411) is completely free of php short tags :slight_smile:
A nice way to check is the following command:

grep -R "<?[^px]" /var/www/openemr/ | less

-brady
OpenEMR

bradymiller wrote on Sunday, August 19, 2012:

Also,

Forgot to discuss the ?w=0 thing. This is basically just something you can use when looking a commits in github (Tony discovered this trick), which makes code reviewing on code with lots of whitespace changes much easier (it’s basically github’s way to do a git diff -w).

-brady

fndtn357 wrote on Monday, August 20, 2012:

Thanks for taking the time to help me out with git-tricks! I really appreciate it, Brady.

~ James