- Issue created by @shrikant.dhotre
- Status changed to Postponed: needs info
about 1 year ago 3:37pm 12 April 2023 - Status changed to Needs review
about 1 year ago 3:42pm 12 April 2023 - Status changed to Needs work
about 1 year ago 3:51pm 12 April 2023 - Status changed to Needs review
about 1 year ago 6:48pm 12 April 2023 - Status changed to Needs work
about 1 year ago 7:05pm 12 April 2023 - ๐บ๐ธUnited States cilefen
Thank you for the patches. Bugs in Drupal Core require steps to reproduce. Please do not remove that tag until providing the steps to reproduce.
- last update
about 1 year ago 29,202 pass - @shrikantdhotre opened merge request.
- last update
about 1 year ago 29,202 pass - ๐ฆ๐บAustralia dpi Perth, Australia
The MR/solution is trivial enough to not warrant credit.
We need steps to reproduce, so we may consider adding tests.
Aside: empty is typically to naive, we need to be using narrower type checking.
- last update
about 1 year ago 29,202 pass - Open on Drupal.org โEnvironment: PHP 8.1 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - @shrikantdhotre opened merge request.
- last update
about 1 year ago 29,202 pass - last update
about 1 year ago Custom Commands Failed - First commit to issue fork.
- last update
about 1 year ago 29,202 pass - last update
about 1 year ago 29,204 pass - Status changed to Postponed: needs info
about 1 year ago 6:00am 18 April 2023 - ๐ณ๐ฑNetherlands Lendude Amsterdam
Marking postpone until we have some steps to reproduce this on a clean Drupal install, usually this is just hiding a problem upstream.
The question to answer is why this would ever be NULL, is it NULL in a valid scenario or due to another problem.
- ๐ฎ๐ณIndia shrikant.dhotre
Thanks for highlighting, I will deep analyses whether NULL is valid scenario or not
- ๐ฎ๐ณIndia shrikant.dhotre
Yes, this is valid Scenario, when we are creating a field with machine name having suffix numeric view will not work,
e.g.field_1
field_2And when we are using views field as view this fields arguments are giving an error.
TypeError: Cannot assign null to property - ๐ณ๐ฟNew Zealand quietone New Zealand
@shrikant.dhotre, thanks. Can you add more detail? Does the error happen when creating the view or when viewing the page. There is an example of the detail needed in Document steps to reproduce an issue โ .
I did try to test, creating a view with a integer numeric field with a name 'field_2'. I did not get an error when creating the page or viewing it.
I have also restored the standard template to make this issue easier to work on.
- ๐ฎ๐ณIndia shrikant.dhotre
Hi @Quietone,
I created fields machine names with numeric, with implementation of workflow module.
created below fields and nested paragraphs with content type using content moderation state, paragraph and view field as view contributed
Modedration stage are defiend like : Draft, Pending, Approved, Archived.
field_name_1,
field_name_2 >> field_name_22 >> field_name_222,
field_name_3 >> field_name_333 >> field_name_444Now requirement is like, we have impleted drupal with headless arch.
Created a Json API with using content revision, so each field is comming with historical data with revision_id
field_name_1-revision_idFor Json API, created a views in rest export nested.
view output is giving an error with
TypeError: Cannot assign null to property - First commit to issue fork.
- last update
11 months ago 29,884 pass - @lysenko opened merge request.
- last update
11 months ago 29,885 pass - ๐บ๐ฆUkraine Lysenko Ukraine, Lutsk
In my opinion, this question arose because of a change in this place:
public string $operator;The value NULL for this variable is assigned here if the passed string does not match the regular expression
The simplest solution seems to be to allow the variable $operator to be NULL
- ๐ญ๐บHungary zserno
I ran into this error after upgrading a Drupal 9 site to 10.
I agree with #16: originally this site started out as an early Drupal 8 site. Somehow, one of the views had its pager's offset configuration unset. Setting the offset value to '0' fixed the issue for me.
I would suggest just to allow NULL for \Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator
@@ -108,7 +108,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend /** * The operator used for the query: or|and. */ - public string $operator; + public ?string $operator;
- ๐ซ๐ฎFinland joey-santiago
Agree with #26...
In my case, the error is thrown in a view that is embedded in a webform. The view arguments are passed by ajax and come from an element that is on the same page of the view. So in some conditions the view gets NULL being passed as an argument. In this case, somehow NULL gets to the operator. Implemented the suggestion suggested in #26 and it seems to work fine.
- last update
9 months ago Custom Commands Failed - last update
8 months ago 30,415 pass - ๐ง๐ฌBulgaria ovanes Sofia
Hello all,
Just to inform you, I've locally tested the patch from comment #28 and can verify that it is effective.
I encountered the following error:
TypeError: Cannot assign null to the property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\ArgumentPluginBase->unpackArgumentValue() (line 1310 of core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php).
The setup is as follows:
- Drupal version: 10.1.4
- PHP Version: 8.1.18Thank you.
- ๐ฉ๐ชGermany DiDebru
We are also facing this issue patch #29 solved it.
I know this needs steps to reproduce but this property can be null and needs to be treated like that. Either by this patch or by allowing it to be null.
- ๐บ๐ธUnited States jonraedeke
Patch #28 and #29 both fix my issue. I'm not sure which is the best approach.
In my case, default contextual filters that happen to be null because the field was not required were causing this fatal error.
- last update
8 months ago Patch Failed to Apply - last update
8 months ago 29,686 pass - Status changed to RTBC
6 months ago 3:07pm 23 December 2023 - ๐ฉ๐ชGermany kreatIL
After a thorough review of the available information and attempts to understand this issue, I have concerns regarding the feasibility of reproducing the error, particularly since it seems to predominantly affect sites that have been upgraded from Drupal 8 or Drupal 9.
From what I've gathered, this error does not readily manifest in fresh installations of Drupal 10, which suggests that it might be tied to specific configurations or legacy data from older versions. This makes it challenging to replicate the conditions necessary to observe the error in a controlled environment.
Patch #29 does not add any new functionality, but merely checks whether $break->operator is set. Which appears to have successfully resolved the issue for many who have applied it, indicating its effectiveness in addressing this specific error.
Given these circumstances, I would like to propose a consideration for the integration of Patch #29 into core.
- last update
6 months ago 25,911 pass, 1,827 fail - last update
6 months ago 25,922 pass, 1,809 fail - last update
6 months ago 25,917 pass, 1,817 fail - last update
6 months ago 25,927 pass, 1,821 fail - last update
6 months ago 25,946 pass, 1,803 fail - ๐ฌ๐งUnited Kingdom Rob230
I have this error in a view which is using search_api.
TypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\ArgumentPluginBase->unpackArgumentValue() (line 1310 of modules/views/src/Plugin/views/argument/ArgumentPluginBase.php).
Drupal\search_api\Plugin\views\argument\SearchApiStandard->fillValue() (Line: 160)
Drupal\search_api\Plugin\views\argument\SearchApiStandard->query() (Line: 1126)
Drupal\views\ViewExecutable->_buildArguments() (Line: 1282)
Drupal\views\ViewExecutable->build() (Line: 392)It's a very simple view which just does a fulltext search and shows the search excerpt. It broke when upgrading to Drupal 10. Whilst patch #29 would fix it, I agree with #38 that the fix only treats the symptom but not the root cause. So I investigated some more and in my case I found it was due to a contextual filter which had a default value of a fixed value of an empty string, but which had a validator for "Content" that looked for the ID of a node and handles multiples with "One or more IDs separated by , or +".
So people should check the contextual filters and make sure an impossible situation hasn't been created where a blank value is validated. One could argue that the validator shouldn't cause an exception on the site, however Drupal had been instructed to do something that didn't make sense, and simply ignoring it would mean the mistake is never found.
- last update
6 months ago Build Successful - last update
6 months ago 25,983 pass, 1,822 fail - last update
6 months ago 25,980 pass, 1,818 fail - last update
6 months ago 25,981 pass, 1,839 fail - ๐บ๐ธUnited States Peter Pulsifer
I had the same error as @ovanes, #30.
TypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\ArgumentPluginBase->unpackArgumentValue() (line 1303 of core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php).
This came from a view that takes a node id as a contextual argument, and it was being passed a random argument. When that argument included a non-numeric character, the error was triggered.
The cause of all this is the function
breakString($str)
in HandlerBase.php, which returns$operator
as a string ('or' or 'and') when$str
is alphanumeric and returns it as null when$str
contains a non-alphanumeric character. I don't see the null return behavior documented anywhere; is it important to retain it? If not, the fix would be to changebreakString()
so it always returned a string for $operator - either 'and', which seems to be the default, or simply a null string, which would at least not cause TyeError issues.I solved my problem by adding numeric validation to the contextual argument, but it seems like this should be cleaned up.
- ๐ฎ๐นItaly Giuseppe87
I confirm the description of #39:
I have on a site started with Drupal 8, upgraded to 9 and recently to 10 a similar situation.
On that site there are some views of nodes with a contextual filter "content:ID" whose validator is "content type" and accept one or multiple ids.
That view is sometimes render programmatically, with the following code:
$view = [ '#type' => 'view', '#name' => $view_id, '#display_id' => $view_display, '#arguments' => $nids, ]; $render = $this->renderer->render($view);
Where
$nids
sometimes may be an empty string - if no value is provided.
Until Drupal 9 this worked, but since Drupal 10 I had to put a check in case $nids is an empty string, because that would cause the error.I also agree that was poor code custom that made Drupal doing something that should not be possible, but hiding that error would hide the mistake without having a way to realize it.
- Status changed to Needs work
4 months ago 11:33am 26 February 2024 - ๐ฌ๐งUnited Kingdom catch
The patch here should be converted to an MR - and the last run on this issue had over a thousand test failures (probably a DrupalCI issue but we need a recent run on gitlab CI to commit it).
Additionally, this approach is just hiding the error without informing admins. I think we could log an error with the view name and display to tell the site admin something is wrong - maybe they can resave or rebuild the view or something.
- Issue was unassigned.
- ๐ฌ๐ทGreece dimitriskr
I came up with this error today. In my project, we're calling views programmatically and some contextual filters started with a comma ",". In 9.5.x this was no problem, but we upgraded to 10.2 few days ago and got this. I first tried to re-save the view but didn't have any changes in the config.
I think we need to add a check that if
is_null($break->operator)
, it means the filter values used to call the view are invalid and return that error to the user
Also, for the actual problem, if the property 'break_phrase' of the 'nid' argument is set to 'true', it will produce this error when using invalid arguments. The 'break_phrase' argument in the UI is "Allow multiple values" in "More" when editing a contextual filter
I'm uploading a test patch that reproduces this error
- ๐ฌ๐ทGreece dimitriskr
dimitriskr โ changed the visibility of the branch 11.x to hidden.
- ๐ฌ๐ทGreece dimitriskr
dimitriskr โ changed the visibility of the branch 10.1.x to hidden.
- Merge request !6774TypeError: Cannot assign null to property ArgumentPluginBase::$operator โ (Open) created by dimitriskr
- ๐ฌ๐ทGreece dimitriskr
I'm moving the work to https://git.drupalcode.org/project/drupal/-/merge_requests/6774. The other MRs can be closed
- Status changed to Needs review
3 months ago 11:55am 18 March 2024 - ๐ฌ๐ทGreece dimitriskr
@pcambra did you maybe forget to push to the issue branch? Otherwise there's nothing to review
- Status changed to Needs work
3 months ago 1:24pm 18 March 2024 - ๐ช๐ธSpain pcambra Spain, ๐ช๐บ
sorry, I was testing patch in #29 (which solves my issue) and changed this by mistake
- ๐ฌ๐ทGreece dimitriskr
OK. but this patch just hides the error, not solving the actual issue. The problem originates from the fact that an argument in your view is invalid
- ๐ฎ๐ณIndia shrikant.dhotre
shrikant.dhotre โ changed the visibility of the branch 3353786-typeerror-cannot-assign to hidden.
- ๐บ๐ธUnited States bfuzze9898
Patch #28 alone works for me. Thanks.