Patterns and synced patterns (reusable blocks)

Created on 21 November 2023, 12 months ago
Updated 11 June 2024, 5 months ago

Patterns and reusable blocks are now merged. This allows for the user to save patterns (synced or unsynced). Also, reusable blocks are now called synced patterns.

Use wp_pattern_sync_status property to distinguish types (API endpoint - /v2/blocks).
wp_pattern_sync_status = '' - synced
wp_pattern_sync_status = 'unsynced' - unsynced

In addition to the content block type that is created, a vocabulary (Pattern Category) needs to be created and add a taxonomy reference to Reusable block type.
Add Sync Status field to Reusable block type.

Pattern Category terms can be created when saving patterns.

Add wp_pattern_category (array of taxonomy ids) to API endpoints.

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇵🇹Portugal marcofernandes

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

Merge Requests

Comments & Activities

  • Issue created by @marcofernandes
  • Status changed to Fixed 12 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Needs work 10 months ago
  • There's no update hook for the new reusable block field_pattern_category and field_pattern_sync_status fields introduced here. This breaks on a site upgrading from 2.x whenever you attempt to add a new pattern:

    The website encountered an unexpected error. Please try again later.<br><br><em class="placeholder">InvalidArgumentException</em>: Field field_pattern_category is unknown. in <em class="placeholder">Drupal\Core\Entity\ContentEntityBase->getTranslatedField()</em> (line <em class="placeholder">587</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/ContentEntityBase.php</em>). <pre class="backtrace">Drupal\Core\Entity\ContentEntityBase->get('field_pattern_category') (Line: 323)
    Drupal\gutenberg\Controller\ReusableBlocksController->getBlockAttributes(Object) (Line: 229)
    Drupal\gutenberg\Controller\ReusableBlocksController->save(Object, NULL)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    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: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
    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: 692)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    </pre>
    

    An upgrade path should be created or documented. Ideally something in an update hook.

  • Pipeline finished with Success
    9 months ago
    Total: 245s
    #88754
  • Status changed to Needs review 9 months ago
  • Pipeline finished with Success
    9 months ago
    Total: 1083s
    #96145
  • Pipeline finished with Success
    9 months ago
    Total: 594s
    #107439
  • Pipeline finished with Success
    9 months ago
    #111876
  • Pipeline finished with Success
    9 months ago
    Total: 331s
    #111895
  • Sorry it took a while to get back to this. I like the approach, but it seems like \Drupal::service('config.installer')->installDefaultConfig('module', 'gutenberg') will override any local configuration overrides the sites might have, so we need special handling for it.

    I've pushed an update to the branch with the updated logic, feel free to test and review, and let me know if it all makes sense.

  • Pipeline finished with Success
    8 months ago
    #114847
  • Pipeline finished with Success
    8 months ago
    Total: 567s
    #117490
  • Pipeline finished with Success
    8 months ago
    Total: 347s
    #126547
  • Pipeline finished with Failed
    8 months ago
    Total: 737s
    #126559
  • Pipeline finished with Success
    8 months ago
    Total: 826s
    #126597
  • Pipeline finished with Canceled
    8 months ago
    Total: 627s
    #126639
  • Pipeline finished with Success
    8 months ago
    Total: 840s
    #126645
  • Pipeline finished with Success
    8 months ago
    Total: 935s
    #126649
  • Pipeline finished with Skipped
    8 months ago
    #136819
  • Pipeline finished with Success
    7 months ago
    Total: 219s
    #143384
  • Pipeline finished with Success
    7 months ago
    Total: 248s
    #143394
  • 🇵🇹Portugal marcofernandes

    I tested from a clean Drupal instance, installed Gutenberg 2.x, enabled Gutenberg for Basic Page changed Gutenberg text format a bit just to check if configuration wouldn't be override. Then I updated Gutenberg to this branch and did an update db but it threw this error:

      Unable to decode output into JSON: Syntax error                                          
    
      TypeError: Drupal\Core\Field\WidgetBase::__construct(): Argument #5 ($third_party_setti  
      ngs) must be of type array, null given, called in /var/www/html/web/core/lib/Drupal/Cor  
      e/Field/WidgetBase.php on line 64 in Drupal\Core\Field\WidgetBase->__construct() (line   
      53 of /var/www/html/web/core/lib/Drupal/Core/Field/WidgetBase.php).                      
    

    Ran update db again but at this time no error occurred and configuration seemed to be ok. At least no override on the text format settings and fields were created.

  • Pipeline finished with Success
    7 months ago
    Total: 185s
    #153774
  • Pipeline finished with Failed
    7 months ago
    Total: 741233s
    #155878
  • Pipeline finished with Skipped
    7 months ago
    #163535
  • Pipeline finished with Success
    7 months ago
    Total: 240s
    #163531
  • Pipeline finished with Success
    6 months ago
    Total: 218s
    #177094
  • Pipeline finished with Success
    6 months ago
    Total: 222s
    #177099
  • Pipeline finished with Canceled
    6 months ago
    Total: 49s
    #177113
  • Pipeline finished with Success
    6 months ago
    Total: 224s
    #177114
  • Pipeline finished with Success
    6 months ago
    Total: 310s
    #177117
  • Pipeline finished with Success
    6 months ago
    Total: 268s
    #177122
  • Status changed to Fixed 6 months ago
  • Pipeline finished with Success
    6 months ago
    Total: 217s
    #177682
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Canceled
    5 months ago
    Total: 16s
    #197469
  • Pipeline finished with Skipped
    5 months ago
    #197471
  • Pipeline finished with Success
    4 months ago
    Total: 693s
    #219108
  • Pipeline finished with Success
    4 months ago
    Total: 756s
    #219115
  • Pipeline finished with Success
    4 months ago
    Total: 301s
    #228750
  • Pipeline finished with Failed
    4 months ago
    Total: 244s
    #237570
  • Pipeline finished with Failed
    4 months ago
    Total: 246s
    #237591
  • Pipeline finished with Success
    4 months ago
    #237597
  • Pipeline finished with Failed
    4 months ago
    #237610
  • Pipeline finished with Failed
    4 months ago
    #237627
  • Pipeline finished with Failed
    4 months ago
    #237626
  • Pipeline finished with Canceled
    4 months ago
    Total: 94s
    #237628
  • Pipeline finished with Failed
    4 months ago
    Total: 274s
    #237630
  • Pipeline finished with Success
    4 months ago
    Total: 273s
    #237637
  • Pipeline finished with Failed
    4 months ago
    #237643
  • Pipeline finished with Failed
    4 months ago
    #237645
  • Pipeline finished with Canceled
    4 months ago
    Total: 279s
    #237638
  • Pipeline finished with Success
    4 months ago
    Total: 1995s
    #237647
  • Pipeline finished with Success
    4 months ago
    #237691
  • Pipeline finished with Success
    4 months ago
    Total: 258s
    #237705
  • Pipeline finished with Failed
    4 months ago
    Total: 453s
    #237710
  • Pipeline finished with Failed
    4 months ago
    Total: 373s
    #237745
  • Pipeline finished with Skipped
    4 months ago
    #238014
  • Pipeline finished with Success
    3 months ago
    Total: 216s
    #247392
  • Pipeline finished with Success
    3 months ago
    Total: 485s
    #247393
  • Pipeline finished with Success
    3 months ago
    Total: 196s
    #248079
  • Pipeline finished with Failed
    3 months ago
    Total: 708s
    #267994
  • Pipeline finished with Failed
    3 months ago
    Total: 139s
    #269013
  • Pipeline finished with Success
    3 months ago
    #269047
  • Pipeline finished with Success
    3 months ago
    Total: 143s
    #269065
  • Pipeline finished with Success
    3 months ago
    #269068
  • Pipeline finished with Success
    3 months ago
    Total: 150s
    #269079
  • Pipeline finished with Success
    3 months ago
    Total: 147s
    #269105
  • Pipeline finished with Failed
    3 months ago
    #269110
  • Pipeline finished with Failed
    3 months ago
    #269115
  • Pipeline finished with Failed
    3 months ago
    #269116
  • Pipeline finished with Success
    3 months ago
    #269130
  • Pipeline finished with Failed
    3 months ago
    Total: 136s
    #269134
  • Pipeline finished with Failed
    3 months ago
    #269152
  • Pipeline finished with Failed
    3 months ago
    #269163
  • Pipeline finished with Success
    3 months ago
    Total: 153s
    #269166
  • Pipeline finished with Success
    3 months ago
    Total: 150s
    #269172
  • Pipeline finished with Success
    3 months ago
    Total: 197s
    #269174
  • Pipeline finished with Success
    3 months ago
    Total: 140s
    #269209
  • Pipeline finished with Failed
    3 months ago
    Total: 141s
    #269254
  • Pipeline finished with Failed
    3 months ago
    Total: 174s
    #269258
  • Pipeline finished with Failed
    3 months ago
    Total: 143s
    #269302
  • Pipeline finished with Failed
    3 months ago
    Total: 196s
    #269312
  • Pipeline finished with Success
    3 months ago
    Total: 134s
    #269325
  • Pipeline finished with Failed
    3 months ago
    Total: 154s
    #269341
  • Pipeline finished with Success
    3 months ago
    #269364
  • Pipeline finished with Success
    3 months ago
    #270110
  • Pipeline finished with Success
    3 months ago
    Total: 149s
    #270220
  • Pipeline finished with Failed
    3 months ago
    Total: 121s
    #270640
  • Pipeline finished with Success
    2 months ago
    Total: 340s
    #280260
  • Pipeline finished with Success
    about 2 months ago
    Total: 135s
    #287278
  • Pipeline finished with Failed
    about 2 months ago
    Total: 537s
    #287552
  • Pipeline finished with Success
    about 2 months ago
    Total: 144s
    #287720
  • Pipeline finished with Success
    about 2 months ago
    Total: 139s
    #288145
  • Pipeline finished with Failed
    about 2 months ago
    Total: 786s
    #289896
  • Pipeline finished with Failed
    about 2 months ago
    Total: 271s
    #291900
  • Pipeline finished with Success
    about 2 months ago
    Total: 219s
    #291914
  • Pipeline finished with Failed
    about 2 months ago
    Total: 229s
    #294665
  • Pipeline finished with Success
    about 2 months ago
    Total: 163s
    #294689
  • Pipeline finished with Skipped
    about 2 months ago
    #295383
  • Pipeline finished with Success
    about 1 month ago
    Total: 166s
    #301758
  • Pipeline finished with Success
    about 1 month ago
    Total: 119s
    #303978
  • Pipeline finished with Success
    about 1 month ago
    Total: 219s
    #304119
  • Pipeline finished with Success
    16 days ago
    Total: 151s
    #325065
  • Pipeline finished with Success
    7 days ago
    Total: 420s
    #333741
  • Pipeline finished with Success
    6 days ago
    Total: 328s
    #333750
  • Pipeline finished with Success
    6 days ago
    Total: 303s
    #333755
  • Pipeline finished with Success
    6 days ago
    Total: 348s
    #334272
Production build 0.71.5 2024