diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rwxr-xr-x | git-tools/commit-msg-hook-range.sh | 29 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v310/profilefield_interests.php | 1 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v310/profilefield_show_novalue.php | 45 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_int.php | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/mcp_header.html | 16 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/mcp_header.html | 17 | ||||
-rw-r--r-- | tests/profile/get_profile_value_test.php | 42 |
8 files changed, 115 insertions, 39 deletions
diff --git a/.travis.yml b/.travis.yml index 70428d611d..4d14c16977 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ script: - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' ]; then ../phpBB/vendor/bin/phing sniff; fi" - cd .. - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH...FETCH_HEAD; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" matrix: allow_failures: diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh index 66628c1d17..2b408c3e79 100755 --- a/git-tools/commit-msg-hook-range.sh +++ b/git-tools/commit-msg-hook-range.sh @@ -5,26 +5,47 @@ # # Calls the git commit-msg hook on all non-merge commits in a given commit range. # -set -e if [ "$#" -ne 1 ]; then - echo "Expected one argument (commit range, e.g. eef1b586...1666476b)." + echo "Expected one argument (commit range, e.g. phpbb/develop..ticket/12345)." exit fi DIR=$(dirname "$0") -COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg" - COMMIT_RANGE="$1" +COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg" +COMMIT_MSG_HOOK_FATAL=$(git config --bool phpbb.hooks.commit-msg.fatal 2> /dev/null) +git config phpbb.hooks.commit-msg.fatal true +EXIT_STATUS=0 for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE") do + echo "Inspecting commit message of commit $COMMIT_HASH" + # The git commit-msg hook takes a path to a file containing a commit # message. So we have to extract the commit message into a file first, # which then also needs to be deleted after our work is done. COMMIT_MESSAGE_PATH="$DIR/commit_msg.$COMMIT_HASH" git log -n 1 --pretty=format:%B "$COMMIT_HASH" > "$COMMIT_MESSAGE_PATH" + + # Invoke hook on commit message file. "$COMMIT_MSG_HOOK_PATH" "$COMMIT_MESSAGE_PATH" + + # If any commit message hook complains with a non-zero exit status, we + # will send a non-zero exit status upstream. + if [ $? -ne 0 ] + then + EXIT_STATUS=1 + fi + rm "$COMMIT_MESSAGE_PATH" done + +# Restore phpbb.hooks.commit-msg.fatal config +if [ -n "$COMMIT_MSG_HOOK_FATAL" ] +then + git config phpbb.hooks.commit-msg.fatal "$COMMIT_MSG_HOOK_FATAL" +fi + +exit $EXIT_STATUS diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php index d73bc78edb..2b943c5e53 100644 --- a/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php @@ -15,6 +15,7 @@ class profilefield_interests extends \phpbb\db\migration\profilefield_base_migra { return array( '\phpbb\db\migration\data\v310\profilefield_types', + '\phpbb\db\migration\data\v310\profilefield_show_novalue', ); } diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_show_novalue.php b/phpBB/phpbb/db/migration/data/v310/profilefield_show_novalue.php new file mode 100644 index 0000000000..d37103e2ce --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_show_novalue.php @@ -0,0 +1,45 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_show_novalue extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields', 'field_show_novalue'); + } + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\profilefield_types'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index b89faca018..267f522d5d 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -141,7 +141,7 @@ class type_int extends type_base */ public function get_profile_value($field_value, $field_data) { - if ($field_value === '' && !$field_data['field_show_novalue']) + if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue']) { return null; } diff --git a/phpBB/styles/prosilver/template/mcp_header.html b/phpBB/styles/prosilver/template/mcp_header.html index 51f496605e..2b2105e770 100644 --- a/phpBB/styles/prosilver/template/mcp_header.html +++ b/phpBB/styles/prosilver/template/mcp_header.html @@ -47,19 +47,3 @@ <p><!-- BEGIN return_links -->{return_links.MESSAGE_LINK}<br /><br /><!-- END return_links --></p> </div> <!-- ENDIF --> - - <!-- IF CONFIRM_MESSAGE --> - <form id="confirm" method="post" action="{S_CONFIRM_ACTION}"{S_FORM_ENCTYPE}> - - <div class="content"> - <h2>{L_PLEASE_CONFIRM}</h2> - <p>{CONFIRM_MESSAGE}</p> - - <fieldset class="submit-buttons"> - {S_HIDDEN_FIELDS}<input class="button1" type="submit" name="submit" value="{L_YES}" /> - <input class="button2" type="cancel" value="{L_NO}" /> - </fieldset> - </div> - - </form> - <!-- ENDIF --> diff --git a/phpBB/styles/subsilver2/template/mcp_header.html b/phpBB/styles/subsilver2/template/mcp_header.html index 9b9f7849f4..7144750ed4 100644 --- a/phpBB/styles/subsilver2/template/mcp_header.html +++ b/phpBB/styles/subsilver2/template/mcp_header.html @@ -58,20 +58,3 @@ <br /> <!-- ENDIF --> - - <!-- IF CONFIRM_MESSAGE --> - <form name="confirm" method="post" action="{S_CONFIRM_ACTION}"> - - <table class="tablebg" width="100%" cellspacing="1"> - <tr> - <th>{L_PLEASE_CONFIRM}</th> - </tr> - <tr> - <td class="row1" align="center"><span class="gen"><br />{CONFIRM_MESSAGE}<br /><br />{S_HIDDEN_FIELDS}<input class="btnmain" type="submit" name="confirm" value="{L_YES}" /> <input class="btnlite" type="submit" name="cancel" value="{L_NO}" /><br /><br /></span></td> - </tr> - </table> - - </form> - - <br /> - <!-- ENDIF --> diff --git a/tests/profile/get_profile_value_test.php b/tests/profile/get_profile_value_test.php new file mode 100644 index 0000000000..e867455a03 --- /dev/null +++ b/tests/profile/get_profile_value_test.php @@ -0,0 +1,42 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_profile_get_profile_value_test extends phpbb_test_case +{ + static public function get_profile_value_int_data() + { + return array( + array('\phpbb\profilefields\type\type_int', '10', true, 10), + array('\phpbb\profilefields\type\type_int', '0', true, 0), + array('\phpbb\profilefields\type\type_int', '', true, 0), + array('\phpbb\profilefields\type\type_int', null, true, 0), + array('\phpbb\profilefields\type\type_int', '10', false, 10), + array('\phpbb\profilefields\type\type_int', '0', false, 0), + array('\phpbb\profilefields\type\type_int', '', false, null), + array('\phpbb\profilefields\type\type_int', null, false, null), + ); + } + + /** + * @dataProvider get_profile_value_int_data + */ + public function test_get_profile_value_int($type, $value, $show_novalue, $expected) + { + $cp = new $type( + $this->getMock('\phpbb\request\request'), + $this->getMock('\phpbb\template\template'), + $this->getMock('\phpbb\user') + ); + + $this->assertSame($expected, $cp->get_profile_value($value, array( + 'field_type' => $type, + 'field_show_novalue' => $show_novalue, + ))); + } +} |