Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-10760

In pre-commit git hook, syntax error is thrown, but is not specifically described

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.11-RC1
    • Component/s: None
    • Labels:
      None
    • Environment:
      PHP 5.4.0, Ubuntu 11.10

      Description

      When committing with the pre-commit git hook enabled, I got a message saying that it found syntax error(s) but no actual description of the error(s). Yes, I could test to find it evetually, but the point of this hook is to show the errors, so that needs to be fixed.

        Activity

        Hide
        Oleg Oleg [X] (Inactive) added a comment -

        Could you run php -l <file> for each changed file and post the results here please.

        Show
        Oleg Oleg [X] (Inactive) added a comment - Could you run php -l <file> for each changed file and post the results here please.
        Hide
        Oleg Oleg [X] (Inactive) added a comment -

        (17:19:53) imkingdavid: php -l phpBB/includes/acp/acp_users.php
        (17:19:53) imkingdavid: PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in phpBB/includes/acp/acp_users.php on line 119
        (17:19:53) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php

        Show
        Oleg Oleg [X] (Inactive) added a comment - (17:19:53) imkingdavid: php -l phpBB/includes/acp/acp_users.php (17:19:53) imkingdavid: PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in phpBB/includes/acp/acp_users.php on line 119 (17:19:53) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php
        Hide
        imkingdavid David King added a comment -

        david@ubuntu:~/Documents/www/repos/phpbb3$ git commit -m '[feature/userdelete] test'
        -e PHP Syntax check failed:
        david@ubuntu:~/Documents/www/repos/phpbb3$ php -l phpBB/includes/acp/acp_users.php
        PHP Parse error: syntax error, unexpected ''user_delete_pending'' (T_CONSTANT_ENCAPSED_STRING), expecting '(' in phpBB/includes/acp/acp_users.php on line 119
        Errors parsing phpBB/includes/acp/acp_users.php

        Show
        imkingdavid David King added a comment - david@ubuntu:~/Documents/www/repos/phpbb3$ git commit -m ' [feature/userdelete] test' -e PHP Syntax check failed: david@ubuntu:~/Documents/www/repos/phpbb3$ php -l phpBB/includes/acp/acp_users.php PHP Parse error: syntax error, unexpected ''user_delete_pending'' (T_CONSTANT_ENCAPSED_STRING), expecting '(' in phpBB/includes/acp/acp_users.php on line 119 Errors parsing phpBB/includes/acp/acp_users.php
        Hide
        Oleg Oleg [X] (Inactive) added a comment -

        We need to redirect stderr to stdout as display errors can be set to stderr. php 5.4 apparently changes the output to prefix syntax error with php. And echo -e should only be used if echo understands -e.

        Show
        Oleg Oleg [X] (Inactive) added a comment - We need to redirect stderr to stdout as display errors can be set to stderr. php 5.4 apparently changes the output to prefix syntax error with php. And echo -e should only be used if echo understands -e.
        Hide
        Oleg Oleg [X] (Inactive) added a comment -

        (17:14:19) nn-: imkingdavid: http://tracker.phpbb.com/browse/PHPBB3-10760?focusedCommentId=37520#comment-37520
        (17:16:45) imkingdavid: each changed file? https://github.com/imkingdavid/phpbb3/compare/develop...feature/userdelete there's 28 of them
        (17:16:48) imkingdavid: well less of just php files
        (17:17:25) imkingdavid: but let me switch branches, just a minute
        (17:19:33) imkingdavid: anyway, I randomly decided to test includes/acp/acp_users.php and it came up with the error when I did the php -l command
        (17:19:53) imkingdavid: php -l phpBB/includes/acp/acp_users.php
        (17:19:53) imkingdavid: PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in phpBB/includes/acp/acp_users.php on line 119
        (17:19:53) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php
        (17:20:02) imkingdavid: nn-: ^
        (17:21:33) nn-: hm
        (17:22:00) nn-: and this produces the message you included in the description from the hook?
        (17:22:26) imkingdavid: when I run the hook, all I got was the thing saying that there was an error
        (17:22:35) imkingdavid: i did not get the description of the error as is here
        (17:22:40) imkingdavid: btw I just fixed it and pushed it
        (17:22:47) nn-: I got the following message: "-e PHP Syntax Error:" but no actual description of the errors.
        (17:23:27) imkingdavid: or well, -e "PHP Syntax check failed:";
        (17:23:47) imkingdavid: i typed the "php syntax error" from memory and was of course wrong
        (17:23:48) imkingdavid: but yes
        (17:23:52) imkingdavid: that was all I was told
        (17:24:02) nn-: if you don't know you say you don't know
        (17:24:03) imkingdavid: i disabled the hook in order to push my commit
        (17:24:05) nn-: you don't make stuff up
        (17:24:23) nn-: or you don't have it or whatever
        (17:25:29) nn-: please take out of the ticket everything that is not an exact copy paste from a terminal
        (17:26:27) imkingdavid: nn-: k done
        (17:26:55) Hahi left the room (quit: Quit: Page closed).
        (17:27:07) nn-: ok
        (17:27:23) nn-: now if you can reproduce that message again please include it and correspoding php -l output
        (17:27:39) nn-: the corresponding part is important
        (17:28:46) imkingdavid: okay added a comment
        (17:30:21) nn-: thanks
        (17:30:26) nn-: so your echo doesn't have -e then
        (17:30:50) nn-: and your php might output errors to stderr
        (17:30:53) nn-: can you do
        (17:30:59) nn-: php -l file >/dev/null
        (17:31:25) imkingdavid: doesn't appear to do anything
        (17:31:51) unknownbliss [~unknownbl@phpbb/website/Unknown-Bliss] entered the room.
        (17:31:51) mode (+o unknownbliss) by ChanServ
        (17:33:44) Sam-T [Sam-T@phpbb/leader/sam] entered the room.
        (17:33:44) nn-: hmm
        (17:34:02) nn-: php -l file 2>/dev/null; echo $?
        (17:35:24) imkingdavid: i'm supposed to replace file with the path to the file?
        (17:35:30) nn-: yes
        (17:36:08) imkingdavid: david@ubuntu:~/Documents/www/repos/phpbb3$ php -l phpBB/includes/acp/acp_users.php 2>/dev/null; echo $
        (17:36:08) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php
        (17:36:08) imkingdavid: $
        (17:37:10) nn-: ? in $? was part of the command
        (17:37:22) nn-: you need to run the whole thing again
        (17:37:54) nn-: and now the two outputs you gave me do not match
        (17:38:06) nn-: (17:30:59) nn-: php -l file >/dev/null
        (17:38:12) nn-: did you substitute file with the path?
        (17:39:49) nn-: apparently new york lowered taxes on "middle income new yorkers"
        (17:39:59) imkingdavid: php -l phpBB/includes/acp/acp_users.php >/dev/null
        (17:39:59) imkingdavid: PHP Parse error: syntax error, unexpected ''user_delete_pending'' (T_CONSTANT_ENCAPSED_STRING), expecting '(' in phpBB/includes/acp/acp_users.php on line 119
        (17:40:08) nn-: for some reason i am not too happy to read that
        (17:40:35) imkingdavid: php -l phpBB/includes/acp/acp_users.php 2>/dev/null; echo $?
        (17:40:35) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php
        (17:40:35) imkingdavid: 255
        (17:40:39) hiddenpearls left the room (quit: Quit: Leaving.).
        (17:40:50) nn-: right
        (17:40:55) nn-: parse error is printed on stderr
        (17:40:57) t_backoff [~t_backoff@unaffiliated/t-backoff/x-5423102] entered the room.
        (17:41:34) nn-: and last grep filters out stdout output
        (17:41:54) nn-: on line 67 of the hook
        (17:42:01) nn-: replace 2>/dev/null with 2>&1
        (17:43:16) marc1706 left the room (quit: Read error: Connection reset by peer).
        (17:44:01) nn-: i am confused how your echo does not have -e
        (17:44:08) Derky left the room (quit: ).
        (17:44:18) nn-: even my echo accepts -e, though man echo does not list it
        (17:44:28) nn-: ah, because that is zsh
        (17:44:36) nn-: which means you are using dash
        (17:45:19) bantu: interesting
        (17:45:29) bantu: confirmed with dash
        (17:45:32) bantu: working with bash
        (17:45:34) nn-: built-in vs binary
        (17:45:43) nn-: luckily i think we can just test for it
        (17:45:55) nn-: if test $(echo -e foo) = foo ...
        (17:46:33) nn-: and i have php 5.4 so i can test the stderr thing
        (17:46:39) imkingdavid: btw I changed the 2>/dev/null with 2>&1 in the hook and tried again and it didn't change anything
        (17:46:43) imkingdavid: if that makes a difference
        (17:47:56) nn-: hmm really
        (17:49:11) nn-: are you sure?
        (17:49:31) nn-: oh that's right
        (17:49:38) nn-: on line 80
        (17:49:51) nn-: replace ^Parse with ^(PHP )?Parse
        (17:49:57) nn-: and grep with egrep
        (17:50:41) imkingdavid: much better
        (17:51:41) nn-: if you want you can pr both changes together
        (17:51:44) nn-: i mean in one pr
        (17:51:59) imkingdavid: in the feature/userdelete pr?
        (17:52:02) nn-: actually no
        (17:52:05) nn-: no definitely not there
        (17:52:10) nn-: i should fix echo -e thing
        (17:52:27) nn-: well you still can pr the two changes you made
        (17:52:41) nn-: also the pr should be against olympus obviously

        Show
        Oleg Oleg [X] (Inactive) added a comment - (17:14:19) nn-: imkingdavid: http://tracker.phpbb.com/browse/PHPBB3-10760?focusedCommentId=37520#comment-37520 (17:16:45) imkingdavid: each changed file? https://github.com/imkingdavid/phpbb3/compare/develop...feature/userdelete there's 28 of them (17:16:48) imkingdavid: well less of just php files (17:17:25) imkingdavid: but let me switch branches, just a minute (17:19:33) imkingdavid: anyway, I randomly decided to test includes/acp/acp_users.php and it came up with the error when I did the php -l command (17:19:53) imkingdavid: php -l phpBB/includes/acp/acp_users.php (17:19:53) imkingdavid: PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in phpBB/includes/acp/acp_users.php on line 119 (17:19:53) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php (17:20:02) imkingdavid: nn-: ^ (17:21:33) nn-: hm (17:22:00) nn-: and this produces the message you included in the description from the hook? (17:22:26) imkingdavid: when I run the hook, all I got was the thing saying that there was an error (17:22:35) imkingdavid: i did not get the description of the error as is here (17:22:40) imkingdavid: btw I just fixed it and pushed it (17:22:47) nn-: I got the following message: "-e PHP Syntax Error:" but no actual description of the errors. (17:23:27) imkingdavid: or well, -e "PHP Syntax check failed:"; (17:23:47) imkingdavid: i typed the "php syntax error" from memory and was of course wrong (17:23:48) imkingdavid: but yes (17:23:52) imkingdavid: that was all I was told (17:24:02) nn-: if you don't know you say you don't know (17:24:03) imkingdavid: i disabled the hook in order to push my commit (17:24:05) nn-: you don't make stuff up (17:24:23) nn-: or you don't have it or whatever (17:25:29) nn-: please take out of the ticket everything that is not an exact copy paste from a terminal (17:26:27) imkingdavid: nn-: k done (17:26:55) Hahi left the room (quit: Quit: Page closed). (17:27:07) nn-: ok (17:27:23) nn-: now if you can reproduce that message again please include it and correspoding php -l output (17:27:39) nn-: the corresponding part is important (17:28:46) imkingdavid: okay added a comment (17:30:21) nn-: thanks (17:30:26) nn-: so your echo doesn't have -e then (17:30:50) nn-: and your php might output errors to stderr (17:30:53) nn-: can you do (17:30:59) nn-: php -l file >/dev/null (17:31:25) imkingdavid: doesn't appear to do anything (17:31:51) unknownbliss [~unknownbl@phpbb/website/Unknown-Bliss] entered the room. (17:31:51) mode (+o unknownbliss) by ChanServ (17:33:44) Sam-T [Sam-T@phpbb/leader/sam] entered the room. (17:33:44) nn-: hmm (17:34:02) nn-: php -l file 2>/dev/null; echo $? (17:35:24) imkingdavid: i'm supposed to replace file with the path to the file? (17:35:30) nn-: yes (17:36:08) imkingdavid: david@ubuntu:~/Documents/www/repos/phpbb3$ php -l phpBB/includes/acp/acp_users.php 2>/dev/null; echo $ (17:36:08) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php (17:36:08) imkingdavid: $ (17:37:10) nn-: ? in $? was part of the command (17:37:22) nn-: you need to run the whole thing again (17:37:54) nn-: and now the two outputs you gave me do not match (17:38:06) nn-: (17:30:59) nn-: php -l file >/dev/null (17:38:12) nn-: did you substitute file with the path? (17:39:49) nn-: apparently new york lowered taxes on "middle income new yorkers" (17:39:59) imkingdavid: php -l phpBB/includes/acp/acp_users.php >/dev/null (17:39:59) imkingdavid: PHP Parse error: syntax error, unexpected ''user_delete_pending'' (T_CONSTANT_ENCAPSED_STRING), expecting '(' in phpBB/includes/acp/acp_users.php on line 119 (17:40:08) nn-: for some reason i am not too happy to read that (17:40:35) imkingdavid: php -l phpBB/includes/acp/acp_users.php 2>/dev/null; echo $? (17:40:35) imkingdavid: Errors parsing phpBB/includes/acp/acp_users.php (17:40:35) imkingdavid: 255 (17:40:39) hiddenpearls left the room (quit: Quit: Leaving.). (17:40:50) nn-: right (17:40:55) nn-: parse error is printed on stderr (17:40:57) t_backoff [~t_backoff@unaffiliated/t-backoff/x-5423102] entered the room. (17:41:34) nn-: and last grep filters out stdout output (17:41:54) nn-: on line 67 of the hook (17:42:01) nn-: replace 2>/dev/null with 2>&1 (17:43:16) marc1706 left the room (quit: Read error: Connection reset by peer). (17:44:01) nn-: i am confused how your echo does not have -e (17:44:08) Derky left the room (quit: ). (17:44:18) nn-: even my echo accepts -e, though man echo does not list it (17:44:28) nn-: ah, because that is zsh (17:44:36) nn-: which means you are using dash (17:45:19) bantu: interesting (17:45:29) bantu: confirmed with dash (17:45:32) bantu: working with bash (17:45:34) nn-: built-in vs binary (17:45:43) nn-: luckily i think we can just test for it (17:45:55) nn-: if test $(echo -e foo) = foo ... (17:46:33) nn-: and i have php 5.4 so i can test the stderr thing (17:46:39) imkingdavid: btw I changed the 2>/dev/null with 2>&1 in the hook and tried again and it didn't change anything (17:46:43) imkingdavid: if that makes a difference (17:47:56) nn-: hmm really (17:49:11) nn-: are you sure? (17:49:31) nn-: oh that's right (17:49:38) nn-: on line 80 (17:49:51) nn-: replace ^Parse with ^(PHP )?Parse (17:49:57) nn-: and grep with egrep (17:50:41) imkingdavid: much better (17:51:41) nn-: if you want you can pr both changes together (17:51:44) nn-: i mean in one pr (17:51:59) imkingdavid: in the feature/userdelete pr? (17:52:02) nn-: actually no (17:52:05) nn-: no definitely not there (17:52:10) nn-: i should fix echo -e thing (17:52:27) nn-: well you still can pr the two changes you made (17:52:41) nn-: also the pr should be against olympus obviously

          People

          • Assignee:
            Oleg Oleg [X] (Inactive)
            Reporter:
            imkingdavid David King
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development