Quantcast
Channel: Issues for Drupal core
Viewing all 293396 articles
Browse latest View live

Allow comment submission status messages and log messages to be overridden more easily in subclasses of CommentForm

$
0
0

Problem/Motivation

It would be really nice if the logger messages and messages passed to drupal_set_message() in the \Drupal\comment\CommentForm::save() method were easier to override in classes that extend CommentForm.

For example, in \Drupal\comment\Form\DeleteForm, there are standalone methods in that form class, and in its parent classes, to return status messages and to insert messages into the logs:

  • ::getQuestion()
  • ::getDescription()
  • ::getDeletionMessage()
  • ::logDeletionMessage()

These helper methods are then used where needed in the form constructor and form submit handlers.

Example from \Drupal\Core\Entity\ContentEntityConfirmFormBase (a parent class of \Drupal\comment\Form\DeleteForm), which uses ::getQuestion() and ::getDescription():

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);

    $form['#title'] = $this->getQuestion();

    $form['#attributes']['class'][] = 'confirmation';
    $form['description'] = array('#markup' => $this->getDescription());
    $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);

    // By default, render the form using theme_confirm_form().
    if (!isset($form['#theme'])) {
      $form['#theme'] = 'confirm_form';
    }
    return $form;
  }

Example from \Drupal\Core\Entity\ContentEntityDeleteForm (a parent class of \Drupal\comment\Form\DeleteForm), which uses ::getDeletionMessage() and ::logDeletionMessage():

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $this->getEntity();

    // Make sure that deleting a translation does not delete the whole entity.
    if (!$entity->isDefaultTranslation()) {
      $untranslated_entity = $entity->getUntranslated();
      $untranslated_entity->removeTranslation($entity->language()->getId());
      $untranslated_entity->save();
      $form_state->setRedirectUrl($untranslated_entity->urlInfo('canonical'));
    }
    else {
      $entity->delete();
      $form_state->setRedirectUrl($this->getRedirectUrl());
    }

    drupal_set_message($this->getDeletionMessage());
    $this->logDeletionMessage();
  }

This approach makes it easy to extend the form class and just override the message text without having to duplicate the code of the entire submit handler method.

For the sake of completeness, here is how the custom child form class would be set as the handler for the comment entity type:

/**
 * Implements hook_entity_type_alter().
 */
function my_custom_comments_entity_type_alter(array &$entity_types) {
  $entity_types['comment']->setFormClass('delete', 'Drupal\my_custom_comments\Form\DeleteForm');
}

As it stands right now, the ::save() method on the default CommentForm doesn't make it easy to override the confirmation messages without reimplementing the whole method in a child class:

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $comment = $this->entity;
    $entity = $comment->getCommentedEntity();
    $field_name = $comment->getFieldName();
    $uri = $entity->urlInfo();
    $logger = $this->logger('content');

    if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) {
      $comment->save();
      $form_state->setValue('cid', $comment->id());

      // Add a log entry.
      $logger->notice('Comment posted: %subject.', array(
          '%subject' => $comment->getSubject(),
          'link' => $this->l(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id()))
        ));

      // Explain the approval queue if necessary.
      if (!$comment->isPublished()) {
        if (!$this->currentUser->hasPermission('administer comments')) {
          drupal_set_message($this->t('Your comment has been queued for review by site administrators and will be published after approval.'));
        }
      }
      else {
        drupal_set_message($this->t('Your comment has been posted.'));
      }
      $query = array();
      // Find the current display page for this comment.
      $field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$field_name];
      $page = $this->entityManager->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
      if ($page > 0) {
        $query['page'] = $page;
      }
      // Redirect to the newly posted comment.
      $uri->setOption('query', $query);
      $uri->setOption('fragment', 'comment-' . $comment->id());
    }
    else {
      $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject()));
      drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())), 'error');
      // Redirect the user to the entity they are commenting on.
    }
    $form_state->setRedirectUrl($uri);
  }

Proposed resolution

Patch file attached that adds helper methods that supply the content for status messages and that write messages to the logs.

Remaining tasks

Needs community review and feedback.

User interface changes

None.

API changes

Exposes additional helper methods in the CommentForm class that child classes can override.

Data model changes

None.


Ignore, testing issue

Inline labels in classy theme do not clear floats

$
0
0

Problem/Motivation

When choosing inline labels in "manage display," the classy theme (and template) attaches a "field--inline-label" class to the div that contains the inline field and label. Then, the inline label contains a class ".field--label-inline .field__label" that floats the label left.

However the enveloping div should include a "clearfix." Because clearfix is missing, any subsequent non-text fields will float up onto one line.

This bug can often be disguised if a field containing an inline label is a text field, since text fields automatically contain a clearfix, or when a field using an inline label is followed by a text field, since that clearfix will clear the float from the prior inline label.

NOTE: Since Bartik uses classy as a base theme, the problem occurs there as well.

Proposed resolution

Add a clearfix class to the div enclosing the field label and field contents in the template, OR

Create a ".field--label-inline" class for the div only, that will clear the label's float in "core\themes\classy\css\components\field.css"

Remaining tasks

User interface changes

API changes

Data model changes

Allow BaseFieldDefinition::setInitialValueFromField() to set a default value - this fixes issues with block_content_update_8400()

$
0
0

Problem/Motivation

After I made composer updates to Drupal 8.5 I ran drush updb --entity-updates.
It fails on the following update:

 [notice] Update started: block_content_update_8400
 [error]  Exception thrown while performing a schema update. SQLSTATE[22004]: Null value not allowed: 1138 Invalid use of NULL value: ALTER TABLE {block_content_field_revision} CHANGE `status` `status` TINYINT NOT NULL; Array
(
)
 [error]  Update failed: block_content_update_8400 

block_content_field_revision table is not empty.

Proposed resolution

Add a new argument with a default value to \Drupal\Core\Field\BaseFieldDefinition::setInitialValueFromField() so that it can provide a default value in case the entity does not have a corresponding field value.

Remaining tasks

User interface changes

None

API changes

setInitialValueFromField($field_name) changed to setInitialValueFromField($field_name, $default_value = NULL). For docs on what $default_value can be see \Drupal\Core\Field\BaseFieldDefinition::setInitialValue().

Data model changes

None

Unnecessary File Information Disclosure

$
0
0

I did not submit this to the Security Team because they are already aware and it was made public in 2016: https://www.drupal.org/forum/newsletters/security-public-service-announc...

The purpose of this issue is to fix the exposure, at least for Webform, with a very simple patch.

Problem

File link is provided to user without any validation.
The full web-accessible path of any uploaded file is reported to the (possibly anonymous) visitor who uploaded the file, even if that visitor does not have submission result access. This file is uploaded and web-accessible without any other form validation being enforced (including CAPTCHA), and (if the submission is never completed) will stay on disk at the given location until the next cron run after 6 hours.

There is no simple means of locking down these file uploads, without requiring users to create logins. Using a private file system will not prevent access or misuse of files - they're still potentially accessible by 3rd parties. The obvious mitigation step of using randomly generated subdirectories (as Google Docs, OneDrive, etc. use) does nothing, because the complete path is still returned to the user.

With the path, malicious users can (not an exhaustive list):

  • Use the site for free 6-hour webhosting (which can mean a lot with the speed of bots)
  • Potentially craft same-origin XSS (normal browser security will be ineffective)
  • Enumerate files uploaded by other users
  • Send legitimate-looking phishing emails (unsuspecting users will see document links coming from their own server)
  • SEO spam (as mentioned in the PSA) - files are uploaded and then submitted to search engines to borrow (and hurt) the reputation of the victim site

Reproduction

You can reproduce this by:

  1. Enabling the module
  2. Creating a Webform with a File component
  3. Optionally, create mandatory fields or validation rules, enable CAPTCHA, etc. - it will have no impact
  4. As a user with access to submit to the Webform (often anonymous), upload a file by clicking the "Upload" AJAX button instead of submitting the form, or intentionally fail validation of some other field (don't enter a required field, or purposely don't pass CAPTCHA).
  5. Observe that the form (either when updated via AJAX or after reloading with form errors) will have a link to the uploaded file next to the "Remove" button.

But why?

I can think of no reason that the file's ultimate address is necessary to display to the user that just uploaded the file. They don't need to be able to click it and retrieve a copy - they just uploaded it. There are a myriad abuses possible with this information, and very few legitimate reasons to display it, so why not remove it?

Solution

The underlying problem with the File module can't be fixed, but there's no reason that Webform should provide another instance of the same problem. webform/components/file.inc already implements as webform_file_allow_access() function. Simply overwrite the output in that function to strip the file link, preventing unnecessary information disclosure. Patch provided.

Comments created in translation are displayed only in the default language

$
0
0

Problem/Motivation

Steps to reproduce:

Install
Install (Enable) content translation module
Install (Enable) comment module
Add a language and configure Article as translatable
Add comment type and configure Article as translatable
Go to admin/config/regional/content-language
Add a field comment in Article as translatable
Create an Article and add translation
Post comments in translated article (as anonymous)
Go to admin/content/comment and publish the comment

Result:
Comment will published in original article

Desired:
Comment should be displayed in translated article

Proposed resolution

Check how is saved the comment in original language or in translation language
Check if the problem is how is displayed the comment.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Comments are not filtered on language

$
0
0

Problem/Motivation

The situation, I have a Drupal 8 multilingual node where Dutch is the main language and French is the other.
If I add a comment to the Dutch node translation and approve it, it will show. But it will also show in the French translation.
I think it is rather weird to see a mix of Dutch and French below a Dutch node.

P.S. as a quick workaround I created a view which shows me the comments based on the current node and filtered on a language. But it would be better that this approach is not necessary.

Proposed resolution

Add an option to select the language for show the comments.

Remaining tasks

Add test coverage.

User interface changes

A new option is added in the 'Manage display' tab for the comment which allow to config the language filter to show the comments.

API changes

The language_manager service is now injected to the CommentStorage class.

Data model changes

A new configuration named language_filter is now available to store the language configuration for display the comments.

Allow profiles to provide a base/parent profile and load them in the correct order

$
0
0

Updated: Comment #393

Problem/Motivation

With Drupal 7's vastly-improved install profile functionality, and the recently-improved drupal.org distribution packaging infrastructure, many new install profiles have been created, and they are awesome.

However, install profiles are not inheritable, so if you want to, say, take Drupal Commons, and base your site off of it, but add one or two extra modules in your own customized install profile, you have to clone the entire install profile and change it to your needs. Allowing install profiles to declare base profiles (just like themes can declare base themes) would drastically simplify customizations to existing distributions by:

  • Inheriting configuration from a parent install profile (base-profile)
  • Overriding specific configuration from the base-profile
  • Inheriting customizations in the installer from the base-profile
  • Having additional installer tasks and form items to customize their own "start-state"

Additional motivations are detailed on Dries's blog post.

Proposed resolution

  • Modify the module load system to take into account base install profiles.
  • Modify the install profile system to run parent installer(s) in the correct order.
  • One proposed solution was to simply use modules instead of profile inheritance. This was discussedatlength and the prevailing attitude was that the functionality for profile inheritance has valuable use cases that cannot be solved by modules alone.
  • An early resolution was to include a tag to exclude dependencies and themes. In an effort to clearly define focus for this patch, this functionality was removed from this patch. The use case for excluded_dependencies and excluded_themes is still very much valid, so this feature request has been given its own issue.

Remaining tasks

  • Create plan
  • Write useful issue summary
  • Extensively test this patch against a real-world base-profile
  • Add to existing documentation page (To be published only after patch is applied.)

User interface changes

None.

API changes

Install profiles can define base profiles using the syntax base profile: BASE_PROFILE inside their .info.yml files.

Or, override dependencies from the base profile using the syntax:

base profile:
  name: BASE_PROFILE

The SQL storage cannot change the schema for an existing entity type (node) with data

$
0
0

Hi all,

When updating from 8.4.5 to 8.5.1 I have this error (on 4 different sites):

system-module
#8501 bijwerken
Mislukt: Drupal\Core\Entity\EntityStorageException: The SQL storage cannot change the schema for an existing entity type (node) with data. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onEntityTypeUpdate() (regel 347 van /home/oms/domains/domain.nl/public_html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

What can I do to fix this?

Thanks,
Rolf

Classy's media.html.twig not printing view_mode class properly

$
0
0

What are the steps required to reproduce the bug?
View a media entity

What behavior were you expecting?
Expect output to have a view mode specific CSS class

What happened instead?
Output has a class "media--view-mode-" with no view mode appended to the class name.
<article data-quickedit-entity-id="media/19" class="contextual-region media media--type-video-embed media--view-mode-" data-quickedit-entity-instance-id="0">

Classy's media.html.twig seems to be expecting the view_mode to be an object and print its ID

{%
  set classes = [
    'media',
    'media--type-' ~ media.bundle()|clean_class,
    not media.isPublished() ? 'media--unpublished',
    view_mode ? 'media--view-mode-' ~ view_mode.id()|clean_class,
  ]
%}

Yet the view_mode is sent to the template as a string, so nothing is being appended.

Adding default class to default images

$
0
0

I needed to add a default class to images that are using the default image. This is mainly because I wanted a teaser image in list views, but dont want to show the default image when viewing the actual node.

Attached is my patch so the default-image class is added to default images.

Provide default values for the table name annotations for content entities

$
0
0

Problem/Motivation

Split from #2232465: Remove table names from entity annotations

We want to move towards making the actual table names an (internal) implementation detail. It should not be required to specify them on the entity type, the only thing that is required is defining if it should be revisionable and/or translatable.

Proposed resolution

In ContentEntityType, set default values if they are not already set. Remove it from all test entity types as a start to make sure it works.

Remaining tasks

User interface changes

API changes

Data model changes

when updating to 8.5.1, block content update 8400 does not run at all

$
0
0

When updating to 8.5.1 from 8.4.5/8.4.6, the block_content update 4800 does not run. NO matter how many times I tried to run update.php, I still can not see the new field added to the database.
And always see what's in the attached images.

oh, and my custom blocks can not be seen except by an admin.

the modules I have installed are the following:

----------------------- ----------------------------------------------------------------------- --------- ---------------- 
  Package                 Name                                                                    Status    Version         
 ----------------------- ----------------------------------------------------------------------- --------- ---------------- 
  Core                    Actions (action)                                                        Enabled   8.5.1           
  Custom                  Add Error Pages (add_error_pages)                                       Enabled                   
  Field types             Address (address)                                                       Enabled   8.x-1.3         
  Administration          Admin Toolbar (admin_toolbar)                                           Enabled   8.x-1.23        
  Administration          Admin Toolbar Extra Tools (admin_toolbar_tools)                         Enabled   8.x-1.23        
  Core                    Aggregator (aggregator)                                                 Enabled   8.5.1           
  Core                    Automated Cron (automated_cron)                                         Enabled   8.5.1           
  Core                    Ban (ban)                                                               Enabled   8.5.1           
  Core                    BigPipe (big_pipe)                                                      Enabled   8.5.1           
  Core                    Block (block)                                                           Enabled   8.5.1           
  Core                    Custom Block (block_content)                                            Enabled   8.5.1           
  Layout                  Bootstrap Layouts (bootstrap_layouts)                                   Enabled   8.x-5.1         
  Core                    Breakpoint (breakpoint)                                                 Enabled   8.5.1           
  Custom                  Cart Empty Page Template Edit (cart_empty_page_template_edit)           Enabled                   
  Core                    CKEditor (ckeditor)                                                     Enabled   8.5.1           
  Clientside Validation   Clientside Validation (clientside_validation)                           Enabled                   
  Clientside Validation   Clientside Validation jQuery (clientside_validation_jquery)             Enabled                   
  Core                    Color (color)                                                           Enabled   8.5.1           
  Core                    Comment (comment)                                                       Enabled   8.5.1           
  Commerce                Commerce (commerce)                                                     Enabled                   
  Commerce (contrib)      Commerce Agree to Terms (commerce_agree_terms)                          Enabled   8.x-1.x-dev     
  Commerce                Commerce Cart (commerce_cart)                                           Enabled                   
  Commerce                Commerce Cart Blocks (commerce_cart_blocks)                             Enabled   8.x-1.x         
  Commerce                Commerce Checkout (commerce_checkout)                                   Enabled                   
  Custom                  Commerce Email Change (commerce_email_change)                           Enabled   1               
  Commerce                Commerce Log (commerce_log)                                             Enabled                   
  Commerce                Commerce Order (commerce_order)                                         Enabled                   
  Costum (contrib)        Commerce other services (commerce_other_services)                       Enabled                   
  Commerce                Commerce Payment (commerce_payment)                                     Enabled                   
  Commerce (contrib)      Commerce PayPal (commerce_paypal)                                       Enabled   8.x-1.0-beta1   
  Commerce                Commerce Price (commerce_price)                                         Enabled                   
  Commerce                Commerce Product (commerce_product)                                     Enabled                   
  Commerce                Commerce Promotion (commerce_promotion)                                 Enabled                   
  Commerce                Commerce Store (commerce_store)                                         Enabled                   
  Commerce                Commerce Tax (commerce_tax)                                             Enabled                   
  Core                    Configuration Manager (config)                                          Enabled   8.5.1           
  Multilingual            Configuration Translation (config_translation)                          Enabled   8.5.1           
  Core                    Contact (contact)                                                       Enabled   8.5.1           
  Other                   Contact storage (contact_storage)                                       Enabled   8.x-1.0-beta9   
  Custom                  Contact Storage Export (contact_storage_export)                         Enabled   8.x-1.11        
  Custom                  Contact Us Email Change (contact_us_email_change)                       Enabled   1               
  Multilingual            Content Translation (content_translation)                               Enabled   8.5.1           
  Core                    Contextual Links (contextual)                                           Enabled   8.5.1           
  Community               Contribute (contribute)                                                 Enabled   8.x-1.0-beta7   
  Custom                  Copyright (copyright)                                                   Enabled   1               
  Web services            Serialization (CSV) (csv_serialization)                                 Enabled   8.x-1.3         
  Chaos tool suite        Chaos tools (ctools)                                                    Enabled   8.x-3.0         
  Field types             Datetime (datetime)                                                     Enabled   8.5.1           
  Core                    Database Logging (dblog)                                                Enabled   8.5.1           
  Development             Devel (devel)                                                           Enabled   8.x-1.2         
  Display Suite           Display Suite (ds)                                                      Enabled   8.x-3.1         
  Display Suite           Display Suite Switch View Mode (ds_switch_view_mode)                    Enabled   8.x-3.1         
  Field types             Dynamic Entity Reference (dynamic_entity_reference)                     Enabled   8.x-1.5         
  Core                    Internal Dynamic Page Cache (dynamic_page_cache)                        Enabled   8.5.1           
  Core                    Text Editor (editor)                                                    Enabled   8.5.1           
  Other                   Embed (embed)                                                           Enabled   8.x-1.0         
  Other                   Entity (entity)                                                         Enabled   8.x-1.0-beta1   
  Filters                 Entity Embed (entity_embed)                                             Enabled                   
  Other                   Entity Legal (entity_legal)                                             Enabled   8.x-2.0-beta1   
  Field types             Entity Reference Revisions (entity_reference_revisions)                 Enabled   8.x-1.4         
  Core                    Field (field)                                                           Enabled   8.5.1           
  Core                    Field UI (field_ui)                                                     Enabled   8.5.1           
  Field types             File (file)                                                             Enabled   8.5.1           
  Core                    Filter (filter)                                                         Enabled   8.5.1           
  Statistics              Google Analytics (google_analytics)                                     Enabled   8.x-2.2         
  Statistics              Google Tag Manager (google_tag)                                         Enabled   8.x-1.0         
  Core                    Help (help)                                                             Enabled   8.5.1           
  Core                    History (history)                                                       Enabled   8.5.1           
  Spam control            Honeypot (honeypot)                                                     Enabled   8.x-1.27        
  Other                   HTTP Response Headers (http_response_headers)                           Enabled   8.x-2.0-alpha1  
  Field types             Image (image)                                                           Enabled   8.5.1           
  Media                   Imce File Manager (imce)                                                Enabled   8.x-1.6         
  Fields                  Inline Entity Form (inline_entity_form)                                 Enabled   8.x-1.0-beta1   
  Security                Key (key)                                                               Enabled   8.x-1.7         
  Development             Devel Kint (kint)                                                       Enabled   8.x-1.2         
  Multilingual            Language (language)                                                     Enabled   8.5.1           
  Core                    Layout Discovery (layout_discovery)                                     Enabled   8.5.1           
  Field types             Link (link)                                                             Enabled   8.5.1           
  Custom                  Linkit (linkit)                                                         Enabled   8.x-5.0-beta6   
  Multilingual            Interface Translation (locale)                                          Enabled   8.5.1           
  Other                   Login with email or username (login_emailusername)                      Enabled                   
  Mail                    Mail System (mailsystem)                                                Enabled   8.x-4.1         
  Media                   Media entity (media_entity)                                             Enabled   8.x-1.7         
  Media                   Media entity image (media_entity_image)                                 Enabled   8.x-1.2         
  Core                    Custom Menu Links (menu_link_content)                                   Enabled   8.5.1           
  Core                    Menu UI (menu_ui)                                                       Enabled   8.5.1           
  SEO                     Metatag (metatag)                                                       Enabled   8.x-1.4         
  SEO                     Metatag: Facebook (metatag_facebook)                                    Enabled   8.x-1.4         
  SEO                     Metatag: favicons (metatag_favicons)                                    Enabled   8.x-1.4         
  SEO                     Metatag: Google Plus (metatag_google_plus)                              Enabled   8.x-1.4         
  SEO                     Metatag: Mobile & UI Adjustments (metatag_mobile)                       Enabled   8.x-1.4         
  SEO                     Metatag: Open Graph (metatag_open_graph)                                Enabled   8.x-1.4         
  SEO                     Metatag: Open Graph Products (metatag_open_graph_products)              Enabled   8.x-1.4         
  SEO                     Metatag: Twitter Cards (metatag_twitter_cards)                          Enabled   8.x-1.4         
  SEO                     Metatag: Views (metatag_views)                                          Enabled   8.x-1.4         
  Field types             Mobile Number (mobile_number)                                           Enabled                   
  Custom                  Moderator Dashboard (moderator_dashboard)                               Enabled                   
  Core                    Node (node)                                                             Enabled   8.5.1           
  Field types             Options (options)                                                       Enabled   8.5.1           
  Core                    Internal Page Cache (page_cache)                                        Enabled   8.5.1           
  Layout                  Page Manager (page_manager)                                             Enabled   8.x-4.0-beta2   
  Layout                  Page Manager UI (page_manager_ui)                                       Enabled   8.x-4.0-beta2   
  Panels                  Panels (panels)                                                         Enabled   8.x-4.2         
  Core                    Path (path)                                                             Enabled   8.5.1           
  Input filters           Pathologic (pathologic)                                                 Enabled                   
  Other                   Paypal Currency Exchange (paypal_currency_exchange)                     Enabled                   
  Other                   Persistent Login (persistent_login)                                     Enabled   8.x-1.0-alpha4  
  Multilingual            Translation template extractor (potx)                                   Enabled   8.x-1.x-dev     
  Administration          Password Reset Landing Page (PRLP) (prlp)                               Enabled   8.x-1.3         
  Other                   Profile (profile)                                                       Enabled   8.x-1.0-rc1     
  Core                    RDF (rdf)                                                               Enabled   8.5.1           
  Registration            Registration Role (registration_role)                                   Enabled   8.x-1.0-beta1   
  Custom                  Remove Generator (remove_generator)                                     Enabled                   
  Custom                  Remove Localtask Persistent Login (remove_localtask_persistent_login)   Enabled   1               
  Core                    Responsive Image (responsive_image)                                     Enabled   8.5.1           
  Core                    Search (search)                                                         Enabled   8.5.1           
  Security                Security Review (security_review)                                       Enabled                   
  Custom                  Send SMS Mail (send_sms_mail)                                           Enabled                   
  Web services            Serialization (serialization)                                           Enabled   8.5.1           
  Core                    Shortcut (shortcut)                                                     Enabled   8.5.1           
  SMS Framework           SMS Framework (sms)                                                     Enabled   8.x-1.1         
  SMS Framework           SMS Blast (sms_blast)                                                   Enabled   8.x-1.1         
  SMS Framework           SMS Devel (sms_devel)                                                   Enabled   8.x-1.1         
  SMS Framework           Mobilyws for SMS Framework (sms_mobilyws)                               Enabled   8.x-1.1         
  SMS Framework           Send to phone (sms_sendtophone)                                         Enabled   8.x-1.1         
  SMS Framework           SMS User (sms_user)                                                     Enabled   8.x-1.1         
  Other                   Social Media Links Block (social_media_links)                           Enabled   8.x-2.6         
  Other                   State Machine (state_machine)                                           Enabled   8.x-1.0-beta3   
  Custom                  Strip Preview Button (strip_preview_button)                             Enabled                   
  Mail                    Swift Mailer (swiftmailer)                                              Enabled   8.x-1.0-beta2   
  Core                    System (system)                                                         Enabled   8.5.1           
  Core                    Taxonomy (taxonomy)                                                     Enabled   8.5.1           
  Field types             Telephone (telephone)                                                   Enabled   8.5.1           
  Custom                  Termsofuse User Registeration (termsofuse_user_registeration)           Enabled   1               
  Field types             Text (text)                                                             Enabled   8.5.1           
  Other                   Token (token)                                                           Enabled                   
  Core                    Toolbar (toolbar)                                                       Enabled   8.5.1           
  Core                    Tour (tour)                                                             Enabled   8.5.1           
  Other                   Typed Data (typed_data)                                                 Enabled                   
  Core                    Update Manager (update)                                                 Enabled   8.5.1           
  Core                    User (user)                                                             Enabled   8.5.1           
  Custom                  User Email Change (user_email_change)                                   Enabled   1               
  Video Embed Field       Video Embed Field (video_embed_field)                                   Enabled   8.x-1.5         
  Video Embed Field       Video Embed Media (video_embed_media)                                   Enabled   8.x-1.5         
  Video Embed Field       Video Embed WYSIWYG (video_embed_wysiwyg)                               Enabled   8.x-1.5         
  Core                    Views (views)                                                           Enabled   8.5.1           
  Views                   Views Bootstrap (views_bootstrap)                                       Enabled   8.x-3.0         
  Views                   Views Bulk Operations (views_bulk_operations)                           Enabled   8.x-2.0         
  Views                   Views Link Area (views_linkarea)                                        Enabled   8.x-1.0-beta1   
  Core                    Views UI (views_ui)                                                     Enabled   8.5.1           
  Webform                 Webform (webform)                                                       Enabled   8.x-5.0-rc3     
  custom                  Webform Add Local Task (webform_add_local_task)                         Enabled   1               
  Webform                 Webform Bootstrap (webform_bootstrap)                                   Enabled   8.x-5.0-rc3     
  Custom                  Webform Dependents Element (webform_dependents_element)                 Enabled                   
  Webform                 Webform Node (webform_node)                                             Enabled   8.x-5.0-rc3     
  Webform                 Webform Scheduled Email Handler (webform_scheduled_email)               Enabled   8.x-5.0-rc3     
  Webform                 Webform Templates (webform_templates)                                   Enabled   8.x-5.0-rc3     
  Webform                 Webform UI (webform_ui)                                                 Enabled   8.x-5.0-rc3     
  Webform                 Webform views (webform_views)                                           Enabled   8.x-5.0-alpha4  
  Field types             Weight (weight)                                                         Enabled   8.x-3.1-alpha1  
 ----------------------- ----------------------------------------------------------------------- --------- ----------------  

Integrate Symfony Console component to natively support command line operations

$
0
0

Problem/Motivation

We should minimize the barriers between a Drupal user and being able to use the console to manage a Drupal site. Adding a native command-line integration will allow more users from more backgrounds to be able to issue CLI commands more easily.

The Drupal community seems to have normalized on Symfony for many framework needs, so we might adopt Symfony Console. Here's an easy introduction to Symfony's Console component: http://symfony.com/doc/current/components/console/introduction.html The proof-of-concept code present in this issue is written using Symfony Console.

Also available to us is the Robo CLI framework, which is highly extensible and uses expressive command discovery: https://robo.li/

Drush is very useful for complex tasks such as drush make, and remote usage with site aliases, as well as working with Drupal versions other than 8. These type of tasks would be outside the scope of the console.

However, the addition of console commands to core, with stringent code review and testing requirements, would be a framework useable by Drush, potentially allowing Drush to slim down in the Drupal 8 use case.

Proposed resolution

Some Specs

Supports adding a command-line interface for some Drupal features.

Extensions can provide their own commands for the CLI.

This CLI integration should be viewed as a separate application which ships with Drupal. This might include going so far as to turn it into a subtree split similar to Drupal components.

Some commands will need to run without an installed Drupal, or even without a booted kernel. Different boot levels in functional vs. kernel vs. unit tests is a useful metaphor for what is needed.

Command line arguments are considered API. More specifically: Tools built to exec() these commands should continue to work, with BC. https://www.drupal.org/core/d8-bc-policy

A functional testing framework will be added so that commands can be maintained.

The executable will be marked as core/composer.json:bin, so that Composer will be able to alias the executable in a spot convenient for the user.

PoC Implementation Notes

Drupal 8 currently already requires symfony/console, so that is already available to us. #2493807: Add symfony/console component to core

We add two different types of console commands: Those which require a booted Drupal, and those which don't.

We use a separate service discovery container as a place to resolve dependencies and commands. This is independent of the Drupal container because it's not a Drupal, it's a console application that happens to use some Drupal as needed.

We use symfony/finder to locate extensions and find service definition files in the form extension_name.console.service.yml. These define services which are usually also commands, which can be used from the CLI. You might ask, "Why not use ExtensionDiscovery?" And the answer is that ExtensionDiscovery requires some degree of booted kernel before it can operate. Our design decision here should be to not require a booted Drupal, so we use some other means.

We execute against the Drupal codebase, booting as needed in order to accomplish the command.

We introduce some testing infrastructure, so that these things are maintainable. Comment #96 illustrates that we need a KTB base class for testing against commands.

As per comment #99 we should at least attempt to integrate existing one-off commands which have happened since this issue was originally posted. See https://github.com/drupal/drupal/tree/8.5.0-rc1/core/lib/Drupal/Core/Com...

Remaining tasks

Figure out the name. drupal/console project is already using the name 'drupal' as its bin file. Arm wrestle over it?

User interface changes

Users will be able to type things like core/console module:install my_module. That seems desirable, doesn't it?

API changes

Properly deprecate drupal_get_profile()


Get process plugin sets multiple for empty array

$
0
0

I have been scratching my head over this issue. The source sometimes has a blank offers, sometimes it is an array with data and sometimes it is an empty array - like this one:
https://api.hel.fi/linkedevents/v1/event/matko:16134/

With the latter example I was getting a bunch of Array index missing, extraction failed exceptions from the extract plugin, despite the skip_on_empty plugin running before, as you can see from my yml file:

  field_offers_is_free:
    -
      plugin: skip_on_empty
      method: process
      source: offers
    -
      plugin: extract
      index:
        - 0
        - is_free
  field_offers_info_url:
    -
      plugin: skip_on_empty
      method: process
      source: offers
    -
      plugin: extract
      default: false
      index:
        - 0
        - info_url
        - fi

I managed - in the end - to track down the reason for why our skip_on_empty plugin was never called: When Get sets $multiple to true, processRow in MigrateExecutable runs a foreach on the value - causing the whole skip_on_empty plugin to be skipped.

With this quick fix in modules/migrate/src/Plugin/migrate/process/Get.php's transform function things work fine for me:

    if (is_string($source)) {
      $a = is_array($return[0]);
      $b = !empty($return[0]);
      $this->multiple = $a && $b;
      return $return[0];
    }

Did I encounter a bug in Migrate or should I change my migration configuration?

wrapper class for PHP's DatePeriod

$
0
0

Problem/Motivation

Date objects in Drupal are of type DrupalDateTime, which inherits from DateTimePlus, which is a wrapper around PHP's native DateTime class.
PHP also has a DatePeriod class. I think it would be useful to also wrap this class creating a DatePeriodPlus and a DrupalDatePeriod. This way the date range field can return a DrupalDatePeriod class as value, like the date field returns an DateTimePlus object. Since all the logic to create DrupalDateTime objects is already in core this class can take advantage of that and also create a period of any of the formats provided by this class, since a period contains a start, end date and an interval.

Proposed resolution

I propose 2 new classes DrupalDatePeriod and DatePeriodPlus. DatePeriodPlus would have a constructor that take 2 dates in any format supported by DateTimePlus, an interval (string or class) default to one day (P1D), the timezone and settings.


/**
   * Constructs a date period object set to a requested date and timezone.
   *
   * @param mixed $date
   *   A /DateTime object, DateTimePlus object, date array, timestamp or NULL.
   *   NULL will default to today.
   * @param mixed $date2
   *   A /DateTime object, DateTimePlus object, date array, timestamp or NULL.
   *   NULL will default to today.
   * @param mixed $interval
   *   (optional) A \DateInterval object, interval string or NULL. NULL uses the
   *   default interval of one day (P1D).
   * @param mixed $timezone
   *   (optional) \DateTimeZone object, time zone string or NULL. NULL uses the
   *   default system time zone. Defaults to NULL. Note that the $timezone
   *   parameter and the current timezone are ignored when the $date
   *   and $date2 parameter either is a \DateTime or \DateTimePlus object.
   * @param array $settings
   *   (optional) Keyed array of settings. Defaults to empty array.
   *   - langcode: (optional) String two letter language code used to control
   *     the result of the format(). Defaults to NULL.
   *   - debug: (optional) Boolean choice to leave debug values in the
   *     date object for debugging purposes. Defaults to FALSE.
   */
  public function __construct($date = NULL, $date2 = NULL, $interval = NULL, $timezone = NULL, array $settings = []) {
    $prepared_timezone = $this->prepareTimezone($timezone);

    // Massage the input values if necessary.
    $prepared_date = $this->prepareDateTime($date, $prepared_timezone, $settings);
    $prepared_date2 = $this->prepareDateTime($date2, $prepared_timezone, $settings);

    $prepared_interval = $this->prepareInterval($interval);

    try {
      $this->errors = [];

      if (!$prepared_date) {
        $this->errors = 'No valid date provided';
      }

      if (!$prepared_date2) {
        $this->errors = 'No valid date2 provided';
      }

      if (empty($this->errors)) {
        $prepared_date_plus = DateTimePlus::createFromDateTime($prepared_date);
        $prepared_date2_plus = DateTimePlus::createFromDateTime($prepared_date2);

        array_merge($this->errors, $prepared_date_plus->getErrors());
        array_merge($this->errors, $prepared_date2_plus->getErrors());

        if (empty($this->errors)) {
          $this->datePeriodObject = new \DatePeriod($prepared_date, $prepared_interval, $prepared_date2);
        }
      }
    }
    catch (\Exception $e) {
      $this->errors[] = $e->getMessage();
    }
  }
/**
   * Prepare the dates.
   *
   * @param mixed $date
   *   A /DateTime object, DateTimePlus object, date array, timestamp or NULL.
   *   NULL will default to today.
   * @param mixed $timezone
   *   A /DateTime object, DateTimePlus object, date array, timestamp or NULL.
   *   NULL will default to today.
   * @param array $settings
   *   (optional) Keyed array of settings. Defaults to empty array.
   *   - langcode: (optional) String two letter language code used to control
   *     the result of the format(). Defaults to NULL.
   *   - debug: (optional) Boolean choice to leave debug values in the
   *     date object for debugging purposes. Defaults to FALSE.
   *
   * @return \DateTime
   *   A php date time object.
   */
  protected function prepareDateTime($date, $timezone, array $settings = []) {
    // If the input is a DateTime object, use it.
    if ($date instanceof \DateTime) {
      return $date;
    }

    // If the input is a DateTimePlus object, get the php datetime object.
    if ($date instanceof DateTimePlus) {
      return $date->getPhpDateTime();
    }

    if (is_array($date)) {
      $date_time_plus = DateTimePlus::createFromArray($date, $timezone, $settings);
      return $date_time_plus->getPhpDateTime();
    }

    if (is_numeric($date)) {
      $date_time_plus = DateTimePlus::createFromTimestamp($date, $timezone, $settings);
      return $date_time_plus->getPhpDateTime();
    }

    $date_time_plus = new DateTimePlus($date, $timezone, $settings);
    return $date_time_plus->getPhpDateTime();
  }

Remaining tasks

  • Agree this is a good idea
  • Make sure https://www.drupal.org/node/2906229 (getPhpDateTime() method) is provided by core
  • Finetune\Rework\Review provided "proof of concept" patch to a fully working version
  • Extend the DrupalDatePeriod with a format function
  • Provide tests
  • Later on the date range field can implement return this class as a computed value

User interface changes

None

API changes

New classes DrupalDatePeriod and DatePeriodPlus

Data model changes

None

Fix multilingual install on Drupal dev version for CLI utilities

$
0
0

Problem/Motivation

If you install Drupal using drush or using #2911319: Provide a single command to install & run Drupal and probably using console too in a language other than English the install_import_translations() step will fail to import translations.

Technical details

On an interactive install the translation project information is changed by _install_prepare_import(). This does not work on CLI installs because locale_translation_get_projects() is statically cached. In locale_translation_build_projects() 8.6.0-dev becomes 8.6.x but install_check_translations() has downloaded a file with the name 8.6.0-dev from the server. Interactive installs use this file because of the way _install_prepare_import() manipulates the project information.

Proposed resolution

Change install_check_translations() to use the same filename as downloading a translation during regular runtime would use. And clear the static cache in _install_prepare_import().

This will also fix:
#2796757: Failing test with stable version string
#2816457: Test fail with stable version
and maybe #2828143: Stop tests like LocaleConfigTranslationImportTest from failing if l.d.o becomes unavailable

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Fix remainig PHP 7.2 compatibility issues

$
0
0

Problem/Motivation

using static analysis I see few notices

core$ docker run -it --rm -v $(pwd):/project -w /project jakzal/phpqa:alpine phpcf .
Max file size set to: 1.000 MiB
Scanning . ...
Skipping file ./modules/migrate_drupal/tests/fixtures/drupal6.php due to file size limit.
Skipping file ./modules/migrate_drupal/tests/fixtures/drupal7.php due to file size limit.
sh: tput: not found

Warning: A non-numeric value encountered in /root/.composer/vendor/wapmorgan/php-code-fixer/bin/phpcf on line 74
 PHP |             Type |                      File:Line | Issue
 5.3 | function         | ...omponent/Utility/Xss.php:84 | Function split() is deprecated. 
 5.3 | function         | ...mponent/Utility/Xss.php:141 | Function split() is deprecated. 
 5.3 | function         | ...Archiver/ArchiveTar.php:306 | Function dl() is deprecated. 
 5.3 | function         | ...Archiver/ArchiveTar.php:306 | Function dl() is deprecated. 
 7.0 | method_name      | ...l/Core/Database/Log.php:112 | Method name log:Log (@php4_constructors) is deprecated. 
 7.0 | method_name      | ...base/Query/Condition.php:98 | Method name condition:Condition (@php4_constructors) is deprecated. 
 7.2 | function_usage   | ...nmetDependenciesTest.php:66 | Function usage assert (@assert_on_string) is deprecated. 
 7.2 | function_usage   | ...nmetDependenciesTest.php:72 | Function usage assert (@assert_on_string) is deprecated. 
 7.2 | function_usage   | ...letest/src/TestBase.php:818 | Function usage assert (@assert_on_string) is deprecated. 
 7.2 | function_usage   | ...letest/src/TestBase.php:821 | Function usage assert (@assert_on_string) is deprecated. 

Replace Suggestions:
1. Don't use function split. Instead use preg_split

Proposed resolution

Clean-up remains

Remaining tasks

patch & commit

Make comment threading per entity translation

Viewing all 293396 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>