Skip to content

Commit d630d9f

Browse files
committed
upd to 0.11.2
1 parent 5430927 commit d630d9f

File tree

13 files changed

+122
-52
lines changed

13 files changed

+122
-52
lines changed

migrations/0.11.2.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* User: darkfriend <hi@darkfriend.ru>
4+
* Date: 17.03.2025
5+
* Time: 19:34
6+
*/
7+
8+
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
9+
10+
$curModuleName = 'dev2fun.imagecompress';
11+
\Bitrix\Main\Loader::includeModule('main');
12+
\Bitrix\Main\Loader::includeModule($curModuleName);
13+
14+
\Bitrix\Main\Loader::registerAutoLoadClasses(
15+
$curModuleName,
16+
[
17+
'Dev2funImageCompress' => 'include.php',
18+
'Dev2fun\ImageCompress\ImageCompressImagesTable' => 'classes/general/ImageCompressImagesTable.php',
19+
'Dev2fun\ImageCompress\ImageCompressImagesConvertedTable' => 'classes/general/ImageCompressImagesConvertedTable.php',
20+
]
21+
);
22+
23+
try {
24+
25+
/** @var Main\DB\MysqlCommonConnection $connection */
26+
$connection = \Dev2fun\ImageCompress\ImageCompressImagesTable::getEntity()->getConnection();
27+
28+
$isTableExists = $connection->isTableExists(\Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName());
29+
if ($isTableExists && !$connection->isIndexExists(\Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
30+
$connection->createIndex(
31+
\Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName(),
32+
'indx_image_hash',
33+
['IMAGE_HASH', 'IMAGE_IGNORE']
34+
);
35+
}
36+
37+
$isTableExists = $connection->isTableExists(\Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName());
38+
if ($isTableExists && !$connection->isIndexExists(\Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName(), ['ORIGINAL_IMAGE_HASH'])) {
39+
$connection->createIndex(
40+
\Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName(),
41+
'indx_original_image_hash',
42+
['ORIGINAL_IMAGE_HASH']
43+
);
44+
}
45+
46+
\Dev2funImageCompress::ShowThanksNotice();
47+
48+
die("0.11.2 - Success");
49+
50+
} catch (Throwable $e) {
51+
ShowError($e->getMessage());
52+
}

utf8/dev2fun.imagecompress/classes/general/ImageCompressImagesTable.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
4-
* @version 0.8.3
4+
* @version 0.11.2
55
*/
66

77
namespace Dev2fun\ImageCompress;
@@ -95,6 +95,14 @@ public static function createTable()
9595
'indx_date_check',
9696
['DATE_CHECK']
9797
);
98+
99+
if (!$connection->isIndexExists(static::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
100+
$connection->createIndex(
101+
static::getTableName(),
102+
'indx_image_hash',
103+
['IMAGE_HASH', 'IMAGE_IGNORE']
104+
);
105+
}
98106
}
99107

100108
/**

utf8/dev2fun.imagecompress/install/index.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
44
* @copyright dev2fun
5-
* @version 0.11.0
5+
* @version 0.11.2
66
*/
77
defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
88
\Bitrix\Main\Localization\Loc::loadMessages(__FILE__);
@@ -296,6 +296,15 @@ public function installFiles()
296296
public function unInstallDB()
297297
{
298298
$connection = Application::getInstance()->getConnection();
299+
300+
if (ImageCompressImagesToConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesToConvertedTable::getTableName())) {
301+
ImageCompressImagesToConvertedTable::dropTable();
302+
}
303+
304+
if (ImageCompressImagesConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesConvertedTable::getTableName())) {
305+
ImageCompressImagesConvertedTable::dropTable();
306+
}
307+
299308
// $connection->dropTable(ImageCompressTable::getTableName());
300309
if (ImageCompressTable::getEntity()->getConnection()->isTableExists(ImageCompressTable::getTableName())) {
301310
$connection->dropTable(ImageCompressTable::getTableName());
@@ -305,12 +314,6 @@ public function unInstallDB()
305314
if (ImageCompressImagesTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesTable::getTableName())) {
306315
ImageCompressImagesTable::dropTable();
307316
}
308-
if (ImageCompressImagesConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesConvertedTable::getTableName())) {
309-
ImageCompressImagesConvertedTable::dropTable();
310-
}
311-
if (ImageCompressImagesToConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesToConvertedTable::getTableName())) {
312-
ImageCompressImagesToConvertedTable::dropTable();
313-
}
314317

315318
Option::delete($this->MODULE_ID);
316319
return true;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
$arModuleVersion = [
3-
'VERSION' => '0.11.1',
4-
'VERSION_DATE' => '2025-02-19 02:30:00',
3+
'VERSION' => '0.11.2',
4+
'VERSION_DATE' => '2025-03-17 00:30:00',
55
];

utf8/dev2fun.imagecompress/lib/Convert.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
44
* @copyright dev2fun
5-
* @version 0.11.1
5+
* @version 0.11.2
66
*/
77

88
namespace Dev2fun\ImageCompress;
@@ -820,7 +820,7 @@ function () use ($arFiles) {
820820
$rows[] = [
821821
// 'SITE_ID' => Dev2funImageCompress::getSiteId(),
822822
'IMAGE_PATH' => $file,
823-
'IMAGE_HASH' => $md5,
823+
'=IMAGE_HASH' => $md5,
824824
// 'DATE_CREATE' => new SqlExpression("NOW()"),
825825
'IMAGE_IGNORE' => 'N',
826826
// 'IMAGE_PROCESSED' => 'N',
@@ -863,11 +863,11 @@ function () use ($arFiles) {
863863
function () use ($arFiles) {
864864
$filter = [
865865
// 'IMAGE_PROCESSED' => 'Y',
866-
'Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_PROCESSED' => 'Y',
867-
'Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_TYPE' => self::getInstance()->getImageTypeByAlgorithm(
866+
'=Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_PROCESSED' => 'Y',
867+
'=Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_TYPE' => self::getInstance()->getImageTypeByAlgorithm(
868868
self::getInstance()->algorithm
869869
),
870-
'IMAGE_IGNORE' => 'N',
870+
'=IMAGE_IGNORE' => 'N',
871871
];
872872
$imagesHash = [];
873873
$arFilesHash = [];
@@ -889,8 +889,6 @@ function () use ($arFiles) {
889889
$arFilesHash[$hash][] = $file;
890890
}
891891

892-
893-
894892
// var_dump(empty($currentFiles[$md5]));
895893

896894
// $imagesHash[] = md5_file($_SERVER['DOCUMENT_ROOT'].$file);
@@ -905,7 +903,7 @@ function () use ($arFiles) {
905903
return [];
906904
}
907905
$filter[] = [
908-
'IMAGE_HASH', 'in', array_unique($imagesHash),
906+
'=IMAGE_HASH' => array_unique($imagesHash),
909907
];
910908
$images = ImageCompressImagesTable::getList([
911909
'select' => [
@@ -1274,7 +1272,7 @@ public static function ConvertImageOnFileDeleteEvent(array $arFile)
12741272

12751273
$items = ImageCompressImagesConvertedTable::getList([
12761274
'filter' => [
1277-
'IMAGE_ID' => $arFile['ID'],
1275+
'=IMAGE_ID' => $arFile['ID'],
12781276
],
12791277
])->fetchAll();
12801278

utf8/dev2fun.imagecompress/lib/LazyConvert.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
4-
* @version 0.11.0
4+
* @version 0.11.2
55
*/
66

77
namespace Dev2fun\ImageCompress;
@@ -114,8 +114,8 @@ public static function convertItems(array $images)
114114
$duplicateImages = ImageCompressImagesConvertedTable::getList([
115115
'select' => ['ID', 'ORIGINAL_IMAGE_HASH'],
116116
'filter' => [
117-
'ORIGINAL_IMAGE_HASH' => $imagesHash,
118-
'IMAGE_TYPE' => $algImageType,
117+
'=ORIGINAL_IMAGE_HASH' => $imagesHash,
118+
'=IMAGE_TYPE' => $algImageType,
119119
],
120120
]);
121121
$arDuplicateImages = [];
@@ -248,7 +248,7 @@ public static function findFiles(array $arFiles = []): array
248248
return $arFiles;
249249
}
250250
$filter = [
251-
'Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_TYPE' => Convert::getInstance()->getImageTypeByAlgorithm(
251+
'=Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable:IMAGE.IMAGE_TYPE' => Convert::getInstance()->getImageTypeByAlgorithm(
252252
Convert::getInstance()->algorithm
253253
),
254254
];
@@ -265,7 +265,7 @@ public static function findFiles(array $arFiles = []): array
265265
return [];
266266
}
267267
$filter[] = [
268-
'IMAGE_HASH', 'in', $imagesHash,
268+
'=IMAGE_HASH' => $imagesHash,
269269
];
270270
$images = ImageCompressImagesTable::getList([
271271
'select' => [

utf8/dev2fun.imagecompress/tabs/convert.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
44
* @copyright dev2fun
5-
* @version 0.11.0
5+
* @version 0.11.2
66
*/
77
defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
88

@@ -192,7 +192,7 @@
192192
<input
193193
type="checkbox"
194194
name="convert_enable_clear_cache"
195-
value="N"
195+
value="Y"
196196
<?php
197197
if (Option::get($curModuleName, 'convert_enable_clear_cache', 'N') === 'Y') {
198198
echo 'checked';

win1251/dev2fun.imagecompress/classes/general/ImageCompressImagesTable.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
4-
* @version 0.8.3
4+
* @version 0.11.2
55
*/
66

77
namespace Dev2fun\ImageCompress;
@@ -95,6 +95,14 @@ public static function createTable()
9595
'indx_date_check',
9696
['DATE_CHECK']
9797
);
98+
99+
if (!$connection->isIndexExists(static::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
100+
$connection->createIndex(
101+
static::getTableName(),
102+
'indx_image_hash',
103+
['IMAGE_HASH', 'IMAGE_IGNORE']
104+
);
105+
}
98106
}
99107

100108
/**

win1251/dev2fun.imagecompress/install/index.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @author darkfriend <hi@darkfriend.ru>
44
* @copyright dev2fun
5-
* @version 0.11.0
5+
* @version 0.11.2
66
*/
77
defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
88
\Bitrix\Main\Localization\Loc::loadMessages(__FILE__);
@@ -296,6 +296,15 @@ public function installFiles()
296296
public function unInstallDB()
297297
{
298298
$connection = Application::getInstance()->getConnection();
299+
300+
if (ImageCompressImagesToConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesToConvertedTable::getTableName())) {
301+
ImageCompressImagesToConvertedTable::dropTable();
302+
}
303+
304+
if (ImageCompressImagesConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesConvertedTable::getTableName())) {
305+
ImageCompressImagesConvertedTable::dropTable();
306+
}
307+
299308
// $connection->dropTable(ImageCompressTable::getTableName());
300309
if (ImageCompressTable::getEntity()->getConnection()->isTableExists(ImageCompressTable::getTableName())) {
301310
$connection->dropTable(ImageCompressTable::getTableName());
@@ -305,12 +314,6 @@ public function unInstallDB()
305314
if (ImageCompressImagesTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesTable::getTableName())) {
306315
ImageCompressImagesTable::dropTable();
307316
}
308-
if (ImageCompressImagesConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesConvertedTable::getTableName())) {
309-
ImageCompressImagesConvertedTable::dropTable();
310-
}
311-
if (ImageCompressImagesToConvertedTable::getEntity()->getConnection()->isTableExists(ImageCompressImagesToConvertedTable::getTableName())) {
312-
ImageCompressImagesToConvertedTable::dropTable();
313-
}
314317

315318
Option::delete($this->MODULE_ID);
316319
return true;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
$arModuleVersion = [
3-
'VERSION' => '0.11.1',
4-
'VERSION_DATE' => '2025-02-19 02:30:00',
3+
'VERSION' => '0.11.2',
4+
'VERSION_DATE' => '2025-03-17 00:30:00',
55
];

0 commit comments

Comments
 (0)