$script->shutdown( 1, "An unexpected error occurred while trying to read diff file ($filePath)" );

    $alreadyIndexedPFs = array();
    $previousPFs = json_decode( $json, true );
    foreach ( getRelations( $db ) as $c => $pf )
    {
        $updateFile = false;
        $diff = array_merge( array_diff_assoc( $pf, $previousPFs[$c] ), array_diff_assoc( $previousPFs[$c], $pf ) );
        if ( count( $diff ) > 0 )
        {
            $updateFile = true;
            foreach ( $diff as $_pf )
            {
                if ( !in_array( $_pf, array_keys( $alreadyIndexedPFs ) ) )
                {
                    $result = PublisherFolderTool::indexContent( $_pf, 10 );
                    $alreadyIndexedPFs[$_pf] = $result;
                }
                else
                {
                    $result = $alreadyIndexedPFs[$_pf];
                }
                if ( $result['errorCode'] > 0 )
                {
                    if ( $result['errorCode'] == 2 )
                    {
                        // The publisherFolder couldn't be found in eZ, we remove it from the newly created diff
                        $key = array_search( $_pf, $pf );
                        if ( $key !== false )
                            unset( $pf[$key] );
                        $previousPFs[$c] = $pf;
foreach ( $allResults as $row )
{
    $exists = (  is_array(eZContentObject::fetchByRemoteID( 'publisher_folder-' . $row['path'], false )) );

    if ( $exists )
        $folders[$row['id']] = $row['path'];
}
    
$replies = $interactiveQuestion->askQuestionMultipleChoices( 'Choose publisher folders you want to purge', $folders, 'validateReplyMultiple', true );

if ( !empty( $replies ) )
{
    foreach ( $replies as $key )
    {
        $result = PublisherFolderTool::indexContent( $folders[$key], $priority );
        if ( $result['errorCode'] > 0 )
        {
            if ( $result['errorCode'] == 1 )
            {
                $script->shutdown( 1, $result['errorMsg'] );
            }
            else
            {
                $cli->error( $result['errorMsg'] );
                continue;
            }
        }
        else
        {
            $cli->notice( 'Publisher folder ' . $folders[$key] . ' is completed, ' . $result['data'] . ' articles have been added in indexation pending.' );