Invalid argument supplied for foreach() in Drupal\views\Plugin\views\display\DisplayPluginBase->destroy().
I am getting warning when edit and delete address in addressbook. Sometime it gives error on address list page also. I have checked that the value passes to foreach() inside destroy() in view module is sometime string and then it gives warning.
Invalid argument supplied for foreach() in Drupal\views\Plugin\views\display\DisplayPluginBase->destroy()
_skipProtectedUserFieldConstraint is being forcefully reset
Problem/Motivation
This is a bit of an odd issue to report, but I needed documented it somewhere as well as a fix to be used in the meantime.
After #2847708: RPC endpoint to reset user password was accepted, I followed up with #2904451: Allow to change password through RPC endpoints through the reset password workflow which is still an issue. I also created https://www.drupal.org/sandbox/hanoii/2904436 (which I am re-considering releasing it as a full module), but I just found it this has not been working since 8.7.0 was released.
After some debugging time I tracked the issue down to #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing which added logic to the entity system that broke what I was doing on the module.
My sandbox module sets _skipProtectedUserFieldConstraint on hook_entity_load()
and resets it on hook_entity_update()
emulating what Drupal's core does. This module allows me to change the password through a regular PATCH post to the user resource rest endpoint, which is why I added #2904451: Allow to change password through RPC endpoints through the reset password workflow.
The fix added by #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing was forcefully resetting_skipProtectedUserFieldConstraint
preventing my module to work. It's noted on the comments that this is a temporary fix and that it will be removed on #2934192: FieldItemBase::getValue() returns partial or full values depending on state, however the patch there does not have any indication for that at the moment.
I know this is not a bug in Drupal core, and that my module is using some Drupal's internals, but I needed a way to set the user password and I wanted to use as much of Drupal's as possible.
I wonder if hook_entity_load()
shouldn't be run on getCanonical(), although probably not.
Proposed resolution
While I am opening this issue to flag something that happened to me I also needed a way to make this work.
I also found https://www.drupal.org/project/rest_password which wasn't around when I created my sandbox but it works differently and for now I rather keep my logic as it is on this project.
Being that what was added was flagged as temporary, I am proposing a further temporal addition so that _skipProtectedUserFieldConstraint is only set and reset if it wasn't set already.
Remaining tasks
Discuss
Release notes snippet
Probably not worth even mentioning?
Allow the user to limit the number of times resetting their password in a day
The user should only be able to change their password once/twice in a day. If user exceeds the limit, it should display a message while trying to change the password.
We can't able to find any module avail this feature. Is there any other modules available to perform this feature in Drupal 8. If not, Could you please suggest me a way to do this?
We have tested with password policy module, but we don't the feature in it. Could you please help us to achieve this?
Add translation context on password strength strings
Hi, currently the password strength module uses 'strong' as string to indicate the best password strength. That's good, but in this specific context the word strong in italian language has a different translation compared to the html "strong" element. So we need to differentiate it using a translation context.
So now I've patched user.module with a custom context.
N.B: In Italian language, the word "strong", when used to indicate the bold style, is translated with "grassetto". Instead, when the word "strong" is used to specify the strength of something, is translated with "forte".
Update to Drupal 9.3.0 adding --2 suffix to (views-) block-ID's
Problem/Motivation
Updates from Drupal 9.2.10 to Drupal 9.3.0 are adding an --2
suffix to block-ID's (maybe only views-block-ID's?). For example block-views-block-newsslider-block-1
changes to block-views-block-newsslider-block-1--2
, causing all JS an CSS selectors applied to the specific IDs not to work anymore and breaking the design of the website. This happens at least to allblock-views-block
-Elements of the affected websites.
This happend with different websites and different base themes (Classy, Bootstrap 3).
Setup:
Steps to reproduce
Update from Drupal 9.2.10 to Drupal 9.3.0
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Make subquery table alias more informative and easy to investigate
Using search_api_db, facets and views on a Multi-site (using ACSF) and New relic for monitoring.
There are too many requests on listing pages which use search_api_db and facets. While trying to check why the queries to alias "subquery" is slow on site 1 and faster on site 2, it becomes very confusing as there are multiple queries which use "subquery" as table alias but they are actually different queries with different tables and joins.
Proposed solution: Make this default alias more informative.
Support for query splitting to Replica in core
I understand how to configure the $database['default']['replica'][] settings so that I can point to 1..N replica servers.
I do not understand how to get anything but my custom-written queries to leverage the Replica servers.
This seems to me like a core feature to supporting multiple databases in core, but I see no clear path to handling this logic, nor do I see a clear place to override this
I've even tried
if (!isset($options['target']) && stripos($query, 'SELECT') === 0) { $options['target'] = 'replica'; } return parent::query($query, $args, $options);
in
Drupal\Core\Database\Driver\mysql\Connection function query(
but whatever other processes are involved with loading any page in Drupal appear to mark the replica as invalid, so I never actually have any queries that execute against the replica in this scenario.
This seems to me like a core scaling issue for Drupal, so I'm not clear on if I'm just misunderstanding how this is supposed to work, or if the only recommendation is to use an external process such as proxySQL or other mechanism to split read/write queries across master/slave (primary/replica)
Can't translate config when source language does not exists
We have multisite project, date format configs exported in codebase with "en" langcode.
Some of sites does not have "en" language and when they trying to translate date format to another language, the error appeared:
"TypeError: Argument 1 passed to Drupal\config_translation\FormElement\ListElement::getTranslationBuild() must implement interface Drupal\Core\Language\LanguageInterface, null given"
It could be solved by setting "und" language in config, but it seems not possible and always reverted to "en" or current site default language by config module: https://www.drupal.org/node/2451885
Postgres driver issue with nested savepoints mimic_implicit_commit duplicated
We're having an issue with Workbench Moderation and Group installed and have traced it back to an issue with the Postgres db driver. The Postgres driver automatically creates savepoints named "mimic_implicit_commit" for most queries running inside of an ongoing transaction.
The problem occurs when a DB query is run that triggers another DB query in the first's preExecute() phase (typically a hook such as hook_node_grants). This creates a situation where a new savepoint also called "mimic_implicit_commit" is added before the original "mimic_implicit_commit" savepoint is released. pushTransaction() doesn't allow for duplicate savepoint names.
The easiest way to re-create is to install/enable Workbench Moderation and then have any module that implements hook_node_grants() with a DB query using the ->execute() method enabled as well (such as Group/Group Node). When you add try to add content as a user without "bypass node access", you'll get this error message when you try to save:
Drupal\Core\Entity\EntityStorageException: mimic_implicit_commit is already in use. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Here's some additional information about the problem. Basically all DB queries funnel into the pgsql\Select class's execute() method, which arbitrarily runs addSavepoint($savepoint_name = 'mimic_implicit_commit')
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...
# Drupal\Core\Database\Driver\pgsql\Select
public function execute() {
$this->connection->addSavepoint();
try {
$result = parent::execute();
}
catch (\Exception $e) {
$this->connection->rollbackSavepoint();
throw $e;
}
$this->connection->releaseSavepoint();
return $result;
}
pgsql\Select\execute() is called from many different places. Only one path via the pgsql/Connection query() method does it actually check for the duplicate 'mimic_implicit_commit' name:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...
# Drupal\Core\Database\Driver\pgsql\Connection
public function query($query, array $args = [], $options = []) {
$options += $this->defaultOptions();
// The PDO PostgreSQL driver has a bug which doesn't type cast booleans
// correctly when parameters are bound using associative arrays.
// @see http://bugs.php.net/bug.php?id=48383
foreach ($args as &$value) {
if (is_bool($value)) {
$value = (int) $value;
}
}
// We need to wrap queries with a savepoint if:
// - Currently in a transaction.
// - A 'mimic_implicit_commit' does not exist already.
// - The query is not a savepoint query.
$wrap_with_savepoint = $this->inTransaction() &&
!isset($this->transactionLayers['mimic_implicit_commit']) &&
!(is_string($query) && (
stripos($query, 'ROLLBACK TO SAVEPOINT ') === 0 ||
stripos($query, 'RELEASE SAVEPOINT ') === 0 ||
stripos($query, 'SAVEPOINT ') === 0
)
);
if ($wrap_with_savepoint) {
// Create a savepoint so we can rollback a failed query. This is so we can
// mimic MySQL and SQLite transactions which don't fail if a single query
// fails. This is important for tables that are created on demand. For
// example, \Drupal\Core\Cache\DatabaseBackend.
$this->addSavepoint();
try {
$return = parent::query($query, $args, $options);
$this->releaseSavepoint();
}
catch (\Exception $e) {
$this->rollbackSavepoint();
throw $e;
}
}
else {
$return = parent::query($query, $args, $options);
}
return $return;
}
However, both Groups and Workbench moderation call the pgsql/Select execute() method directly, bypassing the duplicate check for mimic_implicit_commit in pgsql/Connection query().
Groups:
#0 Drupal\Core\Database\Driver\pgsql\Select->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/DatabaseStorage.php:273]
#1 Drupal\Core\Config\DatabaseStorage->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/CachedStorage.php:207]
#2 Drupal\Core\Config\CachedStorage->findByPrefix() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/CachedStorage.php:183]
#3 Drupal\Core\Config\CachedStorage->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/ConfigFactory.php:328]
#4 Drupal\Core\Config\ConfigFactory->listAll() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/Entity/Query/Query.php:172]
#5 Drupal\Core\Config\Entity\Query\Query->loadRecords() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Config/Entity/Query/Query.php:82]
#6 Drupal\Core\Config\Entity\Query\Query->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php:503]
#7 Drupal\Core\Entity\EntityStorageBase->loadByProperties() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/group/src/GroupMembershipLoader.php:146]
#8 Drupal\group\GroupMembershipLoader->loadByUser() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/group/modules/gnode/gnode.module:169]
Workbench:
#0 Drupal\Core\Database\Driver\pgsql\Select->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php:250]
#1 Drupal\Core\Entity\Query\Sql\Query->result() called at [/opt/tbs/wcms/open_gov/web/current/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php:77]
#2 Drupal\Core\Entity\Query\Sql\Query->execute() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/workbench_moderation/src/ModerationInformation.php:166]
#3 Drupal\workbench_moderation\ModerationInformation->getLatestRevisionId() called at [/opt/tbs/wcms/open_gov/web/current/html/modules/contrib/workbench_moderation/src/ModerationInformation.php:151]
The pgsql driver may need to be patched to handle the duplicate savepoint condition when Query class's execute() function are accessed directly.
How to display text if the field is empty ?
How to display a text if the field is empty ?
I tried the following code but it does not work :
{% if content.field_description is not empty %}
{{ content.field_description }}
{% else %}
test
{% endif %}
Ajax error $form.ajaxSubmit() is not a function in the image editor
The image upload not working and throws error while submitting image. Screenshot of the error is attached. Please help. Thanks
Translatable tours
Hello,
is it planned to make the tour texts translatable as another entity?
Thank you for your reply
For views with paths that do not include %, programmatic links behave differently than UI links
Problem/Motivation
When a view has a contextual filter that is not in the path (the contextual filter value is supplied using the "provide default value" option), then links defined in code do not show up as expanded in menus on the actual view path (the links do show up on other pages, just not the view path itself).
This is different than the behavior of links to the view path that are created in Menu UI, which show up on the actual view path + other pages.
I expect the behavior to be consistent and code-defined links to also show up on the actual view path.
Steps to reproduce
In mymodule.links.menu.yml
I have defined a link:
MYMODULE.fruits-apple:
title: 'Apple'
route_name: view.fruit_list.page_apple
parent: MYMODULE.fruits
weight: 5
menu_name: fruits-navigation
The view page view.fruit_list.page_apple
has the path /fruits/apple
.
The view has a contextual filter on the User ID, which is brought in by a relationship to Author. The contextual figure is set to provide the "User ID from logged-in user" in "When the filter value is NOT in the URL."
When on a page other than /fruits/apple, the link appears in my menu and allows access to the view. When on the parent page (/fruits), it appears expanded under the parent link in the menu. But, on the actual view page (/fruits/apple), the link is not shown.
On the other hand, when I create a link in the menu UI to the path /fruits/apple and then go the page /fruits/apple, I see BOTH my menu UI link and my module-defined link. But if I disable or delete my menu UI link, then my module-defined link is not shown.
I checked the route with /devel/routes and found this:
Route name: view.fruit_list.page_apple
Path: /fruits/apple/{arg_0}
I tried adding route_parameters: { arg_0: '' } and route_parameters: { arg_0: 'NULL' } to trigger the "When the filter value is NOT in the URL" behavior, but that didn't work.
If I delete the contextual filter in the view, my code-defined menu link works correctly.
TitleResolver doesn't pick up _title / _title_callback changes in an Enhancer
I'll let someone else categorise if this is a bug or feature request but, with an Enhancer that sets a _title_callback
(or any other title related defaults) the TitleResolver
class does not pick them and so the pages do not have a title (or have the ones defined in the respective routing.yml
.
It seems to be a simple of case of changing the likes of:
if ($callback = $route->getDefault('_title_callback')) {
toif ($callback = $request->attributes->get('_title_callback')) {
From the git log / issue queue, the change from using attributes->get
to getDefault
was done between #2076085-29: Resolve the need for a 'title callback' using the route and #2076085-32: Resolve the need for a 'title callback' using the route but no explanation as to why...
What could be the reason file and image fields are not showing up in my contact form?
Problem/Motivation
I have added file and image upload fields to my contact form but they are not showing up on frontend. Every other field shows up perfectly fine.
Steps to reproduce
Create new contact form. Add file and/or image reference field (they are available as fields and I ve read online people that were able to add them). Upon looking at the form in the frontend , image and file fields are just not showing up. (not when logged in as admin, neither when not logged in) - all other fields in the contact form work perfectly fine.
Claro: Update the URL's which are still using http and they have shifted to https
Claro: Update the URL's which are still using http and they have shifted to https
Undefined offset: 1 in Drupal\Core\Entity\EntityDisplayRepository->getAllDisplayModesByEntityType()
Problem/Motivation
I'm getting the following notice:
Notice: Undefined offset: 1 in Drupal\Core\Entity\EntityDisplayRepository->getAllDisplayModesByEntityType() (line 115 of core/lib/Drupal/Core/Entity/EntityDisplayRepository.php).
Drupal\Core\Entity\EntityDisplayRepository->getAllDisplayModesByEntityType('view_mode') (Line: 142)
Drupal\Core\Entity\EntityDisplayRepository->getDisplayModesByEntityType('view_mode', 'block_content') (Line: 78)
Drupal\Core\Entity\EntityDisplayRepository->getViewModes('block_content') (Line: 165)
Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 201)
Drupal\Core\Menu\LocalTaskManager->getDefinitions() (Line: 226)
Drupal\Core\Menu\LocalTaskManager->getLocalTasksForRoute('entity.menu.collection') (Line: 310)
Drupal\Core\Menu\LocalTaskManager->getTasksBuild('entity.menu.collection', Object) (Line: 378)
Drupal\Core\Menu\LocalTaskManager->getLocalTasks('entity.menu.collection', 0) (Line: 95)
Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
This error seems to be proceeding from Drupal\Core\Entity\EntityDisplayRepository->getAllDisplayModesByEntityType(). Line 115
113 $this->displayModeInfo[$display_type] = [];
114 foreach ($this->entityTypeManager->getStorage($entity_type_id)->loadMultiple() as $display_mode) {
115 list($display_mode_entity_type, $display_mode_name) = explode('.', $display_mode->id(), 2);
116 $this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = $display_mode->toArray();
117 }
118 $this->moduleHandler->alter($key, $this->displayModeInfo[$display_type]);
119 $this->cacheSet("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, ['entity_types', 'entity_field_info']);
I attach an image.
Steps to reproduce
Every time I update the cache in my environment, I'm getting this notice in each page that I access.
Proposed resolution
Here I found a possible solution and at first sight it seems to work, I'm not getting the error anymore: https://www.daniweb.com/programming/web-development/threads/452877/how-t...
Creating custom 'Display Format' for my view
So sorry for a ticket, I've researched prior to this. I am looking for any support documentation to help me define a new custom 'Display Format' for Views in D8 Core.
There are several modules already out there that add new Views display formatters but I think I need my own custom one.
In all of my research there is a lot of talk about custom field formatters and custom filters but I don't think they are what I am looking for.
Any help finding documentation would be appreciated.
joe
Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real()
Problem/Motivation
PHP 8.1 introduces many deprecation notices that would not appear previously. In my experience, it seems that hitting one of these notices (when thrown by a contrib module) generally causes a critical error coming from Core -- Error: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() (line 63 of core/includes/errors.inc).
. In such cases, the deprecation message is included in the stack trace:
The website encountered an unexpected error. Please try again later.
Error: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() (line 63 of core/includes/errors.inc).
_drupal_error_handler_real(8192, 'Return type of Drupal\profile\Plugin\Field\ProfileEntityFieldItemList::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice', '/var/www/html/drupal/web/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php', 121) (Line: 346)
_drupal_error_handler(8192, 'Return type of Drupal\profile\Plugin\Field\ProfileEntityFieldItemList::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice', '/var/www/html/drupal/web/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php', 121) (Line: 571)
include('/var/www/html/drupal/web/core/includes/bootstrap.inc') (Line: 571)
Composer\Autoload\includeFile('/var/www/html/drupal/vendor/composer/../../web/core/lib/Drupal/Core/Utility/Error.php') (Line: 428)
Composer\Autoload\ClassLoader->loadClass('Drupal\Core\Utility\Error') (Line: 44)
Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber->on403(Object) (Line: 97)
Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber->onException(Object, 'kernel.exception', Object)
call_user_func(Array, Object, 'kernel.exception', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.exception') (Line: 219)
Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object, Object, 1) (Line: 91)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 49)
Asm89\Stack\Cors->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: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Fixing/patching the deprecation seems to get rid of the notice, as well as this error handler error itself. The error handler error is problematic because it turns what should be a simple notice into a critical failure. I think that what must be happening is that the deprecation is somehow short-circuiting the autoloader or something.
Steps to reproduce
Trying to figure out simple steps to reproduce on a clean install. Not sure of a good way yet.
Proposed resolution
Unsure.
Inject hook to dynamic deny internal page cache
Problem/Motivation
page_cache_response_policy event effect more scope, so introduce hook_internal_page_cache_policy_check() to deny internal page cache.