From 1929941d838a0380efca304225cafb004521a886 Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Tue, 10 Oct 2023 20:00:00 +0000 Subject: [PATCH] Version 6.9.5 --- FUNDING.yml | 1 - README.md | 4 +- composer.json | 14 ------- .../Luigifab/Apijs/Helper/Rewrite/Image.php | 6 +-- .../Luigifab/Apijs/Model/Observer.php | 14 ++++--- .../community/Luigifab/Apijs/Model/Python.php | 15 ++++--- .../Apijs/Model/Rewrite/Categoryimg.php | 4 +- .../Apijs/Model/Rewrite/Productimg.php | 4 +- .../controllers/Apijs/WysiwygController.php | 6 +-- .../community/Luigifab/Apijs/etc/config.xml | 4 +- .../community/Luigifab/Apijs/lib/image.py | 42 +++++++++++-------- src/shell/apijs-clean-images.php | 20 ++++++--- .../css/luigifab/apijs/apijs-openmage.css | 4 +- .../css/luigifab/apijs/apijs-openmage.min.css | 2 +- .../luigifab/apijs/apijs-openmage.min.css.map | 2 +- .../css/luigifab/apijs/apijs-print.min.css | 4 +- .../luigifab/apijs/apijs-print.min.css.map | 2 +- .../luigifab/apijs/apijs-screen-rtl.min.css | 4 +- .../apijs/apijs-screen-rtl.min.css.map | 2 +- .../css/luigifab/apijs/apijs-screen.min.css | 4 +- .../luigifab/apijs/apijs-screen.min.css.map | 2 +- .../default/js/luigifab/apijs/apijs.min.js | 4 +- .../js/luigifab/apijs/apijs.min.js.map | 2 +- .../css/luigifab/apijs/apijs-print.min.css | 4 +- .../luigifab/apijs/apijs-print.min.css.map | 2 +- .../luigifab/apijs/apijs-screen-rtl.min.css | 4 +- .../apijs/apijs-screen-rtl.min.css.map | 2 +- .../css/luigifab/apijs/apijs-screen.min.css | 4 +- .../luigifab/apijs/apijs-screen.min.css.map | 2 +- .../default/js/luigifab/apijs/apijs.min.js | 4 +- .../js/luigifab/apijs/apijs.min.js.map | 2 +- 31 files changed, 101 insertions(+), 89 deletions(-) delete mode 100644 FUNDING.yml diff --git a/FUNDING.yml b/FUNDING.yml deleted file mode 100644 index eda3c7b..0000000 --- a/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ["https://fr.tipeee.com/luigifab", "https://gandi.link/f/4b904048", "https://ekwateur.fr/?parrain=EKW001147103", "https://www.ebuyclub.com/?parrain=ebc4"] \ No newline at end of file diff --git a/README.md b/README.md index 9e4cdf6..c514500 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ For more information, go to https://www.luigifab.fr/apijs and https://www.luigif This repository is a releases mirror. To install the module, please use the composer key available in the documentation. -- Current version: 6.9.4 (06/06/2023) -- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2, Python 3.3+ +- Current version: 6.9.5 (10/10/2023) +- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3, Python 3.3+ - Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+ - Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es) / Chinese (zh), Czech (cs), Dutch (nl), Greek (el), Hungarian (hu), Japanese (ja), Polish (pl), Romanian (ro), Russian (ru), Slovak (sk), Turkish (tr), Ukrainian (uk) - License: GNU GPL 2+ diff --git a/composer.json b/composer.json index 0ba05c7..69b0540 100644 --- a/composer.json +++ b/composer.json @@ -16,20 +16,6 @@ "issues": "https://github.com/luigifab/openmage-apijs/issues", "docs": "https://www.luigifab.fr/openmage/apijs" }, - "funding": [ - { - "type": "other", - "url": "https://gandi.link/f/4b904048" - }, - { - "type": "other", - "url": "https://fr.tipeee.com/luigifab" - }, - { - "type": "other", - "url": "https://ekwateur.fr/?parrain=EKW001147103" - } - ], "require": { "php": ">=7.2.0", "openmage/magento-lts": ">=19.4.0 || main-dev || next-dev", diff --git a/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php b/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php index b40b036..d0cfa43 100644 --- a/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php +++ b/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php @@ -1,7 +1,7 @@ * Copyright 2019-2023 | Fabrice Creuzot @@ -133,9 +133,9 @@ public function init($object, $attribute, $path = null, $fixed = true, $webp = f // ajoute l'id pour éviter une boucle infini foreach (explode('/', $full) as $word) - $short .= substr($word, 0, $idx); + $short .= substr($word, 0, $idx); // not mb_substr while (in_array('/media/'.$short.'/', $this->_cacheConfig['list_replace'])) - $short .= substr($word.$key, ++$idx, 1); + $short .= substr($word.$key, ++$idx, 1); // not mb_substr // $dir $short => /var/www/xyz/web/media wc // $dir $full => /var/www/xyz/web/media wysiwyg/cache diff --git a/src/app/code/community/Luigifab/Apijs/Model/Observer.php b/src/app/code/community/Luigifab/Apijs/Model/Observer.php index a02b0cd..6e183e3 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Observer.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Observer.php @@ -1,7 +1,7 @@ * https://github.com/luigifab/openmage-apijs @@ -86,9 +86,10 @@ public function removeProductImages(Varien_Event_Observer $observer) { // EVENT controller_action_predispatch_adminhtml_catalog_product_save (adminhtml) public function updatePostForGallery(Varien_Event_Observer $observer) { - $post = $observer->getData('controller_action')->getRequest()->getPost(); - $productId = $observer->getData('controller_action')->getRequest()->getParam('id', 0); - $storeId = $observer->getData('controller_action')->getRequest()->getParam('store', 0); + $request = $observer->getData('controller_action')->getRequest(); + $post = $request->getPost(); + $productId = $request->getParam('id', 0); + $storeId = $request->getParam('store', 0); if (!empty($post['apijs'])) { @@ -97,7 +98,7 @@ public function updatePostForGallery(Varien_Event_Observer $observer) { $fields = $product->getResource()->getAttribute('media_gallery')->getBackend()->getAllColumns(); $gallery = []; - // simule ce que fait le js du core, quel bordel + // fait ce que fait le js du core, quel bordel foreach ($post['apijs'] as $imageId => $image) { if (!is_array($image) || !array_key_exists('file', $image)) { @@ -136,10 +137,13 @@ public function updatePostForGallery(Varien_Event_Observer $observer) { if (!empty($value) && ($field['Field'] == 'label')) { $values[$field['Field']] = stripslashes($value); $values[$field['Field'].'_default'] = stripslashes($value); + $values[$field['Field'].'_use_default'] = ($value == null); // PR 2481 // null when $$ when checked } else { $values[$field['Field']] = $value; $values[$field['Field'].'_default'] = $value; + if ($field['Field'] == 'position') + $values[$field['Field'].'_use_default'] = ($value == null); // null when $$ when checked } } } diff --git a/src/app/code/community/Luigifab/Apijs/Model/Python.php b/src/app/code/community/Luigifab/Apijs/Model/Python.php index 8e43976..6e58331 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Python.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Python.php @@ -1,7 +1,7 @@ * https://github.com/luigifab/openmage-apijs @@ -128,8 +128,14 @@ public function save($destination = null, $newFilename = null, $immediate = fals try { $this->initCommands(); - $core = max(1, $this->_core - 2); - while (count($this->_pids) >= $core) { + + // leaves 2 cores free, but because $runs include grep check, we add 2 for $maxc + // [] => 18:14 0:00 /usr/bin/python3 ... + // [] => 18:14 0:00 sh -c ps aux | grep Apijs/lib/image.py + // [] => 18:14 0:00 grep Apijs/lib/image.py + $maxc = 2 + max(1, $this->_core - 2); + + while (count($this->_pids) >= $maxc) { foreach ($this->_pids as $key => $pid) { if (file_exists('/proc/'.$pid)) clearstatcache('/proc/'.$pid); @@ -140,8 +146,7 @@ public function save($destination = null, $newFilename = null, $immediate = fals } exec('ps aux | grep Apijs/lib/image.py', $runs); - $core = ceil($core * 1.5); - while (count($runs) >= $core) { + while (count($runs) >= $maxc) { usleep(90000); // 0.09 s $runs = []; exec('ps aux | grep Apijs/lib/image.py', $runs); diff --git a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Categoryimg.php b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Categoryimg.php index 412da48..4789ece 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Categoryimg.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Categoryimg.php @@ -1,7 +1,7 @@ * Copyright 2019-2023 | Fabrice Creuzot @@ -20,7 +20,7 @@ class Luigifab_Apijs_Model_Rewrite_Categoryimg extends Mage_Catalog_Model_Category_Attribute_Backend_Image { - public function getAllowedExtensions() { + public function getAllowedExtensions():array { // PR 3301 return Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions('image'); } diff --git a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Productimg.php b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Productimg.php index 4005c44..8fe2f49 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Productimg.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Productimg.php @@ -1,7 +1,7 @@ * Copyright 2019-2023 | Fabrice Creuzot @@ -20,7 +20,7 @@ class Luigifab_Apijs_Model_Rewrite_Productimg extends Mage_Catalog_Model_Resource_Product_Attribute_Backend_Image { - public function getAllowedExtensions() { + public function getAllowedExtensions():array { // PR 3301 return Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions('image'); } diff --git a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php index 09fd83f..f3e49dc 100644 --- a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php +++ b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php @@ -1,7 +1,7 @@ * Copyright 2019-2023 | Fabrice Creuzot @@ -59,7 +59,7 @@ public function deleteFolderAction() { $cache = trim('wysiwyg/'.str_replace([$base, Mage::getBaseDir('media').'/', '//'], ['', '', '/'], $path), '/'); // s'assure que le dossier à supprimer est bien dans le dossier media/wysiwyg - if (!empty($path) && (stripos($path, $base) === 0) && (trim($path, '/') != trim($base, '/'))) { + if (!empty($path) && (mb_stripos($path, $base) === 0) && (trim($path, '/') != trim($base, '/'))) { // supprime les images en cache foreach ($files as $file) { @@ -94,7 +94,7 @@ public function deleteFilesAction() { $cache = trim('wysiwyg/'.str_replace([$base, Mage::getBaseDir('media').'/', '//'], ['', '', '/'], $path), '/'); // s'assure que les fichiers à supprimer sont bien dans le dossier media/wysiwyg - if (!empty($path) && (stripos($path, $base) === 0)) { + if (!empty($path) && (mb_stripos($path, $base) === 0)) { foreach ($files as $file) { diff --git a/src/app/code/community/Luigifab/Apijs/etc/config.xml b/src/app/code/community/Luigifab/Apijs/etc/config.xml index 346b775..af3785f 100644 --- a/src/app/code/community/Luigifab/Apijs/etc/config.xml +++ b/src/app/code/community/Luigifab/Apijs/etc/config.xml @@ -1,7 +1,7 @@