Deprecated function: Creation of dynamic property

Created on 18 September 2023, 9 months ago
Updated 20 May 2024, about 1 month ago

Drupal 10.1
php 8.2

Deprecated function: Creation of dynamic property Drupal\views_natural_sort\ViewsNaturalSortService::$configFactory is deprecated in Drupal\views_natural_sort\ViewsNaturalSortService->__construct() (line 42 of modules/contrib/views_natural_sort/src/ViewsNaturalSortService.php).
Drupal\views_natural_sort\ViewsNaturalSortService->__construct(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) (Line: 259)
Drupal\Component\DependencyInjection\Container->createService(Array, 'views_natural_sort.service') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('views_natural_sort.service') (Line: 197)
Drupal::service('views_natural_sort.service') (Line: 12)
views_natural_sort_views_data_alter(Array, NULL, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('views_data', Array) (Line: 245)
Drupal\views\ViewsData->getData() (Line: 154)
Drupal\views\ViewsData->get('block_content') (Line: 91)
Drupal\ds\Plugin\Derivative\DsEntityRow->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 291)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('data_field') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('data_field', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('data_field') (Line: 828)
Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin('row') (Line: 129)
Drupal\views\Plugin\views\style\StylePluginBase->init(Object, Object, Array) (Line: 831)
Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin('style') (Line: 346)
Drupal\rest\Plugin\views\display\RestExport->collectRoutes(Object) (Line: 120)
Drupal\views\EventSubscriber\RouteSubscriber->routes()
call_user_func(Array) (Line: 146)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 518)
drupal_flush_all_caches() (Line: 205)
Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 182)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I think it's a minor code fix, but I can't solve it myself.
Maybe someone can help?

๐Ÿ› Bug report
Status

Fixed

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡ฑPoland pingwin_cracow

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pingwin_cracow
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    Shreya_th โ†’ made their first commit to this issueโ€™s fork.

  • Assigned to Shreya_98
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    8 pass
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    Hi @generalredneck,
    I have created MR for Deprecated function: Creation of dynamic property . make all possible changes according to issue in ViewsNaturalSortService.php file. Kindly review the changes.

    Thank you.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    @Shreya_th,
    Thanks for making the changes. You got some code formatting issues, but otherwise, it's good to go. If you will make the changes, I would love to merge this.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    Hi @generalredneck,
    It will be very helpful if you will elaborate that which type of code formatting issues. So it will be easy for me to make changes in code.

    Thank you

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    Shreya_th,
    COnsider using phpcs with the DrupalPractice ruleset. Here is the full list of coding standards infractions introduced by this PR.

    FILE: /home/allan/workspace/d10/web/modules/contrib/views_natural_sort/src/ViewsNaturalSortService.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 24 ERRORS AFFECTING 21 LINES
    -----------------------------------------------------------------------------------------------------------------------
      31 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
      31 | ERROR | [x] Whitespace found at end of line
      33 | ERROR | [x] Whitespace found at end of line
      34 | ERROR | [x] Expected 1 space(s) before asterisk; 2 found
      34 | ERROR | [x] Expected 1 space after asterisk; 2 found
      35 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
      36 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
      38 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
      39 | ERROR | [x] Expected 1 space(s) before asterisk; 3 found
      40 | ERROR | [x] Expected 1 space(s) before asterisk; 3 found
      41 | ERROR | [x] Expected 1 space(s) before asterisk; 3 found
      42 | ERROR | [x] Expected 1 space(s) before asterisk; 3 found
      69 | ERROR | [x] Expected "\Drupal\Core\Queue\QueueFactory" but found "\Drupal\Core\Queue\QueueFactory;" for @var
         |       |     tag in member variable comment
      76 | ERROR | [x] Expected "\Drupal\Core\Queue\QueueWorkerManagerInterface" but found
         |       |     "\Drupal\Core\Queue\QueueWorkerManagerInterface;" for @var tag in member variable comment
     108 | ERROR | [ ] Parameter $loggerFactory is not described in comment
     110 | ERROR | [x] Whitespace found at end of line
     115 | ERROR | [ ] Missing parameter name
     117 | ERROR | [ ] Doc comment for parameter $transformationManager does not match actual variable name $translator
     132 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1 spaces
     134 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1 spaces
     135 | ERROR | [x] Whitespace found at end of line
     136 | ERROR | [x] Additional blank lines found at end of doc comment
     137 | ERROR | [ ] Expected type hint "ConfigFactoryInterface"; found "ConfigFactory" for $configFactory
     137 | ERROR | [ ] Expected type hint "ViewsDataInterface"; found "ViewsData" for $viewsData
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 19 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
  • Assigned to Shreya_98
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    @generalredneck thank you for commenting issues. I Will definitely solve this code standard issues by today itself.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    8 pass
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    Hi @generalredneck,
    I have fixed all the code standard issues . Kindly Review the changes.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    @Shreya_th,

    Would you mind explaining the changes made at https://git.drupalcode.org/project/views_natural_sort/-/merge_requests/1...

    diff --git a/src/ViewsNaturalSortService.php b/src/ViewsNaturalSortService.php
    index 2603a25cd29f244f935a690e62aeee4a8dd94609..b7106713616b2a231dc149b43c601328f8679efa 100644
    --- a/src/ViewsNaturalSortService.php
    +++ b/src/ViewsNaturalSortService.php
    @@ -313,13 +408,13 @@ class ViewsNaturalSortService {
       public function getViewsBaseTable($fieldDefinition) {
         $entityType = $this->entityTypeManager->getDefinition($fieldDefinition->getTargetEntityTypeId());
         $base_table = $entityType->getBaseTable() ?: $entityType->id();
    -    $views_revision_base_table = NULL;
    +    // $views_revision_base_table = NULL;
         $revisionable = $entityType->isRevisionable();
    -    $base_field = $entityType->getKey('id');
    -
    -    $revision_table = '';
    +    // $base_field = $entityType->getKey('id');
    +    // $revision_table = '';
         if ($revisionable) {
    -      $revision_table = $entityType->getRevisionTable() ?: $entityType->id() . '_revision';
    +      // $revision_table = $entityType->getRevisionTable() ?:
    +      // $entityType->id() . '_revision';
         }
     
         $translatable = $entityType->isTranslatable();
    @@ -332,12 +427,12 @@ class ViewsNaturalSortService {
         // have a revision table name set in
         // \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout() so we
         // apply the same kind of logic.
    -    $revision_data_table = '';
    +    // $revision_data_table = '';.
         if ($revisionable && $translatable) {
    -      $revision_data_table = $entityType->getRevisionDataTable() ?: $entityType->id() . '_field_revision';
    +      // $revision_data_table = $entityType->getRevisionDataTable() ?:
    +      // $entityType->id() . '_field_revision';
         }
    -    $revision_field = $entityType->getKey('revision');
    -
    +    // $revision_field = $entityType->getKey('revision');
         $views_base_table = $base_table;
         if ($data_table) {
           $views_base_table = $data_table;
    

    It appears that you are adding some commented out lines of code for some reason.

    I didn't expect you to go through the whole module and fix all the changes that failed coding standards up until now but thank you.

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland pingwin_cracow

    I have made the code corrections presented
    https://git.drupalcode.org/project/views_natural_sort/-/merge_requests/11...
    Unfortunately, there are still errors in the sequence.
    I wonder if there are still errors in the code, or maybe it's in another module?

    I use it
    D 10.1.4
    php 8.2

    new errors detected:

    Deprecated function: Creation of dynamic property Drupal\views_natural_sort\IndexRecord::$type is deprecated in Drupal\views_natural_sort\IndexRecord->generateType() (line 213 of modules/contrib/views_natural_sort/src/IndexRecord.php).
    Drupal\views_natural_sort\IndexRecord->generateType() (Line: 100)
    Drupal\views_natural_sort\IndexRecord->setEntityType('paragraph') (Line: 66)
    Drupal\views_natural_sort\IndexRecord->__construct(Object, Array) (Line: 397)
    Drupal\views_natural_sort\ViewsNaturalSortService->createIndexRecord(Array) (Line: 342)
    Drupal\views_natural_sort\ViewsNaturalSortService->storeIndexRecordsFromEntity(Object) (Line: 92)
    views_natural_sort_entity_insert(Object) (Line: 102)
    views_natural_sort_entity_update(Object)
    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'views_natural_sort') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object) (Line: 408)
    Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 217)
    Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 900)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 564)
    Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781)
    Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 489)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 303)
    Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->preSave() (Line: 233)
    Drupal\Core\Field\FieldItemList->delegateMethod('preSave') (Line: 191)
    Drupal\Core\Field\FieldItemList->preSave() (Line: 938)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 888)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 529)
    Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
    Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 483)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 270)
    Drupal\node\NodeForm->save(Array, Object)
    call_user_func_array(Array, Array) (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('node_news_edit_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 182)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    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: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    If you can help, I will be grateful.
    Best Regards

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada TrevorBradley

    I'm similarly seeing

    Deprecated function: Creation of dynamic property Drupal\views_natural_sort\IndexRecord::$type is deprecated in Drupal\views_natural_sort\IndexRecord->generateType() (line 213 of /app/web/modules/contrib/views_natural_sort/src/IndexRecord.php)

    It's still deprecated, not an error, so give me a few days to come back around to this.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 8 months ago
    8 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 8 months ago
    8 pass
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada TrevorBradley

    Argh, my git logs reference the wrong issue. I'm going to see if I can fix this, but feel free to trash my commits and reroll them.

  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update about 2 months ago
    8 pass
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom malcomio

    As mentioned in #11, the current merge request includes various other changes that don't relate to this issue.

    It makes sense to keep changes limited to the issue in question, and fix coding standards issues separately.

    https://git.drupalcode.org/project/views_natural_sort/-/merge_requests/13 just addresses the deprecations in src/ViewsNaturalSortService.php

  • Pipeline finished with Success
    about 2 months ago
    Total: 145s
    #158593
  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    As indicated by the PHPStan run, this only fixes some of the errors. We had a similar fix marked in ๐Ÿ› Deprecation errors Fixed but for different pieces. I'm going to update the merge request here with the other undefined property fixes.

  • Status changed to Fixed about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States generalredneck

    So I'm leaving the last PHPstan error for another ticket. It's addressed by ๐Ÿ“Œ Automated Drupal 11 compatibility fixes for views_natural_sort Needs review . Thanks so much for your work.

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

Production build 0.69.0 2024