ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / installer / install.pl
index bf0b9d1..bf9ccc4 100755 (executable)
@@ -17,8 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 use diagnostics;
 
 use C4::InstallAuth;
@@ -89,11 +88,13 @@ if ( $step && $step == 1 ) {
     #Whenever there is an error, adding a report to the page
     my $op = $query->param('op') || 'noop';
     $template->param( language      => 1 );
+    my $checkmodule = 1;
     $template->param( 'checkmodule' => 1 )
       ; # we start with the assumption that there are no problems and set this to 0 if there are
 
     unless ( $] >= 5.010000 ) {    # Bug 7375
         $template->param( problems => 1, perlversion => 1, checkmodule => 0 );
+        $checkmodule = 0;
     }
 
     my $perl_modules = C4::Installer::PerlModules->new;
@@ -102,7 +103,6 @@ if ( $step && $step == 1 ) {
     my $modules = $perl_modules->get_attr('missing_pm');
     if ( scalar(@$modules) ) {
         my @components  = ();
-        my $checkmodule = 1;
         foreach (@$modules) {
             my ( $module, $stats ) = each %$_;
             $checkmodule = 0 if $stats->{'required'};
@@ -144,10 +144,11 @@ elsif ( $step && $step == 2 ) {
                     $template->param( 'checkdatabasecreated' => 1 );
                 }
 
-                #Check if user have all necessary grants on this database.
-                my $rq =
-                  $dbh->prepare(
-                    "SHOW GRANTS FOR \'$info{user}\'\@'$info{hostname}'");
+                # Check if user have all necessary grants on this database.
+                # CURRENT_USER is ANSI SQL, and doesn't require mysql table
+                # privileges, making the % check pointless, since they
+                # couldn't even check GRANTS if they couldn't connect.
+                my $rq = $dbh->prepare('SHOW GRANTS FOR CURRENT_USER');
                 $rq->execute;
                 my $grantaccess;
                 while ( my ($line) = $rq->fetchrow ) {
@@ -167,27 +168,6 @@ elsif ( $step && $step == 2 ) {
                           );
                     }
                 }
-                unless ($grantaccess) {
-                    $rq =
-                      $dbh->prepare("SHOW GRANTS FOR \'$info{user}\'\@'\%'");
-                    $rq->execute;
-                    while ( my ($line) = $rq->fetchrow ) {
-                        my $dbname = $info{dbname};
-                        if ( $line =~ m/$dbname/ || index( $line, '*.*' ) > 0 )
-                        {
-                            $grantaccess = 1
-                              if (
-                                index( $line, 'ALL PRIVILEGES' ) > 0
-                                || (   ( index( $line, 'SELECT' ) > 0 )
-                                    && ( index( $line, 'INSERT' ) > 0 )
-                                    && ( index( $line, 'UPDATE' ) > 0 )
-                                    && ( index( $line, 'DELETE' ) > 0 )
-                                    && ( index( $line, 'CREATE' ) > 0 )
-                                    && ( index( $line, 'DROP' ) > 0 ) )
-                              );
-                        }
-                    }
-                }
                 $template->param( "checkgrantaccess" => $grantaccess );
             }    # End mysql connect check...
 
@@ -311,7 +291,7 @@ elsif ( $step && $step == 3 ) {
 # Where <level> is a category of requirement : required, recommended optional
 # level should contain :
 #   SQL File for import With a readable name.
-#   txt File taht explains what this SQL File is meant for.
+#   txt File that explains what this SQL File is meant for.
 # Could be VERY useful to have A Big file for a kind of library.
 # But could also be useful to have some Authorised values data set prepared here.
 # Marcflavour Selection is achieved through radiobuttons.