php drupal-check.phar modules/contrib/toggle_editable_fields/
 6/6 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   tests/src/Functional/ToggleEditableFieldsUiTest.php                                                                                                   
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------ 
  18     Usage of deprecated trait Drupal\field_ui\Tests\FieldUiTestTrait in class Drupal\Tests\toggle_editable_fields\Functional\ToggleEditableFieldsUiTest.  
  83     Call to deprecated method strtolower() of class Drupal\Component\Utility\Unicode.                                                                     
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------ 

                                                                                                                        
 [ERROR] Found 2 errors
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Sergiu Stici created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB

Here is the patch, please review.

woprrr’s picture

Priority: Normal » Major
Status: Needs review » Needs work

@sergiu Can you check by the way Drupal 9 deprecation too ?

Thank you for your great job :) this help is very usefull

naveenvalecha’s picture

Assigned: Unassigned » naveenvalecha

Taking that up

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new3.66 KB
new2.52 KB

Here's the patch for that. We need to keep the libraries_get_path() because it's available only in the 8.9.x so we need to keep the fallback for those who're using the 8.7.x and 8.8.x drupal core

php drupal-check.phar modules/contrib/toggle_editable_fields/
 6/6 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------ 
  Line   toggle_editable_fields.install                                    
 ------ ------------------------------------------------------------------ 
  23     Call to deprecated function libraries_get_path():                 
         Will be removed before a stable Drupal 8 release. Please use the  
         new library load and managment concepts described at:             
         https://www.drupal.org/node/2170763                               
 ------ ------------------------------------------------------------------ 

                                                                                                                        
 [ERROR] Found 1 error
naveenvalecha’s picture

Assigned: naveenvalecha » Unassigned
  1. +++ b/toggle_editable_fields.info.yml
    @@ -2,6 +2,7 @@ name: Toggle Editable Fields
    +core_version_requirement: ^8.7 || ^9
    

    As core_version_requirement string introduced in drupal 8.7 so we need to restrict this https://www.drupal.org/node/3070687

  2. +++ b/toggle_editable_fields.install
    @@ -12,19 +12,25 @@ function toggle_editable_fields_requirements($phase) {
    +  if (\Drupal::hasService('library.libraries_directory_file_finder')) {
    

    This got introduced in 8.9 https://www.drupal.org/node/3099614 so we need to keep the fallback mechanism for 8.7 and 8.8 users

Also, can you run the module tests on 9.0.x?

Status: Needs review » Needs work

The last submitted patch, 5: 3082232-5.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
new493 bytes

Fixing the test failures of #5

The last submitted patch, 5: 3082232-5.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 8: 3082232-8.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
woprrr’s picture

Status: Needs review » Needs work

Great purpose :) ! Some nitpick and Clean code concerns.

  1. +++ b/toggle_editable_fields.info.yml
    @@ -1,7 +1,7 @@
    +core_version_requirement: ^8.7.7 || ^9
    

    We need to require more large version range (8||9)

  2. +++ b/toggle_editable_fields.install
    @@ -12,19 +12,25 @@ function toggle_editable_fields_requirements($phase) {
    +  if (\Drupal::hasService('library.libraries_directory_file_finder')) {
    +    /** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
    +    $library_file_finder = \Drupal::service('library.libraries_directory_file_finder');
    +    $library_found = (bool) $library_file_finder->find('bootstrap-toggle/js/bootstrap-toggle.min.js');
       }
    -
    -  // Is the library found in the root libraries path.
    -  $library_found = file_exists($path);
    -  // If library is not found, then look in the current profile libraries path.
    -  if (!$library_found) {
    -    $profile_path = drupal_get_path('profile', \Drupal::installProfile());
    -    $profile_path .= '/libraries/bootstrap-toggle/js/bootstrap-toggle.min.js';
    -    // Is the library found in the current profile libraries path.
    -    $library_found = file_exists($profile_path);
    +  else {
    +    $path = DRUPAL_ROOT . '/libraries/bootstrap-toggle/js/bootstrap-toggle.min.js';
    +    if (\Drupal::moduleHandler()->moduleExists('libraries')) {
    +      $path = libraries_get_path('bootstrap-toggle') . '/js/bootstrap-toggle.min.js';
    +    }
    +    // Is the library found in the root libraries path.
    +    $library_found = file_exists($path);
    +    // If library is not found, then look in the current profile libraries path.
    +    if (!$library_found) {
    +      $profile_path = drupal_get_path('profile', \Drupal::installProfile());
    +      $profile_path .= '/libraries/bootstrap-toggle/js/bootstrap-toggle.min.js';
    +      // Is the library found in the current profile libraries path.
    +      $library_found = file_exists($profile_path);
    +    }
    

    We can refactor this to reduce / move complexity & improve readability a lot (Clean code \o\).

    Other nitpick :
    Remove obscure comment on method body.
    Found better variable name to understand what we do (that help to remove comment).
    reduce complexity by removing if/else use only if() and respect only 1 level or MAX 2 if not possible.
    The suffix of boostrap-toogle js file are hardcoded a lot we can variabilize it.
    Name of D9 service for library can be variabilized.

woprrr’s picture

Status: Needs work » Needs review
StatusFileSize
new4.99 KB
new4.04 KB

Fast review and nitpick fixes.

woprrr’s picture

StatusFileSize
new4.99 KB

Lets re-roll that :D

david.qdoscc made their first commit to this issue’s fork.

vladimiraus’s picture

Status: Needs review » Needs work
Parent issue: » #3141919: Automated Drupal Rector fixes

Versions 8 and 9 are no longer supported.
Very similar issue is here: #3141919: Automated Drupal Rector fixes. Please move your changes over to this issue.

vladimiraus’s picture

Status: Needs work » Fixed

Thank you for your contribution.
Approved and commited.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.