package Cpanel::Easy::PHP5::SilenceDeprecatedPatch;

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

use strict;

our $easyconfig = {
    'name' => 'Silence Deprecated Patch',
    'note' => 'This patch will remove E_DEPRECATED and E_USER_DEPRECATED from E_ALL',
    'skip' => 0,
    'step' => {
        '0' => {
            'name'    => 'Apply silence-deprecated patch for PHP5',
            'command' => sub {
                my ($self) = @_;

                my $php_version = '';
                my $pns         = "Cpanel::Easy::PHP5";
                if ( $self->{'working_profile'}{$pns} ) {
                    for my $spec ( $pns->versions() ) {
                        if ( $self->{'working_profile'}{ $pns . '::' . $spec } ) {
                            $php_version = $pns . '::' . $spec;
                            next;
                        }
                    }
                }
                return ( 0, 'Could not determine PHP version' ) unless ($php_version);

                my $pp_ec = $self->get_easyconfig_hr_from_ns_variations($php_version);
                return ( 0, 'Could not find parent PHP path info' )
                  if ref $pp_ec ne 'HASH' || !exists $pp_ec->{'src_cd2'};

                require File::Spec;    # Already brought in, but just in case...
                my $path = File::Spec->catdir( $self->{'opt_mod_src_dir'}, $pp_ec->{'src_cd2'} );
                return $self->apply_patch( '../cppatch/php5-silence-deprecated.patch', $path );
            },
        },
    },
};

1;
