Problem/Motivation

drupal-check results on commit hash:
source : [git] https://git.drupal.org/project/poll 01a3a57088f707de842de4f74bdb65c7441d837a
source : http://cgit.drupalcode.org/poll


 ------ -------------------------------------------------- 
  Line   poll.module                                       
 ------ -------------------------------------------------- 
  33     Call to deprecated method url() of class Drupal.  
  33     Call to deprecated method url() of class Drupal.  
  35     Call to deprecated method url() of class Drupal.  
  35     Call to deprecated method url() of class Drupal.  
 ------ -------------------------------------------------- 

 ------ --------------------------------------------------- 
  Line   src/Form/PollDeleteForm.php                        
 ------ --------------------------------------------------- 
  48     Call to deprecated function drupal_set_message().  
 ------ --------------------------------------------------- 

 ------ --------------------------------------------------- 
  Line   src/Form/PollForm.php                              
 ------ --------------------------------------------------- 
  57     Call to deprecated function drupal_set_message().  
  60     Call to deprecated method link() of class          
         Drupal\Core\Entity\EntityInterface.                
  61     Call to deprecated function drupal_set_message().  
 ------ --------------------------------------------------- 

 ------ --------------------------------------------------- 
  Line   src/Form/PollViewForm.php                          
 ------ --------------------------------------------------- 
  71     Call to deprecated function drupal_set_message().  
  96     Call to deprecated method url() of class           
         Drupal\Core\Entity\EntityInterface.                
  297    Call to deprecated function drupal_set_message().  
  345    Call to deprecated function drupal_set_message().  
 ------ --------------------------------------------------- 

 ------ --------------------------------------------------- 
  Line   src/Form/PollVoteDeleteForm.php                    
 ------ --------------------------------------------------- 
  51     Call to deprecated function drupal_set_message().  
 ------ --------------------------------------------------- 

 ------ ------------------------------------------- 
  Line   src/PollListBuilder.php                    
 ------ ------------------------------------------- 
  60     Call to deprecated method link() of class  
         Drupal\Core\Entity\EntityInterface.        
 ------ ------------------------------------------- 

 ------ ---------------------------------------------- 
  Line   src/Tests/PollTestBase.php                    
 ------ ---------------------------------------------- 
  203    Call to deprecated function format_string().  
  235    Call to deprecated function format_string().  
 ------ ---------------------------------------------- 

 ------ ---------------------------------------------- 
  Line   src/Tests/PollTokenReplaceTest.php            
 ------ ---------------------------------------------- 
  73     Call to deprecated function format_string().  
  81     Call to deprecated function format_string().  
 ------ ---------------------------------------------- 

 ------ -------------------------------------------------- 
  Line   src/Tests/PollVoteCheckHostnameTest.php           
 ------ -------------------------------------------------- 
  46     Call to deprecated function format_string().      
  46     Call to deprecated method getUsername() of class  
         Drupal\Core\Session\AccountInterface.             
  52     Call to deprecated function format_string().      
  52     Call to deprecated method getUsername() of class  
         Drupal\Core\Session\AccountInterface.             
  85     Call to deprecated function format_string().      
  85     Call to deprecated method getUsername() of class  
         Drupal\user\Entity\User.                          
  106    Call to deprecated function format_string().      
  106    Call to deprecated method getUsername() of class  
         Drupal\user\Entity\User.                          
  127    Call to deprecated function format_string().      
  127    Call to deprecated method getUsername() of class  
         Drupal\Core\Session\AccountInterface.             
 ------ -------------------------------------------------- 

 ------ --------------------------------------------------------------- 
  Line   tests/src/FunctionalJavascript/PollVoteJavascriptTest.php      
 ------ --------------------------------------------------------------- 
  15     Class                                                          
         Drupal\Tests\poll\FunctionalJavascript\PollVoteJavascriptTest  
         extends deprecated class                                       
         Drupal\FunctionalJavascriptTests\JavascriptTestBase.           
  63     Call to method setUp() of deprecated class                     
         Drupal\Tests\BrowserTestBase.                                  
 ------ --------------------------------------------------------------- 

 [ERROR] Found 30 errors                                                    

 

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork poll-3042954

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

mcdwayne created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new15.01 KB

Here is the patch, please review.

Status: Needs review » Needs work

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

sergiu stici’s picture

Status: Needs work » Needs review
StatusFileSize
new70.69 KB

Corrected codesniffer.

Status: Needs review » Needs work

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

naheemsays’s picture

In places like PollViewForm the following is not correct:

-    drupal_set_message($this->t('Your vote has been recorded.'));
+    $this->messenger()->addMessage($this->t('Your vote has been recorded.'));

In #3042995: Convert votes into entities I have used the following instead:

\Drupal::Messenger()->addMessage($this->t('Your vote has been recorded.'));
berdir’s picture

+++ b/poll.install
@@ -11,59 +11,59 @@ use Drupal\poll\Entity\PollChoice;
  */
 function poll_schema() {
-  $schema['poll_vote'] = array(
+  $schema['poll_vote'] = [
     'description' => 'Stores per-{users} votes for each {poll}.',
-    'fields' => array(
-      'chid' => array(

This seems to mix deprecations with coding standards like array syntax, which makes this much bigger and likely to conflict on several other issues. I'd much rather focus on actual deprecations here, things like array syntax can also be scripted.

And yes, not all places have a messenger() method, you either need to use \Drupal::messenger() or maybe better, add the messenger trait.

naheemsays’s picture

Issue tags: +Amsterdam2019

Adding tag that may get someone to look at this at DrupalconEur: https://twitter.com/gaborhojtsy/status/1185151902998249477

berdir’s picture

Agreed, this would be a good issue for someone at the sprints. I would suggest to start from scratch as the coding standard fixes were moved to #3089551: Code sniffer code style fixes.

Also, drupal_set_message() has a dedicated issue, so don't touch that here and instead help to finish that: #3040194: Remove deprecated function drupal_set_message

berdir’s picture

Also, the results from running the test with deprecations on, 8.7 and older deprecations only:

drupal-check doesn't catch some of these.

Note that this is after #3090356: Convert tests to phpunit and there is also an issue for format_string() but most of the calls do that are actually removed in the phpunit converison: #3035040: Replace deprecated method format_string() calls with FormattableMarkup().

  106x: EntityManagerInterface::getStorage() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getStorage() instead. See https://www.drupal.org/node/2549139
    18x in PollVoteTest::testPollVote from Drupal\Tests\poll\Functional
    16x in PollVoteMultilingualTest::testPollVoteMultilingual from Drupal\Tests\poll\Functional
    15x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
    13x in PollVoteTest::testAnonymousCancelVote from Drupal\Tests\poll\Functional
    12x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    6x in PollDeleteChoiceTest::testChoiceRemoval from Drupal\Tests\poll\Functional
    5x in PollBlockTest::testRecentBlock from Drupal\Tests\poll\Functional
    5x in PollCreateTest::testPollClose from Drupal\Tests\poll\Functional
    5x in PollListTest::testViewListPolls from Drupal\Tests\poll\Functional
    4x in PollHtmlSpecialCharactersTest::testPollChoice from Drupal\Tests\poll\Functional
    4x in PollVoteTest::testClosedPollVoteCancel from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollCreate from Drupal\Tests\poll\Functional
    1x in PollFieldTest::testPollFields from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollQuestion from Drupal\Tests\poll\Functional

  71x: Calling EntityViewBuilder::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.
    10x in PollVoteTest::testPollVote from Drupal\Tests\poll\Functional
    9x in PollVoteMultilingualTest::testPollVoteMultilingual from Drupal\Tests\poll\Functional
    8x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    8x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
    7x in PollFieldTest::testPollFields from Drupal\Tests\poll\Functional
    7x in PollVoteTest::testAnonymousCancelVote from Drupal\Tests\poll\Functional
    4x in PollCreateTest::testPollClose from Drupal\Tests\poll\Functional
    4x in PollDeleteChoiceTest::testChoiceRemoval from Drupal\Tests\poll\Functional
    3x in PollFieldUITest::testPollFieldUI from Drupal\Tests\poll\Functional
    3x in PollVoteTest::testClosedPollVoteCancel from Drupal\Tests\poll\Functional
    2x in PollBlockTest::testRecentBlock from Drupal\Tests\poll\Functional
    2x in PollHtmlSpecialCharactersTest::testPollChoice from Drupal\Tests\poll\Functional
    2x in PollListTest::testViewListPolls from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollCreate from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollQuestion from Drupal\Tests\poll\Functional

  63x: drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. See https://www.drupal.org/node/2774931
    9x in PollVoteMultilingualTest::testPollVoteMultilingual from Drupal\Tests\poll\Functional
    7x in PollVoteTest::testPollVote from Drupal\Tests\poll\Functional
    7x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
    6x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    6x in PollVoteTest::testAnonymousCancelVote from Drupal\Tests\poll\Functional
    4x in PollVoteTest::testClosedPollVoteCancel from Drupal\Tests\poll\Functional
    4x in PollDeleteChoiceTest::testChoiceRemoval from Drupal\Tests\poll\Functional
    3x in PollListTest::testViewListPolls from Drupal\Tests\poll\Functional
    3x in PollCreateTest::testwithRestrictedUser from Drupal\Tests\poll\Functional
    2x in PollFieldTest::testPollFields from Drupal\Tests\poll\Functional
    2x in PollBlockTest::testRecentBlock from Drupal\Tests\poll\Functional
    2x in PollHtmlSpecialCharactersTest::testPollChoice from Drupal\Tests\poll\Functional
    2x in PollCreateTest::testPollClose from Drupal\Tests\poll\Functional
    1x in PollExpirationTest::testAutoExpire from Drupal\Tests\poll\Functional
    1x in PollFieldUITest::testPollFieldUI from Drupal\Tests\poll\Functional
    1x in PollFieldUITest::testPollHelpLinks from Drupal\Tests\poll\Functional
    1x in PollViewTest::testAdminView from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollCreate from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollQuestion from Drupal\Tests\poll\Functional

  63x: EntityInterface::url() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. EntityInterface::toUrl() instead. Note, a \Drupal\Core\Url object is returned. See https://www.drupal.org/node/2614344
    11x in PollVoteTest::testPollVote from Drupal\Tests\poll\Functional
    8x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    8x in PollVoteMultilingualTest::testPollVoteMultilingual from Drupal\Tests\poll\Functional
    8x in PollVoteTest::testAnonymousCancelVote from Drupal\Tests\poll\Functional
    7x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
    4x in PollBlockTest::testRecentBlock from Drupal\Tests\poll\Functional
    4x in PollListTest::testViewListPolls from Drupal\Tests\poll\Functional
    3x in PollDeleteChoiceTest::testChoiceRemoval from Drupal\Tests\poll\Functional
    3x in PollHtmlSpecialCharactersTest::testPollChoice from Drupal\Tests\poll\Functional
    2x in PollCreateTest::testPollClose from Drupal\Tests\poll\Functional
    2x in PollVoteTest::testClosedPollVoteCancel from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollCreate from Drupal\Tests\poll\Functional
    1x in PollFieldTest::testPollFields from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollQuestion from Drupal\Tests\poll\Functional

  25x: EntityInterface::link() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. Use EntityInterface::toLink()->toString() instead. Note, the default relationship for configuration entities changes from 'edit-form' to 'canonical'. See https://www.drupal.org/node/2614344
    3x in PollCreateTest::testwithRestrictedUser from Drupal\Tests\poll\Functional
    2x in PollVoteTest::testClosedPollVoteCancel from Drupal\Tests\poll\Functional
    2x in PollVoteMultilingualTest::testPollVoteMultilingual from Drupal\Tests\poll\Functional
    2x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    2x in PollListTest::testViewListPolls from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollChoice from Drupal\Tests\poll\Functional
    1x in PollVoteTest::testPollVote from Drupal\Tests\poll\Functional
    1x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
    1x in PollViewTest::testAdminView from Drupal\Tests\poll\Functional
    1x in PollHtmlSpecialCharactersTest::testPollQuestion from Drupal\Tests\poll\Functional
    1x in PollBlockTest::testRecentBlock from Drupal\Tests\poll\Functional
    1x in PollFieldUITest::testPollHelpLinks from Drupal\Tests\poll\Functional
    1x in PollFieldUITest::testPollFieldUI from Drupal\Tests\poll\Functional
    1x in PollFieldTest::testPollFields from Drupal\Tests\poll\Functional
    1x in PollExpirationTest::testAutoExpire from Drupal\Tests\poll\Functional
    1x in PollDeleteChoiceTest::testChoiceRemoval from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollClose from Drupal\Tests\poll\Functional
    1x in PollCreateTest::testPollCreate from Drupal\Tests\poll\Functional
    1x in PollVoteTest::testAnonymousCancelVote from Drupal\Tests\poll\Functional

  24x: Drupal::url() is deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute()
    24x in PollFieldUITest::testPollHelpLinks from Drupal\Tests\poll\Functional

  12x: format_string() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Component\Render\FormattableMarkup instead. See https://www.drupal.org/node/2302363
    10x in PollTokenReplaceTest::testPollTokenReplacement from Drupal\Tests\poll\Functional
    2x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional

  2x: The Drupal\FunctionalJavascriptTests\JavascriptTestBase is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Instead, use Drupal\FunctionalJavascriptTests\WebDriverTestBase. See https://www.drupal.org/node/2945059
    1x in ClassLoader::loadClass from Composer\Autoload
    1x in PollVoteJavascriptTest::testAjaxPollVote from Drupal\Tests\poll\FunctionalJavascript

  2x: \Drupal\Core\Session\AccountInterface::getUsername() is deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\Session\AccountInterface::getAccountName() or \Drupal\user\UserInterface::getDisplayName() instead. See https://www.drupal.org/node/2572493
    2x in PollVoteCheckHostnameTest::testHostnamePollVote from Drupal\Tests\poll\Functional
-enzo-’s picture

Hello Folks

I want to try to help you to prepare poll module for Drupal 9, but I am getting some issues.

I downloaded the poll module using the branch 8.8.x, but when I tried to apply the patch drupal_9_deprecated_code-3042954-4.patch to start my contribution from there but the patch doesn't work

git apply --stat drupal_9_deprecated_code-3042954-4.patch
 0 files changed

Could you tell me what I am doing wrong, thanks in advance

naheemsays’s picture

There is no 8.8 branch of the poll module. Did you download drupal core 8.8 branch?

Version control patching details are here: https://www.drupal.org/project/poll/git-instructions.

You probably want to ignore the current patch and start from scratch.

-enzo-’s picture

Hi @nbz

My question was, what branch I need to use to apply the patch if you check my previous comment the patch in my test, said no changes to be applied using the patch posted at #4.

Thanks for your help

naheemsays’s picture

It was for the 8.x-1.x branch. It most likely will not apply cleanly as especially most of the tests have been converted to unit tests and reside at new locations.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new13.95 KB

This fixes a bunch of remaining deprecation mesages, pretty much the only thing left now on 8.8 is the TrustedCallbackInterface, I don't really want to add code to support that, other than that, this should be basically ready for D9.

Updated/removed a bunch of pointless asserts to fix assertTrue() must receive boolean deprecation messages.

Also added the core compatibility key to make it easier to test with D9, will need to be updated to 8.8 once we depend on that. But we need 8.7 now for the EntityViewBuilder constructor/properties.

naheemsays’s picture

-core: 8.x

I think you need to keep this in for now as it will break drupal core releases older than 8.7.7.

berdir’s picture

I'm OK with that :) I did explicitly require 8.7.7+ with the new key.

8.7.7 was released 2.5 months ago and nobody is forced to update this module. And support for 8.6 will end in a few weeks as well.

berdir’s picture

Also, I've just released https://www.drupal.org/project/poll/releases/8.x-1.3 (not published yet by the time I write this), took me 1y6m since the last release, by the time I create another one, it'll probably be safe to rely on 8.8 :)

berdir’s picture

Status: Needs review » Fixed

Committed.

  • Berdir committed 7ec06b8 on 8.x-1.x
    Issue #3042954 by Sergiu Stici, Berdir: Drupal 9 Deprecated Code Report
    

Status: Fixed » Closed (fixed)

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

dhannumanikpuri@gmail.com made their first commit to this issue’s fork.