Tomas Cohen Arazi
5a82616ab7
This patch makes opac/maintenance.pl run smoothly when the DB hasn't been populated yet. It does so, by using C4::Templates::gettemplate instead of C4::Auth::get_user_and_template as the maintenance page doesn't need authentication checks at all, it should happen *before* any attempt to check credentials. To test: - Backup and DROP your database - Point your browser to the OPAC page => FAIL: An error is shown: "Cant's use an undefined value as an ARRAY..." - Apply the patch - Relad the page => SUCCESS: The maintenance page correctly shows. We should now check the rest of the script's behaviour remains untouched: - Reload your backed up DB - Change your DB version number by hand to one version lower, like in: > UPDATE systempreferences SET value="3.1700042" WHERE variable LIKE '%version%'; - Go to the OPAC => SUCCESS: Maintenance page shows as expected - Recover the right version number, like in: > UPDATE systempreferences SET value="3.1700043" WHERE variable LIKE '%version%'; - Set OpacMaintenance to Show on the staff client - Reload the OPAC => SUCCESS: Maintenance page shows as expected - Set OpacMaintenance to 'Don't show' on the staff client - Reload the OPAC => SUCCESS: Normal OPAC shows - Sign off :-D Regards Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Works as described, fixes long existing bug. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
43 lines
No EOL
1.5 KiB
Perl
Executable file
43 lines
No EOL
1.5 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
use Modern::Perl;
|
|
|
|
use CGI;
|
|
use C4::Auth;
|
|
use C4::Output;
|
|
use C4::Templates qw/gettemplate/;
|
|
|
|
my $query = new CGI;
|
|
my $template = C4::Templates::gettemplate( 'maintenance.tt', 'opac', $query, 0 );
|
|
|
|
my $koha_db_version = C4::Context->preference('Version');
|
|
my $kohaversion = C4::Context::KOHAVERSION;
|
|
# Strip dots from version
|
|
$kohaversion =~ s/\.//g if defined $kohaversion;
|
|
$koha_db_version =~ s/\.//g if defined $koha_db_version;
|
|
|
|
if ( !defined $koha_db_version || # DB not populated
|
|
$kohaversion > $koha_db_version || # Update needed
|
|
C4::Context->preference('OpacMaintenance') ) { # Maintenance mode enabled
|
|
output_html_with_http_headers $query, '', $template->output;
|
|
}
|
|
else {
|
|
print $query->redirect("/cgi-bin/koha/opac-main.pl");
|
|
}
|
|
|
|
1; |