Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
drupal-check results on commit hash:
source : [git] https://git.drupal.org/project/entity_print 3f1738f652a0bf246b7a351c05961b76d939a00b
source : http://cgit.drupalcode.org/entity_print
------ ---------------------------------------------------
Line entity_print.module
------ ---------------------------------------------------
38 Call to deprecated method isSubclassOf() of class
Drupal\Core\Entity\EntityTypeInterface.
------ ---------------------------------------------------
------ -------------------------------------------------------------------
Line modules/entity_print_views/src/Controller/ViewPrintController.php
------ -------------------------------------------------------------------
110 Call to deprecated function drupal_set_message().
------ -------------------------------------------------------------------
------ ------------------------------------------------------------------
Line modules/entity_print_views/tests/src/Kernel/ViewsAccessTest.php
------ ------------------------------------------------------------------
18 Usage of deprecated trait Drupal\simpletest\UserCreationTrait in
class Drupal\Tests\entity_print_views\Kernel\ViewsAccessTest.
------ ------------------------------------------------------------------
------ ----------------------------------------------
Line src/EventSubscriber/PostRenderSubscriber.php
------ ----------------------------------------------
75 Call to deprecated method substr() of class
Drupal\Component\Utility\Unicode.
76 Call to deprecated method substr() of class
Drupal\Component\Utility\Unicode.
78 Call to deprecated method substr() of class
Drupal\Component\Utility\Unicode.
------ ----------------------------------------------
------ --------------------------------------------------------
Line src/EventSubscriber/PrintEngineExceptionSubscriber.php
------ --------------------------------------------------------
56 Call to deprecated function drupal_set_message().
------ --------------------------------------------------------
------ ---------------------------------------------------
Line src/Form/SettingsForm.php
------ ---------------------------------------------------
107 Call to deprecated function drupal_set_message().
238 Call to deprecated function drupal_set_message().
------ ---------------------------------------------------
------ ---------------------------------------------------
Line src/Plugin/Action/PrintDownload.php
------ ---------------------------------------------------
124 Call to deprecated function drupal_set_message().
------ ---------------------------------------------------
------ --------------------------------------------------------------
Line src/Tests/Update/EntityPrintUpdateTest.php
------ --------------------------------------------------------------
12 Class Drupal\entity_print\Tests\Update\EntityPrintUpdateTest
extends deprecated class
Drupal\system\Tests\Update\UpdatePathTestBase.
25 Call to method setUp() of deprecated class
Drupal\system\Tests\Update\UpdatePathTestBase.
------ --------------------------------------------------------------
------ -------------------------------------------------
Line tests/src/Functional/Base64ImageTest.php
------ -------------------------------------------------
52 Call to deprecated method strtolower() of class
Drupal\Component\Utility\Unicode.
------ -------------------------------------------------
------ ------------------------------------------------------------------
Line tests/src/Kernel/EntityPrintAccessTest.php
------ ------------------------------------------------------------------
18 Usage of deprecated trait Drupal\simpletest\UserCreationTrait in
class Drupal\Tests\entity_print\Kernel\EntityPrintAccessTest.
19 Usage of deprecated trait Drupal\simpletest\NodeCreationTrait in
class Drupal\Tests\entity_print\Kernel\EntityPrintAccessTest.
20 Usage of deprecated trait
Drupal\simpletest\ContentTypeCreationTrait in class
Drupal\Tests\entity_print\Kernel\EntityPrintAccessTest.
------ ------------------------------------------------------------------
------ ------------------------------------------------------------------
Line tests/src/Kernel/ExtraFieldsTest.php
------ ------------------------------------------------------------------
20 Usage of deprecated trait Drupal\simpletest\NodeCreationTrait in
class Drupal\Tests\entity_print\Kernel\ExtraFieldsTest.
21 Usage of deprecated trait Drupal\simpletest\UserCreationTrait in
class Drupal\Tests\entity_print\Kernel\ExtraFieldsTest.
22 Usage of deprecated trait
Drupal\simpletest\ContentTypeCreationTrait in class
Drupal\Tests\entity_print\Kernel\ExtraFieldsTest.
------ ------------------------------------------------------------------
------ ------------------------------------------------------------------
Line tests/src/Kernel/FilenameGeneratorTest.php
------ ------------------------------------------------------------------
15 Usage of deprecated trait Drupal\simpletest\NodeCreationTrait in
class Drupal\Tests\entity_print\Kernel\FilenameGeneratorTest.
------ ------------------------------------------------------------------
------ ------------------------------------------------------------------
Line tests/src/Kernel/PrintBuilderTest.php
------ ------------------------------------------------------------------
15 Usage of deprecated trait Drupal\simpletest\NodeCreationTrait in
class Drupal\Tests\entity_print\Kernel\PrintBuilderTest.
37 Call to deprecated method install() of class
Drupal\Core\Extension\ThemeHandler.
87 Call to deprecated method install() of class
Drupal\Core\Extension\ThemeHandler.
------ ------------------------------------------------------------------
------ -------------------------------------------------------------------
Line tests/src/Kernel/PrintLinkTest.php
------ -------------------------------------------------------------------
18 Usage of deprecated trait Drupal\simpletest\BlockCreationTrait in
class Drupal\Tests\entity_print\Kernel\PrintLinkTest.
63 Call to deprecated method getMock() of class
Drupal\KernelTests\KernelTestBase.
------ -------------------------------------------------------------------
------ ------------------------------------------------------------------
Line tests/src/Kernel/TranslationTest.php
------ ------------------------------------------------------------------
17 Usage of deprecated trait Drupal\simpletest\NodeCreationTrait in
class Drupal\Tests\entity_print\Kernel\TranslationTest.
41 Call to deprecated method install() of class
Drupal\Core\Extension\ThemeHandler.
------ ------------------------------------------------------------------
[ERROR] Found 27 errors
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#73 | 3042808-73.patch | 41.31 KB | Sam152 |
#73 | interdiff.txt | 1.2 KB | Sam152 |
#72 | 3042808-72.patch | 40.11 KB | Sam152 |
#72 | interdiff.txt | 2.35 KB | Sam152 |
#70 | 3042808-70.patch | 39.8 KB | Sam152 |
Comments
Comment #2
Sergiu Stici CreditAttribution: Sergiu Stici at FFW commentedHere is the patch, please review.
Comment #4
Tolyan4ik CreditAttribution: Tolyan4ik at EPAM Systems commentedPlease review patch
Comment #5
Tolyan4ik CreditAttribution: Tolyan4ik at EPAM Systems commentedComment #6
maacl CreditAttribution: maacl commented#4 was against 1.x-Branch I think, so I worked with #2. Hopefully the tests come back green. There are still deprecation notices left, and simpletests which have to be converted.
Comment #7
maacl CreditAttribution: maacl commentedTrying to convert the tests.
Comment #8
-enzo- CreditAttribution: -enzo- at weKnow Inc commentedHi @maacl
I tried patch #7 with drupal-check and looks OK, do you have any example about how to convert the test and what tests needs to be converted, I could use that information to try to help with this task.
Comment #9
maacl CreditAttribution: maacl commentedI hadn't had the chance to do a deep dive into testing yet. As far as I can tell, there are tests using simpletest classes and traits. Those have to be replaced by PHPunit equivalents. Some tests may need rewriting. You can find them with a simple search in the codebase: https://git.drupalcode.org/search?utf8=%E2%9C%93&search=simpletest&group...
Here is a small piece of documentation: https://www.drupal.org/docs/8/testing/converting-d7-and-d8-simpletests-t...
Comment #10
alexismmd CreditAttribution: alexismmd commentedFixed tests result from EntityPrintAdminTest of last patch.
Comment #11
jedihe CreditAttribution: jedihe as a volunteer commentedJust did a super-quick scan of #10 and noticed it already has core_version_requirement: ^8 || ^9, so I think it's a good idea to test it against both 8.9.x and 9.0.x.
Comment #12
Steven Brown CreditAttribution: Steven Brown as a volunteer commentedHere are some new code deprecation issues. This is from
4592581
.Comment #13
Sahana _N CreditAttribution: Sahana _N at Specbee commentedPlease review the patch.
Comment #15
karishmaamin CreditAttribution: karishmaamin at Specbee commentedplease review the code.
Comment #16
Berdir@karishmaamin: Your patch is incomplete and is not based on the existing work here, reviewing #13.
needs an empty line here.
missing space, missing @param and looks like several of these services aren't updated in services.yaml for the new arguments.
should use messenger()
this is not the event dispatcher.
The test classes aren't moved to the new, correct location (test/src/Functional)
They are also missing the new required $defaultTheme property.
Also, .info.yml files aren't updated and the test theme should have a base theme property, see fails in https://www.drupal.org/pift-ci-job/1648706.
Comment #17
Sahana _N CreditAttribution: Sahana _N at Specbee commentedPlease review the patch.
Comment #19
maacl CreditAttribution: maacl commentedI'll try to merge the different patches into one.
Comment #20
maacl CreditAttribution: maacl commentedI combined #10, #15 and #17 and included the feedback from #16. Thanks Berdir! I hope this will apply.
Comment #22
maacl CreditAttribution: maacl commentedMissed one service, and fixed the code style. Interdiff again for #17.
Comment #24
maacl CreditAttribution: maacl commentedComment #26
Berdirthis is a Drupal 8.8 deprecation, that means the core_version_requirement needs to say ^8.8 || ^9 and core: 8.x needs to be removed.
> Behat\Mink\Exception\ExpectationException: The string "node--view-mode-full" was not found anywhere in the HTML response of the current page.
This fails because this class doesn't exist in stark. The easiest fix for now is to set $defaultTheme to classy instead for that test.
Comment #27
maacl CreditAttribution: maacl commentedThanks, working on it.
@berdir I think you may have had to say something about that. This are deprecations of DomPDF and may be out of scope.
Updating Drupal Core to 8.8 removes `core: 8.x` from configuration also, so I will remove it here, too.
Ah, thank you. Trying to learn this stuff.
Comment #28
maacl CreditAttribution: maacl commentedI tried to figure out what is happening in the failing tests, but did not manage to do so. The EntityPrintAdminTest may need futher conversion to a test with Javascript to keep the original behavior. Lets see what comes back from the Testbot.
Comment #30
maacl CreditAttribution: maacl commentedIntederiff was against wrong patch, here the fixed one.
Comment #31
maacl CreditAttribution: maacl commentedI think I figured out the test fail in EntityPrintActionTest::testDownloadPdfAction(). Should be fixed, is passing locally.
I reverted the changes to EntityPrintAdminTest::testAdminSettings() because I do not understand what the test is looking for exactly and why the fileds are missing. Probably because it requires JS.
Comment #32
abhijeet.kumar2107 CreditAttribution: abhijeet.kumar2107 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #33
abhijeet.kumar2107 CreditAttribution: abhijeet.kumar2107 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #34
heddnThis is still missing a composer require section
drupal/core: "^8 || ^9"
Comment #35
BerdirThat's optional, drupal.org will add that automatically. Only needs to be done if composer.json already has a line for drupal/core.
Comment #36
abhijeet.kumar2107 CreditAttribution: abhijeet.kumar2107 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #37
GaëlGWith latest dev and latest patch, I still get this:
False positive ?
Comment #38
heddnThe key thing to look at is
This module's plugin manager isn't using yaml plugins, so it doesn't apply.
Still NW though because tests are failing.
Comment #39
jungleJust FYI
Comment #40
jungleConfirmed that #37 is the only one left, I should install the module first, before scanning with upgrade_status. The report in #39 was from without installing the module. Sorry for the noisy.
Comment #41
rahul.shindeComment #42
BerdirThat yaml message is bogus and should be ignored
Comment #43
rahul.shindeComment #44
maacl CreditAttribution: maacl commentedThis needs a reroll, after #3147348: Automated Drupal 9 compatibility fixes has been comitted.
Comment #45
jastraat CreditAttribution: jastraat at Technivant commentedRerolled -
Comment #47
jastraat CreditAttribution: jastraat at Technivant commentedAnother potential issue:
ArgumentCountError: Too few arguments to function Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf::__construct(), 5 passed in /modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php on line 103 and exactly 6 expected in Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf->__construct() (line 70 of modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php).
Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf->__construct(Array, 'dompdf', Array, Object, Object) (Line: 103)
Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf::create(Object, Array, 'dompdf', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('dompdf', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('dompdf', Array) (Line: 90)
Drupal\entity_print\Plugin\EntityPrintPluginManager->createInstance('dompdf') (Line: 186)
Drupal\entity_print\Form\SettingsForm->getPluginForm('dompdf', Object) (Line: 159)
Drupal\entity_print\Form\SettingsForm->buildForm(Array, Object, Object)
call_user_func_array(Array, Array) (Line: 531)
Drupal\Core\Form\FormBuilder->retrieveForm('entity_print_admin_settings_form', Object) (Line: 277)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #48
gaspounet CreditAttribution: gaspounet commentedHi!
First of all I'm sorry but I don't know how to produce patches.
The module seems to work for me on Drupal 9 after applying the patch #45 and injecting the file system service in the create function in the file modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php:
An other error occured, I had to replace the static function in the renderSingle function in the file modules/contrib/entity_print/modules/entity_print_views/src/Renderer/ViewRenderer.php by an anonymous function:
Comment #49
jastraat CreditAttribution: jastraat at Technivant commented@gaspounet Thanks!
I've rerolled the patch with those two changes. It does address the issue I posted earlier, but I think there are still problems with entity_print_views. When attempting to use a "view PDF" option in the view header, I get the following error:
Error generating document: Rendering not yet supported for "Drupal\views\Entity\View". Entity Print context "entity"
Looks like it's coming from src/Renderer/RendererFactory
Comment #50
Taran2LOkay, put some time into this. New patch attached.
Comment #51
Taran2LChanges since #49:
core_version_requirement
up (wherecore
has been previously)Comment #52
Taran2LRunning locally against D9.1.x:
Comment #53
Taran2LSo, new patch against D9.1.x:
Remaining deprecation cannot be fixed atm, as this deprecation is coming from Symfony 4.3 (unless D8 support is no longer a goal)
Changes since #50:
Comment #54
Taran2LOops, incorrect interdiff, fixed
Comment #55
Taran2LAnd another small update: test modules/themes do not need to specify supported core versions and let's have stark everywhere
Comment #56
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedTrying something
Comment #57
Taran2Lhi @Sam152 - it does not work, I was trying to achieve the same in #50
In order to be able to run D9 on DrupalCI,
core_version_requirement
must be committed firstComment #58
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedOkay, interesting.
I can commit this, but I do have some questions:
Why can't we use the existing prePrender method? Lets just implement
TrustedCallbackInterface
?Why was all this added?
Updating these to all use dependency injection seems kind of out of scope? Wasn't required for D9 support right?
Comment #60
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI've committed the core_version_requirement changes only, to get a test run working. I'm going to try post a patch with the completely unambiguous stuff to see how far that gets.
Comment #61
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #63
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedLooks like injecting the messenger service was cosmetic as well.
Comment #65
Taran2LHi @Sam152- I can answer to point 2:
So, the
Drupal\Tests\BrowserTestBase
does run tests slighly differently thanDrupal\simpletest\WebTestBase
in the context how AJAX is handled:BrowserTestBase
does not emulate AJAX calls in any way. So, tests run like a page without JS.The current implementation of the form does not work without JS, because settings of the selected plugin are present in the form array only.
What happens:
The form is being built without any plugin config available in the form array because all export types are not set. Then you select plugin for PDF; press Save configuration; then the form is validated and submitted. Submit callback saves the configuration of the selected plugin ID, but it's empty, so the default values are being deleted. This change adds all existing/default config to the form, so it does not matter which plugin will be selected - it's settings will be preserved.
Comment #66
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedOkay, this is something that shouldn't be changed as part of this issue. We should instead be using WebDriverTestBase to correctly test AJAX, leaving the functionality intact.
Comment #67
Taran2L@Sam152 what is the point of removing injections? Backward compatibility? Then add a deprecation with a fallback to the
\Drupal
callBTW, the
core
key should be removed from the info files in order to make it compatible with D9.Then there are a few places where this change should be also made:
core
key can be removed for the testing modules/themes as of 8.8.2:core
key should be removed and replaced withcore_version_requirement
:Well, imho the point of the test is to test functionality, not the AJAX (as it's covered by core tests). A separate JS test can be added in order to test that AJAX is also working. But it's up to you.
Comment #68
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #69
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe 'core' key can be kept in place, to retain support for running the module on 8.7 and lower.
I agree, but the functionality was changed in the patch? Nobody proposed, discussed or agreed to that, so making the change because it's a bit harder to test in this issue is pretty confusing and should be out of scope.
Comment #70
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #71
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedWondering why this was changed? This indicates to me there was a genuine test failure? The fix should be addressing the failure, not updating the assertions in the test.
Comment #72
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedAddressing some final bits of feedback on the patch.
Comment #73
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedRereading some of the feedback in this issue:
So it looks like 'core' should be removed after all.
Looks like the changes in composer.json can go too.
Comment #74
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedSomehow credit dropped off for everyone on this issue, trying to recreddit faithfully. For folks who assign and unassign issues to themselves, please stop.
Comment #76
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #77
gaspounet CreditAttribution: gaspounet commentedThank you for the last commit ;) Cheers!
Comment #78
Taran2L@Sam152, thanks for the quick turnaround and the new stable version!