Bug 40292: Use Koha::Devel::Files to list dbrevs

For reusability and to limit files to the git index

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2025-10-17 12:26:25 +02:00 committed by Lucas Gass
parent de5e76bac2
commit 647b28e536
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 22 additions and 23 deletions

View File

@ -213,6 +213,22 @@ sub ls_perl_files {
return @files;
}
=head2 ls_dbrev_files
my @dbrev_files = $file_manager->ls_dbrev_files;
Lists all dbrevs files.
=cut
sub ls_dbrev_files {
my ($self) = @_;
my $cmd = q{git ls-files installer/data/mysql/db_revs/*.pl};
my @files = qx{$cmd};
chomp for @files;
return @files;
}
=head2 ls_js_files
my @js_files = $file_manager->ls_js_files();

View File

@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
# along with Koha; if not, see <https://www.gnu.org/licenses>.
use Modern::Perl;
@ -23,35 +23,18 @@ use Test::More;
use File::Find;
use File::Slurp;
use Test::NoWarnings;
use Koha::Devel::Files;
# Test for Bug 40292: Prevent SQL syntax error when upgrading to 25.05 on MariaDB 10.3
# This test ensures that database revision files don't use SQL syntax that is incompatible
# with older MariaDB versions (specifically MariaDB 10.3)
my @db_rev_files;
my $db_revs_dir = 'installer/data/mysql/db_revs';
my $dev_files = Koha::Devel::Files->new;
my @dbrev_files = $dev_files->ls_dbrev_files;
# Skip test if db_revs directory doesn't exist
if ( !-d $db_revs_dir ) {
plan skip_all => "Database revisions directory ($db_revs_dir) not found";
}
plan tests => scalar @dbrev_files + 1;
# Find all .pl files in the db_revs directory
find(
sub {
push @db_rev_files, $File::Find::name if /\.pl$/;
},
$db_revs_dir
);
# Skip test if no database revision files found
if ( !@db_rev_files ) {
plan skip_all => "No database revision files found in $db_revs_dir";
}
plan tests => scalar @db_rev_files + 1;
foreach my $file (@db_rev_files) {
foreach my $file (@dbrev_files) {
my $content = read_file($file);
# Check for incompatible RENAME COLUMN syntax