localgovdrupal / localgov_project

Project template for Drupal 10 sites built with the LocalGov Drupal distribution.
https://localgovdrupal.org
GNU General Public License v2.0
10 stars 8 forks source link

PHP 8.1 and Drupal 9 Lando recipe #65

Closed finnlewis closed 2 years ago

finnlewis commented 2 years ago

It might be a time to update the default Lando recipe to Drupal9 and run PHP 8.1, which is recommended.

https://www.drupal.org/docs/system-requirements/php-requirements#php_required

finnlewis commented 2 years ago

Notes from Merge Monday:

@stephen-cox mentions that we are currently testing with PHP 7.4, so we need to look at the testing framework if we want to start supporting PHP 8.

finnlewis commented 2 years ago

With PHP 8.1.2 and Drupal 9.3.4 I am getting this error:

Error: Class "Drupal\Core\Logger\RfcLogLevel" not found in drupal_error_levels() (line 26 of core/includes/errors.inc). 

finn@finnibuntu:~/sites/l.localgov/MY_PROJECT$ lando php -v PHP 8.1.2 (cli) (built: Jan 26 2022 16:33:54) (NTS)

This looks related:

https://www.drupal.org/project/drupal/issues/3258987

finnlewis commented 2 years ago

I've done some more work on this.

I've:

Now run into a PHP dependency problem:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.24. in /var/www/html/vendor/composer/platform_check.php on line 24

See: https://github.com/localgovdrupal/localgov_project/runs/5816390787?check_suite_focus=true#step:5:10

Not sure if this means the container is actually running PHP 7.4 or if this is a composer mismatch between versions of the profile and the project.

finnlewis commented 2 years ago

Hey @stephen-cox - welcome back!

Just pinging you on this one as you might have thoughts on how best to proceed.

As @ekes explained to me (again!) the test script pulls the current version of the localgovdrupal/apache-php container before checking out the branch to run tests, which is why this is initially failing:

https://github.com/localgovdrupal/localgov_project/runs/5816390787?check_suite_focus=true#step:4:6

Is there a neat way around this?

finnlewis commented 2 years ago

Just looking at Thunder's testing configuration, and it looks like they test on PHP 7.4 and 8.1.

https://github.com/thunder/thunder-distribution/blob/6.3.x/.github/workflows/tests.yml#L45

I wonder if that's something we want to do.

Also looking at how Thunder sets up PHP:

https://github.com/thunder/thunder-distribution/blob/6.3.x/.github/workflows/tests.yml#L128-L132

Do we still need our custom docker container?

stephen-cox commented 2 years ago

To use PHP 8.1 we need to upgrade phpstan and some related packages to version 1.x. The complete list is:

Once this is done it triggers a whole load more deprecation errors which will need fixing before we can roll out Drupal 8.1 testing for all

 ------ ----------------------------------------------------------------------------------------------------- 
  Line   localgov_alert_banner/src/Form/AlertBannerEntityDeleteForm.php                                       
 ------ ----------------------------------------------------------------------------------------------------- 
  12     Class Drupal\localgov_alert_banner\Form\AlertBannerEntityDeleteForm extends @internal class          
         Drupal\Core\Entity\ContentEntityDeleteForm.                                                          
         💡 Extend \Drupal\Core\Entity\ContentEntityConfirmFormBase. See https://www.drupal.org/node/2491057  
 ------ ----------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------- 
  Line   localgov_core/src/FieldRenameHelper.php                                                                      
 ------ ------------------------------------------------------------------------------------------------------------- 
  92     Call to deprecated method findConfigEntityDependentsAsEntities() of class Drupal\Core\Config\ConfigManager:  
         in drupal:9.3.0 and is removed from drupal:10.0.0.                                                           
           Instead you should use                                                                                     
           ConfigManagerInterface::findConfigEntityDependenciesAsEntities().                                          
 ------ ------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------ 
  Line   localgov_demo/localgov_demo.module              
 ------ ------------------------------------------------ 
  62     Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
  153    Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
 ------ ------------------------------------------------ 

 ------ ----------------------------------------------------------------------------------------- 
  Line   localgov_directories/modules/localgov_directories_or/tests/src/Kernel/FacetSyncTest.php  
 ------ ----------------------------------------------------------------------------------------- 
  70     Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  82     Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  88     Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  94     Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  105    Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  118    Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
  125    Missing explicit access check on entity query.                                           
         💡 See https://www.drupal.org/node/3201242                                               
 ------ ----------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------- 
  Line   localgov_directories/src/LocalgovDirectoriesFacetsListBuilder.php  
 ------ ------------------------------------------------------------------- 
  92     Missing explicit access check on entity query.                     
         💡 See https://www.drupal.org/node/3201242                         
 ------ ------------------------------------------------------------------- 

 ------ ------------------------------------------------ 
  Line   localgov_geo/localgov_geo.install               
 ------ ------------------------------------------------ 
  73     Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
 ------ ------------------------------------------------ 

 ------ ------------------------------------------------ 
  Line   localgov_geo/src/LocalgovGeoListBuilder.php     
 ------ ------------------------------------------------ 
  68     Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
 ------ ------------------------------------------------ 

 ------ ------------------------------------------------- 
  Line   localgov_guides/src/ChildParentRelationship.php  
 ------ ------------------------------------------------- 
  54     Missing explicit access check on entity query.   
         💡 See https://www.drupal.org/node/3201242       
 ------ ------------------------------------------------- 

 ------ ------------------------------------------------ 
  Line   localgov_news/localgov_news.install             
 ------ ------------------------------------------------ 
  20     Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
 ------ ------------------------------------------------ 

 ------ -------------------------------------------------------------------------------------------------------------------------- 
  Line   localgov_openreferral/src/Encoder/JsonEncoder.php                                                                         
 ------ -------------------------------------------------------------------------------------------------------------------------- 
  10     Class Drupal\localgov_openreferral\Encoder\JsonEncoder extends @internal class Drupal\serialization\Encoder\JsonEncoder.  
 ------ -------------------------------------------------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------------------------------------------------------- 
  Line   localgov_openreferral/src/QueryPagerTrait.php (in context of class Drupal\localgov_openreferral\Controller\EndpointsController)  
 ------ --------------------------------------------------------------------------------------------------------------------------------- 
  36     Missing explicit access check on entity query.                                                                                   
         💡 See https://www.drupal.org/node/3201242                                                                                       
 ------ --------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------ 
  Line   localgov_services/modules/localgov_services_navigation/src/EntityChildRelationshipUi.php  
 ------ ------------------------------------------------------------------------------------------ 
  158    Missing explicit access check on entity query.                                            
         💡 See https://www.drupal.org/node/3201242                                                
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------------------------------ 
  Line   localgov_services/modules/localgov_services_navigation/src/Plugin/EntityReferenceSelection/ServicesSelection.php  
 ------ ------------------------------------------------------------------------------------------------------------------ 
  253    Missing explicit access check on entity query.                                                                    
         💡 See https://www.drupal.org/node/3201242                                                                        
 ------ ------------------------------------------------------------------------------------------------------------------ 

 ------ ---------------------------------------------------------------------------------------------- 
  Line   localgov_services/modules/localgov_services_status/src/Plugin/Block/ServiceStatusMessage.php  
 ------ ---------------------------------------------------------------------------------------------- 
  86     Missing explicit access check on entity query.                                                
         💡 See https://www.drupal.org/node/3201242                                                    
 ------ ---------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------- 
  Line   localgov_services/modules/localgov_services_status/src/ServiceStatus.php  
 ------ -------------------------------------------------------------------------- 
  138    Missing explicit access check on entity query.                            
         💡 See https://www.drupal.org/node/3201242                                
 ------ -------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------------------- 
  Line   localgov_subsites/tests/src/Functional/SubsiteBlocksTest.php                                                          
 ------ ---------------------------------------------------------------------------------------------------------------------- 
  94     Call to deprecated constant FILE_STATUS_PERMANENT: Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use  
         \Drupal\file\FileInterface::STATUS_PERMANENT or \Drupal\file\FileInterface::setPermanent().                           
 ------ ---------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------ 
  Line   localgov_workflows/localgov_workflows.module    
 ------ ------------------------------------------------ 
  118    Missing explicit access check on entity query.  
         💡 See https://www.drupal.org/node/3201242      
 ------ ------------------------------------------------ 
stephen-cox commented 2 years ago

Also looking at how Thunder sets up PHP:

https://github.com/thunder/thunder-distribution/blob/6.3.x/.github/workflows/tests.yml#L128-L132

Do we still need our custom docker container?

They also set up MySQL and Selenium services

https://github.com/thunder/thunder-distribution/blob/6.3.x/.github/workflows/tests.yml#L106-L117

Certainly worth looking at, but I would suggest another issue to look at this