protected function proceedFileComments(array $patchset)
    {
        /**
         * To import the file comments there are (maybe) some data which is not very correct.
         * For example comments can be deleted later on.
         * This information is not deliviered by the API.
         * The same for comments marked as "Done".
         *
         * Sad, but true.
         * But hey! Some comments are better than nothing.
         * During analysis the comments you have to take care this in mind.
         */

        foreach ($patchset['comments'] as $comment) {

            // Take care of reviewer
            $comment['reviewer'] = $this->proceedPerson($comment['reviewer']);

            // Search the file id
            $whereParts = array(
                'patchset' => $patchset['id'],
                'file' => $comment['file']
            );
            $fileRow = $this->getLookupTableValues(Database::TABLE_FILES, array('id'), $whereParts);

            // Sometimes we got comments to files, which are not part of the current patchset.
            // See https://review.typo3.org/#/c/22107/3 for example.
            // File "Classes/BackEnd/Ajax.php" is not part of the 3rd patchset.
            // But Oliver Klee commented this file, because this file was part of the 1st patchset.
            // This file was not part of the 2nd patchset either.
            // In this case "file" would be NULL during database insert and an exception would be thrown:
            // [Exception] Column 'file' cannot be null (1048)
            //
            // Okay we got two options to solve this.
            // 1. We ignore the comment and loss the information
            // 2. Create a new file action "COMMENTED", insert this file with the new type and insert the comment
            // We will choose option 2, because we do not accept data loss if we can store it.
            //
            // If you are reading this and got a better solution, contact us
            // We would be happy to see your way
            if ($fileRow === false) {
                // Take care of file action
                $type = $this->proceedLookupTable(Database::TABLE_FILEACTION, 'id', 'name', 'COMMENTED');

                $fileData = array(
                    'patchset' => $patchset['id'],
                    'file' => $comment['file'],
                    'file_old' => '',
                    'insertions' => 0,
                    'deletions' => 0,
                    'type' => $type
                );
                $fileRow['id'] = $this->getDatabase()->insertRecord(Database::TABLE_FILES, $fileData);
            }

            $commentRow = array(
                'patchset' => $patchset['id'],
                'file' => $fileRow['id'],
                'line' => $comment['line'],
                'reviewer' => $comment['reviewer']['id'],
                'message' => $comment['message'],
                'message_crc32' => crc32($comment['message'])
            );

            // Attention: One person can comment twice at the same line.
            // We do not get any timestamp :(
            // e.g. see https://review.typo3.org/#/c/11758/1/ExtendingSphinxForTYPO3/build/.gitignore,unified
            // To be "unique enough" we add a CRC32 checksum of the message
            $fileCommentRow = $this->getGerritFileCommentByIdentifier(
                $patchset['id'],
                $fileRow['id'],
                $comment['line'],
                $comment['reviewer']['id'],
                $commentRow['message_crc32']
            );
            if ($fileCommentRow === false) {
                $this->getDatabase()->insertRecord(Database::TABLE_FILE_COMMENTS, $commentRow);
            }

            // Normally we would update the comment here (in a else part).
            // But in this data we got from the API there is nothing to update.
            // Sometimes the same comment in the same file in the same line by the same person was created
            // Sadly we do not get a timestamp or something.
            // This is the reason why there is no else part + no checkIfServersFirstRun check
            // We just ignore duplicates here.
            // I know that this might be dangerous, because we can miss comments, but until there is no additional
            // identifier this can be difficult
            // One idea is that the number of comment will be introduces in the select check (with a simple $i var)
            // But this needs further testing if the order of the comments is always the same
            // TODO check this

            $comment = $this->unsetKeys($comment, array('file', 'line', 'reviewer', 'message'));

            $this->checkIfAllValuesWereProceeded($comment, 'File comment');
        }
    }
protected function proceedFileComments(array $patchset)
    {
        /**
         * To import the file comments there are (maybe) some data which is not very correct.
         * For example comments can be deleted later on.
         * This information is not deliviered by the API.
         * The same for comments marked as "Done".
         *
         * Sad, but true.
         * But hey! Some comments are better than nothing.
         * During analysis the comments you have to take care this in mind.
         */

        foreach ($patchset['comments'] as $comment) {

            // Take care of reviewer
            $comment['reviewer'] = $this->proceedPerson($comment['reviewer']);

            // Search the file id
            $whereParts = array(
                'patchset' => $patchset['id'],
                'file' => $comment['file']
            );
            $fileRow = $this->getLookupTableValues(Database::TABLE_FILES, array('id'), $whereParts);

            // Sometimes we got comments to files, which are not part of the current patchset.
            // See https://review.typo3.org/#/c/22107/3 for example.
            // File "Classes/BackEnd/Ajax.php" is not part of the 3rd patchset.
            // But Oliver Klee commented this file, because this file was part of the 1st patchset.
            // This file was not part of the 2nd patchset either.
            // In this case "file" would be NULL during database insert and an exception would be thrown:
            // [Exception] Column 'file' cannot be null (1048)
            //
            // Okay we got two options to solve this.
            // 1. We ignore the comment and loss the information
            // 2. Create a new file action "COMMENTED", insert this file with the new type and insert the comment
            // We will choose option 2, because we do not accept data loss if we can store it.
            //
            // If you are reading this and got a better solution, contact us
            // We would be happy to see your way
            if ($fileRow === false) {
                // Take care of file action
                $type = $this->proceedLookupTable(Database::TABLE_FILEACTION, 'id', 'name', 'COMMENTED');

                $fileData = array(
                    'patchset' => $patchset['id'],
                    'file' => $comment['file'],
                    'file_old' => '',
                    'insertions' => 0,
                    'deletions' => 0,
                    'type' => $type
                );
                $fileRow['id'] = $this->getDatabase()->insertRecord(Database::TABLE_FILES, $fileData);
            }

            $commentRow = array(
                'patchset' => $patchset['id'],
                'file' => $fileRow['id'],
                'line' => $comment['line'],
                'reviewer' => $comment['reviewer']['id'],
                'message' => $comment['message'],
                'message_crc32' => crc32($comment['message'])
            );

            // Attention: One person can comment twice at the same line.
            // We do not get any timestamp :(
            // e.g. see https://review.typo3.org/#/c/11758/1/ExtendingSphinxForTYPO3/build/.gitignore,unified
            // To be "unique enough" we add a CRC32 checksum of the message
            $fileCommentRow = $this->getGerritFileCommentByIdentifier(
                $patchset['id'],
                $fileRow['id'],
                $comment['line'],
                $comment['reviewer']['id'],
                $commentRow['message_crc32']
            );
            if ($fileCommentRow === false) {
                $this->getDatabase()->insertRecord(Database::TABLE_FILE_COMMENTS, $commentRow);
            }

            // Normally we would update the comment here (in a else part).
            // But in this data we got from the API there is nothing to update.
            // Sometimes the same comment in the same file in the same line by the same person was created
            // Sadly we do not get a timestamp or something.
            // This is the reason why there is no else part + no checkIfServersFirstRun check
            // We just ignore duplicates here.
            // I know that this might be dangerous, because we can miss comments, but until there is no additional
            // identifier this can be difficult
            // One idea is that the number of comment will be introduces in the select check (with a simple $i var)
            // But this needs further testing if the order of the comments is always the same
            // TODO check this

            $comment = $this->unsetKeys($comment, array('file', 'line', 'reviewer', 'message'));

            $this->checkIfAllValuesWereProceeded($comment, 'File comment');
        }
    }
protected function proceedFileComments ( array $ patchset ) { /**
         * To import the file comments there are (maybe) some data which is not very correct.
         * For example comments can be deleted later on.
         * This information is not deliviered by the API.
         * The same for comments marked as "Done".
         *
         * Sad, but true.
         * But hey! Some comments are better than nothing.
         * During analysis the comments you have to take care this in mind.
         */ foreach ( $ patchset [ 'comments' ] as $ comment ) { // Take care of reviewer $ comment [ 'reviewer' ] = $ this -> proceedPerson ( $ comment [ 'reviewer' ] ) ; // Search the file id $ whereParts = array ( 'patchset' => $ patchset [ 'id' ] , 'file' => $ comment [ 'file' ] ) ; $ fileRow = $ this -> getLookupTableValues ( Database :: TABLE_FILES , array ( 'id' ) , $ whereParts ) ; // Sometimes we got comments to files, which are not part of the current patchset. // See https://review.typo3.org/#/c/22107/3 for example. // File "Classes/BackEnd/Ajax.php" is not part of the 3rd patchset. // But Oliver Klee commented this file, because this file was part of the 1st patchset. // This file was not part of the 2nd patchset either. // In this case "file" would be NULL during database insert and an exception would be thrown: // [Exception] Column 'file' cannot be null (1048) // // Okay we got two options to solve this. // 1. We ignore the comment and loss the information // 2. Create a new file action "COMMENTED", insert this file with the new type and insert the comment // We will choose option 2, because we do not accept data loss if we can store it. // // If you are reading this and got a better solution, contact us // We would be happy to see your way if ( $ fileRow === false ) { // Take care of file action $ type = $ this -> proceedLookupTable ( Database :: TABLE_FILEACTION , 'id' , 'name' , 'COMMENTED' ) ; $ fileData = array ( 'patchset' => $ patchset [ 'id' ] , 'file' => $ comment [ 'file' ] , 'file_old' => '' , 'insertions' => 0 , 'deletions' => 0 , 'type' => $ type ) ; $ fileRow [ 'id' ] = $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_FILES , $ fileData ) ; } $ commentRow = array ( 'patchset' => $ patchset [ 'id' ] , 'file' => $ fileRow [ 'id' ] , 'line' => $ comment [ 'line' ] , 'reviewer' => $ comment [ 'reviewer' ] [ 'id' ] , 'message' => $ comment [ 'message' ] , 'message_crc32' => crc32 ( $ comment [ 'message' ] ) ) ; // Attention: One person can comment twice at the same line. // We do not get any timestamp :( // e.g. see https://review.typo3.org/#/c/11758/1/ExtendingSphinxForTYPO3/build/.gitignore,unified // To be "unique enough" we add a CRC32 checksum of the message $ fileCommentRow = $ this -> getGerritFileCommentByIdentifier ( $ patchset [ 'id' ] , $ fileRow [ 'id' ] , $ comment [ 'line' ] , $ comment [ 'reviewer' ] [ 'id' ] , $ commentRow [ 'message_crc32' ] ) ; if ( $ fileCommentRow === false ) { $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_FILE_COMMENTS , $ commentRow ) ; } // Normally we would update the comment here (in a else part). // But in this data we got from the API there is nothing to update. // Sometimes the same comment in the same file in the same line by the same person was created // Sadly we do not get a timestamp or something. // This is the reason why there is no else part + no checkIfServersFirstRun check // We just ignore duplicates here. // I know that this might be dangerous, because we can miss comments, but until there is no additional // identifier this can be difficult // One idea is that the number of comment will be introduces in the select check (with a simple $i var) // But this needs further testing if the order of the comments is always the same // TODO check this $ comment = $ this -> unsetKeys ( $ comment , array ( 'file' , 'line' , 'reviewer' , 'message' ) ) ; $ this -> checkIfAllValuesWereProceeded ( $ comment , 'File comment' ) ; } }
Proceeds the comments of a single patchset.
One patchset can have n comments.

@param array $patchset The current patchset
@return void
Proceeds the comments of a single patchset . One patchset can have n comments .