- Issue created by @lazzyvn
- 🇮🇳India shashank5563 New Delhi
Thank you for applying! Reviewers will review the project files, describing what needs to be changed.
Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.
To reviewers: Please read How to review security advisory coverage applications → , What to cover in an application review → , and Drupal.org security advisory coverage application workflow → .
While this application is open, only the user who opened the application can make commits to the project used for the application.
Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.
- 🇮🇳India vinaymahale
Ran PHPCS tests. No issues were found. Let's wait for other reviewers
- 🇮🇳India shashank5563 New Delhi
@lazzyvn , I have reviewed the changes, and they look fine to me.
Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.
- 🇮🇳India vinaymahale
I am changing priority as per Issue priorities.
- 🇲🇩Moldova andrei.vesterli Chisinau
Hi @lazzyvn
First of all, good job, and thx for the contribution to Drupal community! Here you can find some issues to fix:
-
File:
js/ocr-image.js
Line 10:let editorId = $("textarea[name*='" + field + "[0][value]']").prop("id"); if(typeof CKEDITOR !== 'undefined' && CKEDITOR.instances[editorId] != undefined){ let editor = CKEDITOR.instances[editorId].setData(ocr); } if(typeof CKEditor5 !== 'undefined'){ editorId = $("textarea[name*='" + field + "[0][value]']").data("ckeditor5-id"); let editor = Drupal.CKEditor5Instances.get(editorId).setData(ocr); } I don't see any purpose of these lines. You can simply remove them.
-
File:
js/orc-image.js
Line: 1(function ($, Drupal, drupalSettings, once) {...
one > is not used, so, remove that from init. -
File:
composer.json
Line: 6"license": "GPL-2.0+",
Use"license": "GPL-2.0-or-later",
instead. Check this → documentation for more information about composer.json configuration. -
File:
src/Plugin/Field/TesseractLanguages.php
Class:TesseractLanguages
- Missing return type for the defined methods for ex:
tesseractConvertLang: string { ... }
- Usage of `t()` function is not correct. Just add the translation trait instead
Drupal\Core\StringTranslation\StringTranslationTrait
.
- Missing return type for the defined methods for ex:
-
Files:
src/Plugin/Field/FieldWidget/OcrImageWidget.php, src/Plugin/Field/FieldWidget/OcrFileWidget.php
Comments: Check the return type forgetLinesText, getPowerpointType
-
Code:
if (!empty($field_text_name = $this->getSetting('text_field'))) { $fid = $form_state->getValue($field_name); if (!empty($fid)) { if (is_array($fid)) { $fid = end($fid); if (is_array($fid) && !empty($fid["fids"])) { $fid = end($fid["fids"]); } } $file = File::load($fid); $uri = $file->getFileUri(); $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager') ->getViaUri($uri); $file_path = $stream_wrapper_manager->realpath(); $language = $this->getSetting('language'); if (empty($language)) { $language = TesseractLanguages::tesseractConvertLang(); } $line_datas = $this->getLinesText($file_path, $language, $this->getSetting('limit')); if (!empty($line_datas)) { $ocr = implode(PHP_EOL, $line_datas); $form_state->setValue($field_text_name, $ocr); $element["#default_value"]["description"] = $ocr; $element['#attached']['drupalSettings']['ocr_field_widget'] = [ 'field_name' => $field_name, 'field' => $field_text_name, 'ocr' => $ocr, ]; $element['#attached']['library'][] = 'ocr_image/ocr_image'; } } }
can be converted to something like:
if (!empty($field_text_name = $this->getSetting('text_field')) && $fid = $form_state->getValue($field_name) && !empty($fid)) { if (is_array($fid)) { $fid = end($fid); if (is_array($fid) && !empty($fid["fids"])) { $fid = end($fid["fids"]); } } $file = File::load($fid); $uri = $file->getFileUri(); $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager')->getViaUri($uri); $file_path = $stream_wrapper_manager->realpath(); $language = $this->getSetting('language'); if (empty($language)) { $language = TesseractLanguages::tesseractConvertLang(); } $line_datas = $this->getLinesText($file_path, $language, $this->getSetting('limit')); if (!empty($line_datas)) { $ocr = implode(PHP_EOL, $line_datas); $form_state->setValue($field_text_name, $ocr); $element["#default_value"]["description"] = $ocr; $element['#attached']['drupalSettings']['ocr_field_widget'] = [ 'field_name' => $field_name, 'field' => $field_text_name, 'ocr' => $ocr, ]; $element['#attached']['library'][] = 'ocr_image/ocr_image'; } }
- Convert file
Readme.md
into theREAMDE.md
. Provide proper basic module documentation. See this → example.
-
File:
- Status changed to Needs work
over 1 year ago 8:29am 11 September 2023 - 🇫🇷France lazzyvn paris
@andrei.vesterli
thank you for your correction.
but i don't know how to fix thisUsing the t() function is not correct. Just add the translation trait instead Drupal\Core\StringTranslation\StringTranslationTrait.
This is a static method (public static function), so I think we cann't use StringTranslationTrait and replace t() with $this->t(), right?
another point is fixed in branch dev - 🇲🇩Moldova andrei.vesterli Chisinau
As a variant:
use Drupal\Core\StringTranslation\TranslatableMarkup; // Usage new TranslatableMarkup('Some string');
- 🇫🇷France lazzyvn paris
@andrei.vesterli
I tested the code in Drupal 9.5 and 10.1.2, it doesn't work when uploading a pdf, image, docx file. revert to old code, it works fine
I don't know why it can't get fid as number after upload.if (!empty($field_text_name = $this->getSetting('text_field')) && $fid = $form_state->getValue($field_name) && !empty($fid)) {
- 🇲🇩Moldova andrei.vesterli Chisinau
Hi @lazzyvn
No worries. Leave as you did then. I have no other comments for now. Let's see someone else to review your module. Cheers man!
Regards,
Andrei - Status changed to Needs review
over 1 year ago 8:47am 12 September 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
- Dries → ' post on Responsible maintainers
- Best practices for creating and maintaining projects →
- Maintaining a drupal.org project with Git →
- Commit messages - providing history and credit →
- Release naming conventions → .
- Helping maintainers in the issue queues →
You can find more contributors chatting on the Slack → #contribute channel. So, come hang out and stay involved → .
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review → . I encourage you to learn more about that process and join the group of reviewers.I thank all the reviewers.
- Assigned to apaderno
- Status changed to Fixed
over 1 year ago 12:38pm 27 September 2023 Automatically closed - issue fixed for 2 weeks with no activity.