View Issue Details

IDProjectCategoryView StatusLast Update
0008524mantisbtintegrationpublic2007-11-23 19:00
Reportermdl Assigned Tovboctor  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Platformx86OSLinux - SlackwareOS Version9
Product Version1.1.0rc2 
Fixed in Version1.1.0rc3 
Summary0008524: core/checkin.php is missing toplevel <? causing the script to fail.
Description

I have mantis 1.0.6 running at work. I had to modify checkin.php back in March 2007 so that it integrates with my CVS install.

Then, I installed 1.1.0rc2 on another server, and this time, the checkin.php was missing the php opening tag, causing the file to be copied back to the cvs client of the person committing a file.

I have tons more info on how to make this integration work. I'll submit the patch in a note.

Steps To Reproduce

add the following line to your "CVSROOT/verifymsg" file:
DEFAULT /usr/local/bin/php /your_htdocs_path/mantis/core/checkin.php

Then, commit a change against the CVS repository.

You will see the whole content of checkin.php being sent back by the php interpreter.

Additional Information

Here's my checkin.php, which works ok for me. I apologize if the text gets garbled. My personal patch is between the line "START CUSTOM" and "END CUSTOM"

<fixed>
#!/usr/local/bin/php -q
<?

Mantis - a php based bugtracking system

Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org

Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net

Mantis is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 2 of the License, or

(at your option) any later version.

#

Mantis is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

#

You should have received a copy of the GNU General Public License

along with Mantis. If not, see http://www.gnu.org/licenses/.

    # See the README and LICENSE files for details

    # --------------------------------------------------------
    # $Id: checkin.php,v 1.5.2.1 2007/10/13 22:35:16 giallu Exp $
    # --------------------------------------------------------

    global $g_bypass_headers;
    $g_bypass_headers = 1;
    require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );

    # Make sure this script doesn't run via the webserver
    # @@@ This is a hack to detect php-cgi, there must be a better way.
    if ( isset( $_SERVER['SERVER_PORT'] ) ) {
            echo "checkin.php is not allowed to run through the webserver.\n";
            exit( 1 );
    }

    # Check that the username is set and exists
    $t_username = config_get( 'source_control_account' );
    if ( is_blank( $t_username ) || ( user_get_id_by_name( $t_username ) === false ) ) {
            echo "Invalid source control account ('$t_username').\n";
            exit( 1 );
    }

    if ( !defined( "STDIN" ) ) {
            define("STDIN", fopen('php://stdin','r'));
    }

    # **** START CUSTOM ****
    $t_cvs_user = exec("whoami");

    # Detect references to issues + concat all lines to have the comment log.
    $t_commit_regexp = config_get( 'source_control_regexp' );
    $t_commit_fixed_regexp = config_get( 'source_control_fixed_regexp' );

    $t_issues = array();
    $t_fixed_issues = array();

    $t_comment = $t_cvs_user.": ";
    $t_line = exec( "cat $argv[1]\n" ); # line added + modified
    $t_comment .= $t_line;

    if ( preg_match_all( $t_commit_regexp, $t_line, $t_matches ) ) {
            for ( $i = 0; $i < count( $t_matches[0] ); $i++ ) {
                    $t_issues[$i] = $t_matches[1][$i];
                    echo "found issue: ".$t_issues[$i]."\n";
            }
    }
    if ( preg_match_all( $t_commit_fixed_regexp, $t_line, $t_matches ) ) {
            for ( $i = 0; $i < count( $t_matches[0] ); $i++ ) {
                    $t_fixed_issues[$i] = $t_matches[1][$i];
                    echo "fixed issue: ".$t_fixed_issues[$i]."\n";
            }
    }
    # **** END CUSTOM ****

    # If no issues found, then no work to do.
    if ( ( count( $t_issues ) == 0 ) && ( count( $t_fixed_issues ) == 0 ) ) {
            echo "Comment does not reference any issues.\n";
            exit(0);
    }

    # Login as source control user
    if ( !auth_attempt_script_login( $t_username ) ) {
            echo "Unable to login\n";
            exit( 1 );
    }

    # history parameters are reserved for future use.
    $t_history_old_value = '';
    $t_history_new_value = '';

    # add note to each bug only once
    $t_issues = array_unique( $t_issues );
    $t_fixed_issues = array_unique( $t_fixed_issues );

    # Call the custom function to register the checkin on each issue.

    foreach ( $t_issues as $t_issue_id ) {
            if ( !in_array( $t_issue_id, $t_fixed_issues ) ) {
                    helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment, $t_history_old_value, $t_history_new_value, fa

lse ) );
}
}

    foreach ( $t_fixed_issues as $t_issue_id ) {
            helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment, $t_history_old_value, $t_history_new_value, true ) );
    }

    exit( 0 );

?>
</fixed>

TagsNo tags attached.

Relationships

has duplicate 0008523 closedvboctor SubVersion integration not working 

Activities

mdl

mdl

2007-11-01 03:16

reporter   ~0016045

Oh, sorry the <fixed> </fixed> for triggering a fixed font didn't work

mdl

mdl

2007-11-01 03:17

reporter   ~0016046

Also, here's the code for config_inc.php:

    // integration with CVS
    $g_source_control_notes_view_status = VS_PUBLIC;
    $g_source_control_account = 'cvs-account';
    $g_source_control_set_status_to = RESOLVED;
    // status can be one of: FEEDBACK, ACKNOWLEDGED, CONFIRMED, ASSIGNED, RESOLVED, CLOSED
    $g_source_control_regexp = "/issue\s*[#]{0,1}(\d+)/i";
    $g_source_control_fixed_regexp = "/fixed\s*[#]{0,1}(\d+)/i";

Basically, I added a cvs-account username to mantis.

mdl

mdl

2007-11-01 03:20

reporter   ~0016047

Last one: by the way, there's another bug somewhere in there, I just never bothered to fix it:

make sure to commit only with just one comment line. Do not spam across multiple lines or the mantis bug ID check will fail.

With the above code, you can use either "issue 0000512" or "fixed 0000512" to get the php to read the bug ID as 512.