package Cpanel::Easy::PHP5::Mysql;

# cpanel - Cpanel/Easy/PHP5/Mysql.pm              Copyright(c) 2014 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use Cpanel::Version::Compare ();

our $easyconfig = {
    'name'    => 'Mysql',
    'note'    => 'compile MySQL support using the PHP bundled libraries (if the System MySQL option is checked it takes precedence over this option)',
    'url'     => 'http://www.php.net/manual/en/ref.mysql.php',
    'modself' => sub {
        my $easy    = shift;
        my $self_hr = shift;

        my @info = $easy->get_system_mysql_info();

        if (@info) {

            # FB 127149: only support php mysqlnd (native driver) going forward
            my $support = $easy->get_php_mysql_support_type( $info[4], $info[3] );
            $self_hr->{'implies'}{'Cpanel::Easy::PHP5::MysqlOfSystem'} = 0 if $support eq 'mysqlnd';
        }
        else {
            $self_hr->{'hastargz'}                   = 0;
            $self_hr->{'skip'}                       = 1;
            $self_hr->{'treat_as_off_while_skipped'} = 1;
        }
    },
    'dryrun' => {
        '0' => {
            'name'    => 'MySQL Compile Test',
            'command' => sub {
                my ($self) = @_;
                return $self->do_mysql_h_test_compile();
            },
        },
    },
    'step' => {
        '0' => {
            'name'    => 'to config options',
            'command' => sub {
                my ($self) = @_;

                if ( !$self->get_ns_value_from_profile('Cpanel::Easy::PHP5::MysqlOfSystem') ) {
                    $self->add_to_configure( { '--with-mysql' => '' } );
                }

                return ( 1, 'Ok' );
            },
        },
    },
};

1;
