Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory
Commits
29bcd870
Verified
Commit
29bcd870
authored
2 years ago
by
dockx thibault
Browse files
Options
Download
Patches
Plain Diff
Fix(Snapshots) error reported by AT
Fixes error reported by Automated Test.
parent
18e12593
dev
6342-update-the-locales-for-1-5
6344-template-issue-when-creating-a-template-with-empty-password-error-message-should-not-be-seen
6365-core-locking-mechanism-is-not-changing-the-mail-ressource-it-does-lock-the-mail-account
6365-core-when-lock-mechanism-is-trigger-the-user-should-not-be-editable-if-not-unlock
6378-orcid-test-method-is-wrong-and-break-orcid-saving
core-php8
master
fusiondirectory-1.5
fusiondirectory-1.4
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/management/snapshot/class_SnapshotCreateDialog.inc
+5
-1
include/management/snapshot/class_SnapshotCreateDialog.inc
include/management/snapshot/class_SnapshotHandler.inc
+39
-26
include/management/snapshot/class_SnapshotHandler.inc
with
44 additions
and
27 deletions
+44
-27
include/management/snapshot/class_SnapshotCreateDialog.inc
+
5
−
1
View file @
29bcd870
...
@@ -91,7 +91,11 @@ class SnapshotCreateDialog extends ManagementDialog
...
@@ -91,7 +91,11 @@ class SnapshotCreateDialog extends ManagementDialog
public
function
getLdapRecordedDataSources
()
:
array
public
function
getLdapRecordedDataSources
()
:
array
{
{
global
$config
;
global
$config
;
$recordedDataSources
=
$config
->
current
[
'SNAPSHOTSOURCEDATA'
];
$recordedDataSources
=
[];
if
(
isset
(
$config
->
current
[
'SNAPSHOTSOURCEDATA'
])
&&
!
empty
(
$config
->
current
[
'SNAPSHOTSOURCEDATA'
]))
{
$recordedDataSources
=
$config
->
current
[
'SNAPSHOTSOURCEDATA'
];
}
return
$recordedDataSources
;
return
$recordedDataSources
;
}
}
...
...
This diff is collapsed.
Click to expand it.
include/management/snapshot/class_SnapshotHandler.inc
+
39
−
26
View file @
29bcd870
...
@@ -290,37 +290,50 @@ class SnapshotHandler
...
@@ -290,37 +290,50 @@ class SnapshotHandler
{
{
global
$config
;
global
$config
;
$snapMinRetention
=
$config
->
current
[
'SNAPSHOTMINRETENTION'
];
// In case the snap configuration has not set any numbers
$snapRetentionDays
=
$config
->
current
[
'SNAPSHOTRETENTIONDAYS'
];
if
(
isset
(
$config
->
current
[
'SNAPSHOTMINRETENTION'
])
&&
!
empty
(
$config
->
current
[
'SNAPSHOTMINRETENTION'
]))
{
$snapMinRetention
=
$config
->
current
[
'SNAPSHOTMINRETENTION'
];
}
else
{
$snapMinRetention
=
0
;
}
if
(
isset
(
$config
->
current
[
'SNAPSHOTRETENTIONDAYS'
])
&&
!
empty
(
$config
->
current
[
'SNAPSHOTRETENTIONDAYS'
]))
{
$snapRetentionDays
=
$config
->
current
[
'SNAPSHOTRETENTIONDAYS'
];
}
else
{
$snapRetentionDays
=
-
1
;
}
// calculate the epoch date on which snaps can be delete.
// calculate the epoch date on which snaps can be delete.
$todayMinusRetention
=
time
()
-
(
$snapRetentionDays
*
24
*
60
*
60
);
if
(
$snapRetentionDays
!==
1
)
{
$snapDateToDelete
=
strtotime
(
date
(
'Y-m-d H:i:s'
,
$todayMinusRetention
));
$todayMinusRetention
=
time
()
-
(
$snapRetentionDays
*
24
*
60
*
60
);
$snapDateToDelete
=
strtotime
(
date
(
'Y-m-d H:i:s'
,
$todayMinusRetention
));
$dnSnapshotsList
=
$this
->
getSnapshots
(
$dn
,
TRUE
);
$snapToDelete
=
[];
$dnSnapshotsList
=
$this
->
getSnapshots
(
$dn
,
TRUE
);
$snapCount
=
0
;
$snapToDelete
=
[];
$snapCount
=
0
;
if
(
isset
(
$dnSnapshotsList
)
&&
!
empty
(
$dnSnapshotsList
))
{
foreach
(
$dnSnapshotsList
as
$snap
)
{
// Generate an arrays with snapshot to delete due to overdate.
$snapCount
+=
1
;
if
(
isset
(
$dnSnapshotsList
)
&&
!
empty
(
$dnSnapshotsList
))
{
// let's keep seconds instead of nanosecs
foreach
(
$dnSnapshotsList
as
$snap
)
{
$snapEpoch
=
preg_split
(
'/-/'
,
$snap
[
'gosaSnapshotTimestamp'
][
0
]);
$snapCount
+=
1
;
if
(
$snapEpoch
[
0
]
<
$snapDateToDelete
)
{
// let's keep seconds instead of nanosecs
$snapToDelete
[]
=
$snap
[
'dn'
];
$snapEpoch
=
preg_split
(
'/-/'
,
$snap
[
'gosaSnapshotTimestamp'
][
0
]);
if
(
$snapEpoch
[
0
]
<
$snapDateToDelete
)
{
$snapToDelete
[]
=
$snap
[
'dn'
];
}
}
}
}
}
}
// The not empty is not mandatory but is more ressource friendly
// The not empty is not mandatory but is more ressource friendly
if
(
!
empty
(
$snapToDelete
)
&&
(
$snapCount
>
$snapMinRetention
))
{
if
(
!
empty
(
$snapToDelete
)
&&
(
$snapCount
>
$snapMinRetention
))
{
$snapToKeep
=
$snapCount
-
$snapMinRetention
;
$snapToKeep
=
$snapCount
-
$snapMinRetention
;
// Sort snapToDelete by old first DN timestamp is the only thing different.
// Sort snapToDelete by old first DN timestamp is the only thing different.
sort
(
$snapToDelete
);
sort
(
$snapToDelete
);
for
(
$i
=
0
;
$i
<
$snapToKeep
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$snapToKeep
;
$i
++
)
{
// not empty required because array keeps on being iterated even if NULL object.
// not empty required because array keeps on being iterated even if NULL object.
if
(
!
empty
(
$snapToDelete
[
$i
]))
{
if
(
!
empty
(
$snapToDelete
[
$i
]))
{
$this
->
removeSnapshot
(
$snapToDelete
[
$i
]);
$this
->
removeSnapshot
(
$snapToDelete
[
$i
]);
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets