1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
documentfilescleanup.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Catalog\Update;
4
5
use Bitrix\Catalog\StoreDocumentFileTable;
6
7
class
DocumentFilesCleanup
8
{
9
public
static
function
execAgent
(): string
10
{
11
$connection
=
\Bitrix\Main\Application::getConnection
();
12
$helper =
$connection
->getSqlHelper();
13
$queryResult =
$connection
->query(
'
14
select doc_files.ID, FILE_ID from b_catalog_store_document_file doc_files
15
left outer join b_catalog_store_docs docs
16
on docs.ID = doc_files.DOCUMENT_ID
17
where docs.ID is null
18
limit 50
19
'
);
20
$documentFiles = $queryResult->fetchAll();
21
22
if
(empty($documentFiles))
23
{
24
return
''
;
25
}
26
27
$filesToRemove = array_column($documentFiles,
'FILE_ID'
);
28
$entriesToRemove = array_column($documentFiles,
'ID'
);
29
30
foreach
($filesToRemove as $fileId)
31
{
32
\CFile::Delete($fileId);
33
}
34
35
$entriesForQuery = implode(
','
, $entriesToRemove);
36
37
$connection
->queryExecute(
38
'delete from '
. $helper->quote(
StoreDocumentFileTable::getTableName
())
39
.
' where '
. $helper->quote(
'ID'
) .
' in ('
. $entriesForQuery .
')'
40
);
41
42
$isCleanupOver = !(bool)
$connection
->query(
'
43
select doc_files.ID, FILE_ID from b_catalog_store_document_file doc_files
44
left outer join b_catalog_store_docs docs
45
on docs.ID = doc_files.DOCUMENT_ID
46
where docs.ID is null
47
limit 1
48
'
)->fetch();
49
50
if
($isCleanupOver)
51
{
52
return
''
;
53
}
54
55
return
'\Bitrix\Catalog\Update\DocumentFilesCleanup::execAgent();'
;
56
}
57
}
$connection
$connection
Определения
actionsdefinitions.php:38
Bitrix\Catalog\StoreDocumentFileTable\getTableName
static getTableName()
Определения
storedocumentfiletable.php:44
Bitrix\Catalog\Update\DocumentFilesCleanup
Определения
documentfilescleanup.php:8
Bitrix\Catalog\Update\DocumentFilesCleanup\execAgent
static execAgent()
Определения
documentfilescleanup.php:9
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
bitrix
modules
catalog
lib
update
documentfilescleanup.php
Создано системой
1.14.0