Problem/Motivation

Create this a custom

Proposed resolution

The default value will be "Don't show again"

Comments

RenatoG created an issue. See original summary.

paulocs’s picture

Status: Active » Needs review
StatusFileSize
new4.01 KB

Here is a patch for this feature.

Please review it.

Thanks!

renatog’s picture

Issue tags: +Needs manual testing

Amazing! Thanks a lot Paulo!

Testing

renatog’s picture

Status: Needs review » Needs work
Issue tags: -Needs manual testing +phpcs, +Novice, +Coding standards, +DrupalCodingStandard

It works well congrats!

But before commit we need to fix phpcs for Drupal Standards and phpcs for Drupal Practice

For Drupal Standards

FILE: /modal_page/modal_page.install
--------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------
 12 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
 18 | ERROR | [x] Expected 1 blank line before function; 2 found
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------


FILE: /modal_page/src/Helper/ModalPageFieldHelper.php
-------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------
 41 | ERROR | [x] Opening brace should be on the same line as the declaration
 44 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 44 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 4
 45 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 46 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 47 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 51 | ERROR | [x] Object operator not indented correctly; expected 4 spaces but found 6
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------

For Best Practice:

FILE: /modal_page/src/Helper/ModalPageFieldHelper.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------------------------------
 44 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
    |         | instead
 45 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
    |         | instead
 46 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
    |         | instead
-------------------------------------------------------------------------------------------------------------------------------------

Time: 341ms; Memory: 8MB
renatog’s picture

Version: 8.x-2.x-dev » 4.0.x-dev
Status: Needs work » Needs review
Issue tags: -phpcs, -Novice, -Coding standards, -DrupalCodingStandard
StatusFileSize
new4.94 KB
renatog’s picture

StatusFileSize
new5.13 KB

Created a script to fill this field on database

$field_to_be_updated = ['dont_show_again_label' => t("Don't show again")];

  modal_page_update_modal_table($field_to_be_updated);

Fixed all phpcs

renatog’s picture

StatusFileSize
new3.28 KB

Interdiff

renatog’s picture

Status: Needs review » Needs work
Issue tags: +hook_update, +hook_update_n

Amazing job Paulo!

Changing the status to needs work because we need to update the name of hook_update

Currently is
modal_page_update_8209

But this value is used for

  • 8 = Drupal version
  • 2 = Modal Page 2
  • 09 = Update Number 09

Accoding with this documentation: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...

On this case we're using 4.0.1 and I don't know how create it 🤔

This example works:
function modal_page_update_9401() {

But I don't know if it's correct.

We need to check it.

RenatoG credited dww.

renatog’s picture

Talked on Drupal Slack:

@Greg:

In terms of code function, it just needs to be a sequential number higher than the previous hook update number. In terms of convention, I don't know if there is one yet. I'd just go with 9001 if you have a 9000
I could be totally wrong about that though. This is new stuff for me.

@DWW

dww 11 hours ago
Technically, it can be anything higher than the previous update. ;)

dww 11 hours ago
But the safer bet would probably be to jump to 5 digits (or more).

dww 11 hours ago
Lemme try to dig up the documentation on this.

dww 11 hours ago
https://www.drupal.org/project/drupal/issues/3010334
Drupal.org
Document how contrib hook_update_N() should be numbered now that modules can be compatible with multiple major branches and versioned semantically
Problem/Motivation In 8.7.7 and 8.8.3, core has already added the needed support for modules to be compatible with multiple major versions and versioned semantically. However, we didn't do a thorough review outside the changed functionality for corrections to make to existing documentation. hook_update_N() is one such place, and it's important that the numbering scheme remain intact despite these changes. (Confusion about update hook numbering could cause data integrity issues.)
Oct 30th, 2018

dww 11 hours ago
So yeah, eeek, none of that is "decided" yet. But unless you're planning for your module to move into core, probably the safest bet is to jump to 5 digits. E.g. project_update_40001()

dww 11 hours ago
Updates added in the 4.1.x branch would be 40101.
4.7.x branch would be 40701
4.11.x branch would be 41101
5.0.x branch would be 50001
...

dww 11 hours ago
(assuming you only plan to need 100 DB updates for each minor branch). ;)

So I think we can use:

modal_page_update_40001(){
  // Update
 }

Makes sense?

paulocs’s picture

Status: Needs work » Needs review
StatusFileSize
new566 bytes
new5.13 KB

I tested with modal_page_update_40001 and it works for me!
It makes sense to me after @DWW said:

Updates added in the 4.1.x branch would be 40101.
4.7.x branch would be 40701
4.11.x branch would be 41101
5.0.x branch would be 50001

Here is a patch and the interdiff.

Thanks

renatog’s picture

Issue tags: +Needs manual testing

Amazing! Thanks a lot Paulo!

  • RenatoG committed e8280a9 on 4.0.x authored by paulocs
    Issue #3163519 by RenatoG, paulocs, Greg Boggs, dww: Create option to...
renatog’s picture

Status: Needs review » Fixed
Issue tags: -hook_update, -hook_update_n, -Needs manual testing

Committed to the dev branch!

Thank you so much, guys!

Best regards.

renatog’s picture

Status: Fixed » Closed (fixed)