Problem/Motivation

  • Fix coding standard errors by phpstan at d.o
    $ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
     ------ ---------------------------------------------------------------------------------- 
      Line   modules/cloud_cluster_worker/src/Form/Config/CloudClusterWorkerAdminSettings.php  
     ------ ---------------------------------------------------------------------------------- 
      267    Call to deprecated function watchdog_exception():                                 
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                           
               Use \Drupal\Core\Utility\Error::logException() instead.                         
     ------ ---------------------------------------------------------------------------------- 
     ------ ------------------------------------------------------------------ 
      Line   modules/cloud_service_providers/aws_cloud/aws_cloud.module        
     ------ ------------------------------------------------------------------ 
      1748   Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      2100   Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      2113   Call to deprecated method deleteRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
             instead.                                                          
      2174   Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
     ------ ------------------------------------------------------------------ 
     ------ ----------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceEditForm.php  
     ------ ----------------------------------------------------------------------------- 
      534    Call to deprecated method formatExample() of class                           
             Drupal\Core\Datetime\Element\Datetime:                                       
             in drupal:10.2.0 and is removed from drupal:11.0.0.                          
               There is no replacement.                                                   
     ------ ----------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php  
     ------ ---------------------------------------------------------------------------------------------- 
      5258   Call to deprecated method loadRevision() of class                                             
             Drupal\Core\Entity\EntityStorageInterface:                                                    
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                                       
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                                
             instead.                                                                                      
     ------ ---------------------------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/aws_cloud/src/Service/Ec2/Ec2BatchOperations.php  
     ------ ---------------------------------------------------------------------------------- 
      1580   Call to deprecated method loadRevision() of class                                 
             Drupal\Core\Entity\EntityStorageInterface:                                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                    
             instead.                                                                          
      1589   Call to deprecated method loadRevision() of class                                 
             Drupal\Core\Entity\EntityStorageInterface:                                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision                    
             instead.                                                                          
      1591   Call to deprecated method deleteRevision() of class                               
             Drupal\Core\Entity\EntityStorageInterface:                                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision                  
             instead.                                                                          
     ------ ---------------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/docker/src/Service/DockerService.php  
     ------ ---------------------------------------------------------------------- 
      410    Call to deprecated function watchdog_exception():                     
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use               
               Use \Drupal\Core\Utility\Error::logException() instead.             
     ------ ---------------------------------------------------------------------- 
     ------ --------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/k8s/k8s.module                       
     ------ --------------------------------------------------------------------- 
      790    Call to static method getOptionsListByRegion() on an unknown class   
             Drupal\Core\DateTime\TimeZoneFormHelper.                             
             💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
      1092   Call to deprecated method loadRevision() of class                    
             Drupal\Core\Entity\EntityStorageInterface:                           
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use              
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision       
             instead.                                                             
     ------ --------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/k8s/tests/src/Unit/Plugin/cloud/launch_template/K8sCloudLaunchTemplatePluginTest.php  
     ------ ---------------------------------------------------------------------------------------------------------------------- 
      79     Missing call to parent::setUp() method.                                                                               
     ------ ---------------------------------------------------------------------------------------------------------------------- 
     ------ ------------------------------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/k8s/tests/src/Unit/Plugin/cloud/project/K8sCloudProjectPluginTest.php  
     ------ ------------------------------------------------------------------------------------------------------- 
      89     Missing call to parent::setUp() method.                                                                
     ------ ------------------------------------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   modules/cloud_service_providers/openstack/openstack.module      
     ------ ---------------------------------------------------------------- 
      327    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ --------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/openstack/src/Service/Rest/OpenStackService.php  
     ------ --------------------------------------------------------------------------------- 
      8017   Call to deprecated function watchdog_exception():                                
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                          
               Use \Drupal\Core\Utility\Error::logException() instead.                        
     ------ --------------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/openstack/tests/src/Unit/Plugin/cloud/launch_template/OpenStackCloudLaunchTemplatePluginTest.php  
     ------ ---------------------------------------------------------------------------------------------------------------------------------- 
      71     Missing call to parent::setUp() method.                                                                                           
     ------ ---------------------------------------------------------------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/terraform/src/Service/TerraformService.php  
     ------ ---------------------------------------------------------------------------- 
      543    Call to deprecated function watchdog_exception():                           
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use                     
               Use \Drupal\Core\Utility\Error::logException() instead.                   
     ------ ---------------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------------- 
      Line   modules/cloud_service_providers/vmware/src/Service/VmwareService.php  
     ------ ---------------------------------------------------------------------- 
      436    Call to deprecated function watchdog_exception():                     
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use               
               Use \Drupal\Core\Utility\Error::logException() instead.             
     ------ ---------------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   src/Controller/CloudConfigController.php                        
     ------ ---------------------------------------------------------------- 
      109    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      132    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   src/Controller/CloudLaunchTemplateController.php                
     ------ ---------------------------------------------------------------- 
      120    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      143    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      188    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   src/Controller/CloudProjectController.php                       
     ------ ---------------------------------------------------------------- 
      120    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      143    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      186    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   src/Controller/CloudStoreController.php                         
     ------ ---------------------------------------------------------------- 
      119    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      142    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
      185    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ------------------------------------------------------------------ 
      Line   src/Form/CloudConfigRevisionDeleteForm.php                        
     ------ ------------------------------------------------------------------ 
      128    Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      138    Call to deprecated method deleteRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
             instead.                                                          
     ------ ------------------------------------------------------------------ 
     ------ ---------------------------------------------------------------- 
      Line   src/Form/CloudConfigRevisionRevertForm.php                      
     ------ ---------------------------------------------------------------- 
      132    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ------------------------------------------------------------------ 
      Line   src/Form/CloudLaunchTemplateRevisionDeleteForm.php                
     ------ ------------------------------------------------------------------ 
      131    Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      141    Call to deprecated method deleteRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
             instead.                                                          
     ------ ------------------------------------------------------------------ 
     ------ ---------------------------------------------------------------- 
      Line   src/Form/CloudLaunchTemplateRevisionRevertForm.php              
     ------ ---------------------------------------------------------------- 
      151    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ------------------------------------------------------------------ 
      Line   src/Form/CloudProjectRevisionDeleteForm.php                       
     ------ ------------------------------------------------------------------ 
      131    Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      141    Call to deprecated method deleteRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
             instead.                                                          
     ------ ------------------------------------------------------------------ 
     ------ ---------------------------------------------------------------- 
      Line   src/Form/CloudProjectRevisionRevertForm.php                     
     ------ ---------------------------------------------------------------- 
      129    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ------------------------------------------------------------------ 
      Line   src/Form/CloudStoreRevisionDeleteForm.php                         
     ------ ------------------------------------------------------------------ 
      131    Call to deprecated method loadRevision() of class                 
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision    
             instead.                                                          
      141    Call to deprecated method deleteRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                        
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use           
             \Drupal\Core\Entity\RevisionableStorageInterface::deleteRevision  
             instead.                                                          
     ------ ------------------------------------------------------------------ 
     ------ ---------------------------------------------------------------- 
      Line   src/Form/CloudStoreRevisionRevertForm.php                       
     ------ ---------------------------------------------------------------- 
      136    Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     ------ ---------------------------------------------------------------- 
      Line   src/Service/CloudService.php                                    
     ------ ---------------------------------------------------------------- 
      1723   Call to deprecated method loadRevision() of class               
             Drupal\Core\Entity\EntityStorageInterface:                      
             in drupal:10.1.0 and is removed from drupal:11.0.0. Use         
             \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision  
             instead.                                                        
     ------ ---------------------------------------------------------------- 
     [ERROR] Found 44 errors   
    

Issue fork cloud-3424222

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

yas created an issue. See original summary.

yas’s picture

Status: Active » Needs work
yas’s picture

Status: Needs work » Needs review

@baldwinlouie

Can you please review the patch? Especially I want you to review the code such as $cloud_config_storage = $this->entityTypeManager()->getStorage('cloud_config'); , which looks invalid, and also Error::logException() refactoring.

Please refer the test results by https://git.drupalcode.org/project/cloud/-/pipelines/105757 and ignore the following error message:

 ------ --------------------------------------------------------------------- 
  Line   modules/cloud_service_providers/k8s/k8s.module                       
 ------ --------------------------------------------------------------------- 
  790    Call to static method getOptionsListByRegion() on an unknown class   
         Drupal\Core\DateTime\TimeZoneFormHelper.                             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ --------------------------------------------------------------------- 

I believe the code return TimeZoneFormHelper::getOptionsListByRegion() is valid however please correct me if I'm wrong.

Thanks!

yas’s picture

Version: 6.x-dev » 7.x-dev

yas’s picture

@baldwinlouie

FYI, I fixed the following error by including the namespace for Drupal\Core\DateTime\TimeZoneFormHelper::getOptionsListByRegion()

------ --------------------------------------------------------------------- 
  Line   modules/cloud_service_providers/k8s/k8s.module                       
 ------ --------------------------------------------------------------------- 
  790    Call to static method getOptionsListByRegion() on an unknown class   
         Drupal\Core\DateTime\TimeZoneFormHelper.                             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ --------------------------------------------------------------------- 
yas’s picture

@baldwinlouie

Thank you for your review. I understood there had the namespace typo. I fixed it, so can you please review the patch again? phpcs and phpstan have been passed successfully :)

Thanks!

baldwinlouie’s picture

Status: Needs review » Needs work
StatusFileSize
new511.15 KB
new311.85 KB

@yas, Thank you for working on this patch.

I think the Error::logException() looks good. My concern is the updates for revision handling.

I downloaded and ran this patch to check the revision handling.

The usage of $entity_storage->getRevision($revision_id) causes a 500 error because getRevision() method doesn't exist.

I've been playing with how to use the loadRevision from RevisionableStorageInterface. I think the following modifications should work.

Consider the usage in updateCloudLaunchTemplate in Ec2BatchOperation.php. The following adjustments made it work. You can recreate this error if you try to `Refresh` AWS launch template. The code that refreshes aws launch templates interacts with Revisions.

1. Anywhere you need to load entities with revisions, add PHPDoc comment to add typehinting.

    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
    $entity_storage = $entity_type_manager->getStorage('cloud_launch_template');

2. Change $entity_storage->getRevision back to $entity_storage->loadRevision($revision_id);.

What do you think?

yas’s picture

Status: Needs work » Needs review

@baldwinlouie

Thank you for your confirmation and suggestion. I added the type hint to avoid the phpstan warnings. I reverted to loadRevision and refactor to use getRevision() if possible.

Can you please review the patch again? Thanks!

baldwinlouie’s picture

StatusFileSize
new243.98 KB

@yas, thank you for updating the patch. I posted my second round of comments. Basically, all `getRevision()` should be changed to `loadRevision()`. Otherwise you will encounter errors such as the following screenshot

To reproduce this error.
1. Go to any AWS Launch Template and click "Edit"
2. Then click the "Revisions" tab.

With the current `getRevision()` code, the "Revisions" tab will error out.

yas’s picture

@baldwinlouie

Thank you for your review. I am sorry for my misunderstanding. I confirmed the patch on local environment, and it works. Can you please check the patch again? Thanks!

baldwinlouie’s picture

Status: Needs review » Reviewed & tested by the community

@yas, thank you for the update! The patch looks good to me now!

yas’s picture

@baldwinlouie

Thank you for your review. I'll merge the patch to 7.x, and close this issue as Fixed.

  • yas committed b60eda91 on 7.x
    Issue #3424222 by yas, baldwinlouie: Comply with Drupal coding standards...
yas’s picture

Status: Reviewed & tested by the community » Fixed

yas’s picture

Status: Fixed » Reviewed & tested by the community

@baldwinlouie

I found a bug and fixed it. I'll merge the hotfix to 7.x branch and close this issue as Fixed. Thanks!

  • yas committed 39cb7075 on 7.x
    Issue #3424222 by yas, baldwinlouie: Hotfix - Comply with Drupal coding...
yas’s picture

Status: Reviewed & tested by the community » Fixed
yas’s picture

Status: Fixed » Needs work

I found the following error; so I'll fix it.

TypeError: Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsService::__construct(): Argument #1 ($entity_type_manager) must be of type Drupal\Core\Entity\EntityTypeManagerInterface, Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManager given, called in /var/www/cloud_orchestrator/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 260 in Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsService->__construct() (line 162 of /var/www/cloud_orchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php).

yas’s picture

Status: Needs work » Needs review

I tested the patch, so it should work.

yas’s picture

Status: Needs review » Reviewed & tested by the community

@baldwinlouie

I'll merge the hotfix to 7.x branch and close this issue as Fixed. Thanks!

  • yas authored 36dbecc4 on 7.x
    Issue #3424222 by yas: Hotfix - Comply with Drupal coding standards (30...
yas’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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