View | Details | Raw Unified | Return to bug 17669
Collapse All | Expand All

(-)a/Koha/UploadedFiles.pm (-2 / +2 lines)
Lines 77-83 sub delete { Link Here
77
=head3 delete_temporary
77
=head3 delete_temporary
78
78
79
Delete_temporary is called by cleanup_database and only removes temporary
79
Delete_temporary is called by cleanup_database and only removes temporary
80
uploads older than [pref Upload_PurgeTemporaryFiles_Days] days.
80
uploads older than [pref UploadPurgeTemporaryFilesDays] days.
81
It is possible to override the pref with the override_pref parameter.
81
It is possible to override the pref with the override_pref parameter.
82
82
83
Returns true if no errors occur. (Even when no files had to be deleted.)
83
Returns true if no errors occur. (Even when no files had to be deleted.)
Lines 87-93 Returns true if no errors occur. (Even when no files had to be deleted.) Link Here
87
sub delete_temporary {
87
sub delete_temporary {
88
    my ( $self, $params ) = @_;
88
    my ( $self, $params ) = @_;
89
    my $days = $params->{override_pref} ||
89
    my $days = $params->{override_pref} ||
90
        C4::Context->preference('Upload_PurgeTemporaryFiles_Days');
90
        C4::Context->preference('UploadPurgeTemporaryFilesDays');
91
    return 1 if !$days;
91
    return 1 if !$days;
92
    my $dt = dt_from_string();
92
    my $dt = dt_from_string();
93
    $dt->subtract( days => $days );
93
    $dt->subtract( days => $days );
(-)a/installer/data/mysql/atomicupdate/bug17669.perl (-2 / +2 lines)
Lines 1-12 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q|
3
    $dbh->do(q|
4
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('Upload_PurgeTemporaryFiles_Days','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer');
4
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer');
5
    |);
5
    |);
6
6
7
    my ( $cnt ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM uploaded_files WHERE permanent IS NULL or permanent=0" );
7
    my ( $cnt ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM uploaded_files WHERE permanent IS NULL or permanent=0" );
8
    if( $cnt ) {
8
    if( $cnt ) {
9
        print "NOTE: You have $cnt temporary uploads. You could benefit from setting pref Upload_PurgeTemporaryFiles_Days now to automatically delete them.\n";
9
        print "NOTE: You have $cnt temporary uploads. You could benefit from setting pref UploadPurgeTemporaryFilesDays now to automatically delete them.\n";
10
    }
10
    }
11
11
12
    SetVersion( $DBversion );
12
    SetVersion( $DBversion );
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 536-542 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
536
('UniqueItemFields','barcode','','Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'),
536
('UniqueItemFields','barcode','','Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'),
537
('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'),
537
('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'),
538
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
538
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
539
('Upload_PurgeTemporaryFiles_Days','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'),
539
('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'),
540
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
540
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
541
('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'),
541
('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'),
542
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
542
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref (-1 / +1 lines)
Lines 29-34 Tools: Link Here
29
    Upload:
29
    Upload:
30
        -
30
        -
31
            - Automatically delete temporary uploads older than
31
            - Automatically delete temporary uploads older than
32
            - pref: Upload_PurgeTemporaryFiles_Days
32
            - pref: UploadPurgeTemporaryFilesDays
33
              class: integer
33
              class: integer
34
            - "days in cleanup_database cron job. NOTE: If you leave this field empty (zero), the cron job will not delete any files."
34
            - "days in cleanup_database cron job. NOTE: If you leave this field empty (zero), the cron job will not delete any files."
(-)a/t/db_dependent/Upload.t (-4 / +3 lines)
Lines 269-283 subtest 'Testing delete_temporary' => sub { Link Here
269
    $recs[2]->dtcreated($dt)->store;
269
    $recs[2]->dtcreated($dt)->store;
270
270
271
    # Now call delete_temporary with 0, 6, 5 and 1 (via override)
271
    # Now call delete_temporary with 0, 6, 5 and 1 (via override)
272
    t::lib::Mocks::mock_preference('Upload_PurgeTemporaryFiles_Days', 0 );
272
    t::lib::Mocks::mock_preference('UploadPurgeTemporaryFilesDays', 0 );
273
    Koha::UploadedFiles->delete_temporary;
273
    Koha::UploadedFiles->delete_temporary;
274
    is( Koha::UploadedFiles->search->count, 6, 'Delete with pref==0' );
274
    is( Koha::UploadedFiles->search->count, 6, 'Delete with pref==0' );
275
275
276
    t::lib::Mocks::mock_preference('Upload_PurgeTemporaryFiles_Days', 6 );
276
    t::lib::Mocks::mock_preference('UploadPurgeTemporaryFilesDays', 6 );
277
    Koha::UploadedFiles->delete_temporary;
277
    Koha::UploadedFiles->delete_temporary;
278
    is( Koha::UploadedFiles->search->count, 6, 'Delete with pref==6' );
278
    is( Koha::UploadedFiles->search->count, 6, 'Delete with pref==6' );
279
279
280
    t::lib::Mocks::mock_preference('Upload_PurgeTemporaryFiles_Days', 5 );
280
    t::lib::Mocks::mock_preference('UploadPurgeTemporaryFilesDays', 5 );
281
    Koha::UploadedFiles->delete_temporary;
281
    Koha::UploadedFiles->delete_temporary;
282
    is( Koha::UploadedFiles->search->count, 4, 'Delete with pref==5 makes 4' );
282
    is( Koha::UploadedFiles->search->count, 4, 'Delete with pref==5 makes 4' );
283
283
284
- 

Return to bug 17669