Prepare Drupal 10 compatibility (planned for August 2022).

Running drupal-check reports:

FILE: allowed_formats.info.yml

STATUS         LINE                           MESSAGE                           
--------------------------------------------------------------------------------
Check manually 0    Value of core_version_requirement: ^8.8 || ^9 is not        
                    compatible with the next major version of Drupal core. See  
                    https://drupal.org/node/3070687.                            
--------------------------------------------------------------------------------

FILE: composer.json

STATUS         LINE                           MESSAGE                           
--------------------------------------------------------------------------------
Check manually 0    The drupal/core requirement is not compatible with the next 
                    major version of Drupal. Either remove it or update it to be
                    compatible. See                                             
                    https://drupal.org/node/2514612#s-drupal-9-compatibility.   
--------------------------------------------------------------------------------

Thank's


Drupal 10.0 development


Thank you so much for the Drupal Core team

Following with


The current composer require status for this module under Drupal 10

composer create-project drupal/recommended-project:10.0.0-alpha4@alpha /var/www/html/sandboxes/drupal10allowed_formats
cd /var/www/html/sandboxes/drupal10allowed_formats/

composer require drupal/allowed_formats;

is having the following problem

Using version ^1.5 for drupal/allowed_formats
./composer.json has been updated
Running composer update drupal/allowed_formats
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires drupal/allowed_formats ^1.5 -> satisfiable by drupal/allowed_formats[1.5.0, 1.x-dev].
    - drupal/allowed_formats[1.5.0, ..., 1.x-dev] require drupal/core ^8.8 || ^9 -> found drupal/core[8.8.0-alpha1, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.0.0-alpha4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/allowed_formats:*" to figure out if any version is installable, or "composer require drupal/allowed_formats:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
<code>

<hr />
<h4>Farther <strong><a href="https://github.com/mglaman/drupal-check">drupal-check</a></strong> on</h4>

<code>
composer create-project drupal/recommended-project:~9 /var/www/html/sandboxes/drupal9allowed_formats

cd /var/www/html/sandboxes/drupal9allowed_formats/

composer require drupal/allowed_formats

composer require drupal/core-dev --with-all-dependencies
composer require mglaman/drupal-check --dev
composer require phpspec/prophecy-phpunit:^2 --dev 

php vendor/bin/drupal-check -d web/modules/contrib/allowed_formats/

Output:

allowed_formats--drupal-check--report.txt

 ------ ---------------------------------------------- 
  Line   allowed_formats.module                        
 ------ ---------------------------------------------- 
  20     Call to an undefined method                   
         Drupal\Core\Form\FormInterface::getEntity().  
 ------ ---------------------------------------------- 


 [ERROR] Found 1 error                                                          


Comments

S3b0uN3t created an issue. See original summary.

victoria-marina’s picture

Assigned: Unassigned » victoria-marina

I'll work on this.

victoria-marina’s picture

Assigned: victoria-marina » Unassigned
Status: Active » Needs review
StatusFileSize
new701 bytes

Here is a patch. Kindly review it.

Guilherme Rabelo’s picture

Assigned: Unassigned » Guilherme Rabelo

I will review this patch.

s3b0un3t’s picture

Thank you @victoria-marina for your responsiveness.
I thought to provide a patch as soon as possible

Guilherme Rabelo’s picture

Assigned: Guilherme Rabelo » Unassigned
Status: Needs review » Reviewed & tested by the community

When i ran the drupal-check command after applying the patch, it didn't show any error messages. For this reason i believe that everything is right.
Moving to RTBC!

victoria-marina’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new597 bytes
new1.37 KB

Hi! I just provided a new small patch to fix the test error.

victoria-marina’s picture

StatusFileSize
new2.03 KB
new481 bytes

One more small patch. The other problem happening on tests, unfortunately I don't know exactly how to solve it.

andregp’s picture

Status: Needs review » Needs work

Needs work (still has failing tests).

rajab natshah’s picture

Issue summary: View changes
StatusFileSize
new420 bytes

Drupal 10.0 development


Thank you so much for the Drupal Core team

Following with


The current composer require status for this module under Drupal 10

composer create-project drupal/recommended-project:10.0.0-alpha4@alpha /var/www/html/sandboxes/drupal10allowed_formats
cd /var/www/html/sandboxes/drupal10allowed_formats/

composer require drupal/allowed_formats;

is having the following problem

Using version ^1.5 for drupal/allowed_formats
./composer.json has been updated
Running composer update drupal/allowed_formats
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires drupal/allowed_formats ^1.5 -> satisfiable by drupal/allowed_formats[1.5.0, 1.x-dev].
    - drupal/allowed_formats[1.5.0, ..., 1.x-dev] require drupal/core ^8.8 || ^9 -> found drupal/core[8.8.0-alpha1, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.0.0-alpha4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/allowed_formats:*" to figure out if any version is installable, or "composer require drupal/allowed_formats:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
<code>

<hr />
<h4>Farther <strong><a href="https://github.com/mglaman/drupal-check">drupal-check</a></strong> on</h4>

<code>
composer create-project drupal/recommended-project:~9 /var/www/html/sandboxes/drupal9allowed_formats

cd /var/www/html/sandboxes/drupal9allowed_formats/

composer require drupal/allowed_formats

composer require drupal/core-dev --with-all-dependencies
composer require mglaman/drupal-check --dev
composer require phpspec/prophecy-phpunit:^2 --dev 

php vendor/bin/drupal-check -d web/modules/contrib/allowed_formats/

Output:

allowed_formats--drupal-check--report.txt

 ------ ---------------------------------------------- 
  Line   allowed_formats.module                        
 ------ ---------------------------------------------- 
  20     Call to an undefined method                   
         Drupal\Core\Form\FormInterface::getEntity().  
 ------ ---------------------------------------------- 


 [ERROR] Found 1 error                                                          

rassoni’s picture

Assigned: Unassigned » rassoni
rassoni’s picture

Status: Needs work » Needs review
StatusFileSize
new2.28 KB
new291.58 KB

Fixed all issues Please review my patch.
I am sharing with you a screenshot of the result.

rassoni’s picture

Assigned: rassoni » Unassigned
berdir’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
StatusFileSize
new2.76 KB
new1.41 KB
+++ b/allowed_formats.module
@@ -11,13 +11,17 @@ use Drupal\Core\Form\FormStateInterface;
  */
 function allowed_formats_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) {
-  /** @var \Drupal\Core\Field\FieldConfigInterface $field */
-  $field = $form_state->getFormObject()->getEntity();
+
+  $form_object = $form_state->getFormObject();
+  if ($form_object instanceof EntityFormInterface) {
+    /** @var \Drupal\Core\Field\FieldConfigInterface $field */
+    $field = $form_object->getEntity();
 

This is not about Drupal 10 compatibility, drupal-check now includes more strict phpstan checks and not only
d10 related issues. It could be kept if it's a small thing, but it either needs to be rewritten or the whole section inside would need to be indented.

I went back to #8 which has more fixes anyway and fixed the tests because on change is missing. The tools don't report on the subtle but important hook rename that this module relies on. That also means we require at least Drupal 9.2

luke.leber’s picture

The CR for the hook rename that #14 refers to: https://www.drupal.org/node/3180429.

Tauany Bueno’s picture

Assigned: Unassigned » Tauany Bueno

hi, i'll review it :)

Tauany Bueno’s picture

Assigned: Tauany Bueno » Unassigned
Status: Needs review » Reviewed & tested by the community

hi!

I reviewed the last patch and all it didn't show any warnings or errors.
The correction mentioned on #15 was already made on the patch. I believe everything is right, so I'm changing it to RTBC.

kristen pol’s picture

Issue tags: +Drupal 10 porting day

Thanks for the patch and testing.

@tauanygb Did you test on Drupal 9 or 10 or both?

Tauany Bueno’s picture

@Kristen Pol I tested it on a Drupal 9 environment, and ran drupal-check.

luke.leber’s picture

Additional +1 RTBC to #14. Manually tested against 10.0.x-dev and 9.5.x-dev; the patch and automated test results look great.

  • nord102 committed 9b52e52 on 8.x-1.x
    Issue #3269869 by victoria-marina, Rashmisoni, Berdir: Drupal 10...
nord102’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all for the work on this issue. This has been committed to the dev version and will be included in the next release.

Status: Fixed » Closed (fixed)

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

claudiu.cristea’s picture

@nord102, could you, please, tag a new release to include this change?

nord102’s picture

@claudiu.cristea

I have tagged a new release for this