drupal-check upgrade_rector/
9/9 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ --------------------------------------------------------------------
Line src/RectorProcessor.php
------ --------------------------------------------------------------------
95 Call to deprecated function file_directory_temp():
in drupal:8.8.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::getTempDirectory() instead.
------ --------------------------------------------------------------------

------ -------------------------------------------------------------------------------------------------------------------------------------
Line tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php
------ -------------------------------------------------------------------------------------------------------------------------------------
Class Drupal\upgrade_rector_test\Form\UpgradeRectorTestErrorForm was not found while trying to analyse it - autoloading is probably
not configured properly.
------ -------------------------------------------------------------------------------------------------------------------------------------

------ --------------------------------------------------------------------------
Line tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module
------ --------------------------------------------------------------------------
8 Call to deprecated function drupal_set_message():
in drupal:8.5.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
9 Call to deprecated method url() of class Drupal:
in drupal:8.0.0 and is removed from drupal:9.0.0.
Instead create a \Drupal\Core\Url object directly, for example using
Url::fromRoute().
------ --------------------------------------------------------------------------

Comments

vsujeetkumar created an issue. See original summary.

gábor hojtsy’s picture

Title: Drupal 9 Deprecated Code and Analysis Report » Drupal 9 compatibility of Upgrade Rector
gábor hojtsy’s picture

Issue tags: +Drupal 9 compatibility

Thanks for the issue. I linked it from the project page.

gábor hojtsy’s picture

As you can see tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php and tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module are explicitly about testing whether rector will fix the uses of deprecated code, so we should not fix them or rector will not have anything to fix for testing purposes. We are not actually enabling/installing these test code pieces, so theoretically we can leave them around and still pass tests on Drupal 9 with our test code that is not Drupal 9 compatible.

The situation with file_directory_temp() is we would need to require Drupal 8.8 to fix it. A patch would be great to get started on that. Maybe rector itself can generate it at this point? :)

Also, the report did not show but the info file would need to change to allow installing on Drupal 9.

vsujeetkumar’s picture

Assigned: vsujeetkumar » Unassigned
Status: Active » Needs review
StatusFileSize
new2.79 KB

Patch created, Please review.

Status: Needs review » Needs work

The last submitted patch, 5: 3131599_5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

+++ b/src/RectorProcessor.php
--- a/tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php
+++ b/tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php

+++ b/tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php
+++ b/tests/modules/upgrade_rector_test_error/src/Form/UpgradeRectorTestErrorForm.php
@@ -1,6 +1,8 @@

@@ -1,6 +1,8 @@
 <?php
 
-namespace Drupal\upgrade_rector_test\Form;
+namespace Drupal\upgrade_rector_test_error\Form;
+
+use Drupal\Core\Url;
 
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -13,8 +15,8 @@ class UpgradeRectorTestErrorForm extends FormBase {

@@ -13,8 +15,8 @@ class UpgradeRectorTestErrorForm extends FormBase {
 
   public function buildForm(array $form, FormStateInterface $form_state) {
     $foo = LOCALE_PLURAL_DELIMITER;
-    drupal_set_message('Sample message');
-    $url = Drupal::url('<front');
+    \Drupal::messenger()->addMessage('Sample message');
+    $url = Url::fromRoute('<front>')->toString();
   }
 
   public function submitForm(array &$form, FormStateInterface $form_state) {}
diff --git a/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module b/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module

diff --git a/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module b/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module
index 2fa72c4..e97061e 100644

index 2fa72c4..e97061e 100644
--- a/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module

--- a/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module
+++ b/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module

+++ b/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module
+++ b/tests/modules/upgrade_rector_test_error/upgrade_rector_test_error.module
@@ -1,10 +1,12 @@

@@ -1,10 +1,12 @@
 <?php
 
+use Drupal\Core\Url;
+
 /**
  * Sample code to test ourselves for now.
  */
 function upgrade_rector_test_sample() {
   $foo = LOCALE_PLURAL_DELIMITER;
-  drupal_set_message('Sample message');
-  $url = Drupal::url('<front');
+  \Drupal::messenger()->addMessage('Sample message');
+  $url = Url::fromRoute('<front>')->toString();
 }

As I wrote above, these should not be fixed. We need them present so we can test with them that rector works.

The rest of the patch looks good. We can even add a conditional around the file temp directory call and keep it working on 8.7 while being Drupal 9 compatible.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB
new1.47 KB

Fixed those.

Status: Needs review » Needs work

The last submitted patch, 8: 3131599-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB
new351 bytes

Core key should not be there.

  • Gábor Hojtsy committed 91ade2a on 8.x-1.x
    Issue #3131599 by Gábor Hojtsy, vsujeetkumar: Drupal 9 compatibility of...
gábor hojtsy’s picture

Status: Needs review » Fixed

Woot!

  • Gábor Hojtsy committed fbf5172 on 8.x-1.x
    Issue #3131599 followup by Gábor Hojtsy: composer file should also...

  • Gábor Hojtsy committed aee0887 on 8.x-1.x
    Issue #3131599 followup by Gábor Hojtsy: update test setUp() method...

Status: Fixed » Closed (fixed)

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