Issue fork drupal-3375092

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jcontreras created an issue. See original summary.

jcontreras’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.26 KB
cilefen’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Needs review » Needs work
jcontreras’s picture

Version: 11.x-dev » 10.1.x-dev

Sorry, this was supposed to be a pplied to 10.1.x version

cilefen’s picture

larowlan’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

Can we get some detail about what the issue is here?

jcontreras’s picture

@Iarowlan -
Starting Drupal 10.1 there are some constraints added to pages settings in blocks, that only allow strings "<front>" and anything beginning with a forward slash "/", there for limiting the use of this settings section. Block Exclude Pages module uses a "!" at the beginning of URLs on pages settings to exclude some pages when a wild card is used.

This is to try and figure out a solution to fix the issue https://www.drupal.org/project/block_exclude_pages/issues/3372696

cilefen’s picture

What is the core issue that introduced the behavior change?

jcontreras’s picture

@cilefen -
in /core/modules/system/src/Plugin/Condition/RequestPath.php

if (empty($path) || $path === '<front>' || str_starts_with($path, '/')) {
jcontreras’s picture

If there is a better way to overwrite the URL limitation via the contributed module rather than patching the Drupal core please advise. Thank you.

cilefen’s picture

Using git blame, it is this issue. So what you are saying is that module Block Exclude Pages was using some nonstandard syntax for visibility and Block Exclude Pages is now broken by the validation. Correct?

cilefen’s picture

"Non-standard" isn't the right word. It is better to say that Block Exclude Pages invented a syntax that relies on the field not being validated. Is that more correct?

jcontreras’s picture

Block Exclude pages is been used on a little over 6000 sites, from drupal 7 to now. I came up with that a few years back because there was nothing to meet the need of excluding/negate specific pages. And yes I guess we can say I "invented" that syntax as it was allowed before in the validation making it more flexible and it worked just fine, but now I have no way to fix it other than doing this.

cilefen’s picture

Understood.

Something that would help spot changes like this in the future would be to have automated tests in the module to run against development versions of Drupal Core.

Can you override the validator method in the RequestPath plugin instead?

jcontreras’s picture

I am still kinda new to OOP and overwriting methods. I'll see if I can figure it out.

jcontreras’s picture

I have been trying to overwrite the "validateForm()" method on class Drupal\block\BlockForm in my .module file...
I tried creating an instance of "BlockForm" but I get an error:
ArgumentCountError: Too few arguments to function Drupal\block\BlockForm::__construct()
All variables to pass are protected and I can't figure out how to initiate this method..

Any help on how I would go about rewriting all these validations?

cilefen’s picture

Category: Feature request » Support request
Issue tags: -Needs issue summary update

It would be exceedingly difficult to help, not seeing your code. Anyway, coding guidance is not often provided in the Core issue queue, although it sometimes happens. The place to get timely answers is in #contribute in Drupal Slack and also in https://drupal.stackexchange.com, provided this hasn't been asked in the past—you should search thoroughly.

Based on everything I have seen I am changing this issue to a support request.

hlopes’s picture

You can override the condition plugins using hook_condition_info_alter .

SamLerner made their first commit to this issue’s fork.

samlerner’s picture

I made a fork here before realizing the fix was better suited in the contrib module, not in core.

I added an MR to #3372696: D10 Warning when enabling path with exclusion that uses a hook to change the Condition plugin to a custom one in the module that allows for exclamation points.

niklp’s picture

Little bit unusual to suggest this perhaps, but I notice that there is another module that does almost exactly the same as this one, altho exposes functionality slightly differently in the UI - https://www.drupal.org/project/condition_path

I also notice that this module is using conditional plugins, so perhaps you could modify this module to work in the same way as that one, whilst keeping the (IMO, slightly better) position in the UI the same?

quietone’s picture

Status: Postponed (maintainer needs more info) » Fixed

This is a support request, which @cilefen has pointed out are better handled outside of the core queue. And a fix has been applied to the contrib module that was reported in use in the issue summary. @SamLerner, thanks for reporting here on that.

I think this is resolved now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.