mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
issue #1827 new check on filesystem compared to what is listed in the database
While not fixing issue #1827 it helps users to detect if they have been affected by the problem.
This commit is contained in:
25
admin.php
25
admin.php
@@ -29,6 +29,31 @@ check_status(ACCESS_ADMINISTRATOR);
|
||||
check_input_parameter('page', $_GET, false, '/^[a-zA-Z\d_-]+$/');
|
||||
check_input_parameter('section', $_GET, false, '/^[a-z]+[a-z_\/-]*(\.php)?$/i');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Filesystem checks |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if ($conf['fs_quick_check_period'] > 0)
|
||||
{
|
||||
$perform_fsqc = false;
|
||||
if (isset($conf['fs_quick_check_last_check']))
|
||||
{
|
||||
if (strtotime($conf['fs_quick_check_last_check']) < strtotime($conf['fs_quick_check_period'].' seconds ago'))
|
||||
{
|
||||
$perform_fsqc = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$perform_fsqc = true;
|
||||
}
|
||||
|
||||
if ($perform_fsqc)
|
||||
{
|
||||
fs_quick_check();
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Direct actions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -3458,6 +3458,79 @@ function get_cache_size_derivatives($path)
|
||||
return $msizes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a header warning if we find missing photos on a random sample.
|
||||
*
|
||||
* @since 13.4.0
|
||||
*/
|
||||
function fs_quick_check()
|
||||
{
|
||||
global $page, $conf;
|
||||
|
||||
if ($conf['fs_quick_check_period'] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($page[__FUNCTION__.'_already_called']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$page[__FUNCTION__.'_already_called'] = true;
|
||||
conf_update_param('fs_quick_check_last_check', date('c'));
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
id
|
||||
FROM '.IMAGES_TABLE.'
|
||||
WHERE date_available < \'2022-12-08 00:00:00\'
|
||||
AND path LIKE \'./upload/%\'
|
||||
LIMIT 5000
|
||||
;';
|
||||
$issue1827_ids = query2array($query, null, 'id');
|
||||
shuffle($issue1827_ids);
|
||||
$issue1827_ids = array_slice($issue1827_ids, 0, 50);
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
id
|
||||
FROM '.IMAGES_TABLE.'
|
||||
LIMIT 5000
|
||||
;';
|
||||
$random_image_ids = query2array($query, null, 'id');
|
||||
shuffle($random_image_ids);
|
||||
$random_image_ids = array_slice($random_image_ids, 0, 50);
|
||||
|
||||
$fs_quick_check_ids = array_unique(array_merge($issue1827_ids, $random_image_ids));
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
path
|
||||
FROM '.IMAGES_TABLE.'
|
||||
WHERE id IN ('.implode(',', $fs_quick_check_ids).')
|
||||
;';
|
||||
$fsqc_paths = query2array($query, 'id', 'path');
|
||||
|
||||
foreach ($fsqc_paths as $id => $path)
|
||||
{
|
||||
if (!file_exists($path))
|
||||
{
|
||||
global $template;
|
||||
|
||||
$template->assign(
|
||||
'header_msgs',
|
||||
array(
|
||||
l10n('Some photos are missing from your file system. Details provided by plugin Check Uploads'),
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return news from piwigo.org.
|
||||
*
|
||||
|
||||
@@ -552,6 +552,7 @@ class updates
|
||||
// changes. Anyway, a compiled template purge will be performed
|
||||
// by upgrade.php
|
||||
$template->delete_compiled_templates();
|
||||
conf_delete_param('fs_quick_check_last_check');
|
||||
|
||||
$page['infos'][] = l10n('Update Complete');
|
||||
$page['infos'][] = $upgrade_to;
|
||||
|
||||
@@ -73,6 +73,8 @@ if ($nb_orphans > 0)
|
||||
$page['warnings'][] = $message;
|
||||
}
|
||||
|
||||
fs_quick_check();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
fs_quick_check();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | actions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -280,6 +280,13 @@ $conf['stat_compare_year_displayed'] = 5;
|
||||
// Limit for linked albums search
|
||||
$conf['linked_album_search_limit'] = 100;
|
||||
|
||||
// how often should we check for missing photos in the filesystem. Only in the
|
||||
// administration. Consider the fs_quick_check is always performed on
|
||||
// dashboard and maintenance pages. This setting is only for any other
|
||||
// administration page.
|
||||
// 0 to disable.
|
||||
$conf['fs_quick_check_period'] = 24*60*60;
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | email |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -1325,4 +1325,5 @@ $lang['If anything bad happens during the update, you would be able to restore a
|
||||
$lang['Apply to root albums'] = 'Apply to root albums';
|
||||
$lang['Album name must not be empty'] = 'Album name must not be empty';
|
||||
$lang['Visit history'] = 'Visit history';
|
||||
$lang['Some photos are missing from your file system. Details provided by plugin Check Uploads'] = 'Some photos are missing from your file system. Details provided by plugin Check Uploads';
|
||||
// Leave this line empty
|
||||
|
||||
@@ -1325,4 +1325,5 @@ $lang['If anything bad happens during the update, you would be able to restore a
|
||||
$lang['Apply to root albums'] = 'Appliquer aux albums racine';
|
||||
$lang['Album name must not be empty'] = 'Le nom de l\'album ne doit pas être vide';
|
||||
$lang['Visit history'] = 'Historique des visites';
|
||||
$lang['Some photos are missing from your file system. Details provided by plugin Check Uploads'] = 'Des photos sont absentes de votre système de fichier. À contrôler avec le plugin Check Uploads.';
|
||||
// Leave this line empty
|
||||
|
||||
Reference in New Issue
Block a user