Problem/Motivation

Drupal Version: 9.3.9 PHP:7.3
/*|all-page

Warning: strpos(): Empty needle in page_specific_class_preprocess_html() (line 43 of modules/~theming/page_specific_class/page_specific_class.module).

Proposed resolution

        // Check wildcard.
        if (strpos($url, '*') !== FALSE) {
/*WT-patch*/
          /*$path = str_replace('/*', '', $url);
          $path = str_replace('*', '', $path);
          if (strpos($alias_path, $path) === 0) {*/
          $path = str_replace(['/*', '*'], '', $url);
          if ($path == '' || strpos($alias_path, $path) === 0) {
/*<<<*/
            $passWildCard = TRUE;
CommentFileSizeAuthor
#5 3277278-5.patch748 bytessourabhjain

Comments

Promo-IL created an issue. See original summary.

promo-il’s picture

Issue summary: View changes
sourabhjain’s picture

Assigned: Unassigned » sourabhjain
sourabhjain’s picture

I am working on this issue.

sourabhjain’s picture

Assigned: sourabhjain » Unassigned
Status: Active » Needs review
StatusFileSize
new748 bytes

Resolved the issue as suggestion. Please review.

promo-il’s picture

#5 and the original solution does not miss validation /node/*/edit = /node/33/edit
PHP:8 Drupal:9.3.13
Another solution

        // Check wildcard.
        if (strpos($url, '*') !== FALSE) {
/*WT-patch: Warning*/
          /*$path = str_replace('/*', '', $url);
          $path = str_replace('*', '', $path);
          if (strpos($alias_path, $path) === 0) {*/
/*v.1*/
             //$path = str_replace(['/*', '*'], '', $url);
             //if ($path == '' || strpos($alias_path, $path) === 0) {
/*v.2*/
             $pattern = str_replace(['*','/'], ['(.*)','\/'], $url);
             if( preg_match("/{$pattern}/", $alias_path) ) {
/*<<<*/
            $passWildCard = TRUE;
          }
        }
ilfelice’s picture

FWIW, #6 worked nicely (in PHP 8.1, Drupal:9.3.14)

hardik_patel_12’s picture

Status: Needs review » Closed (works as designed)

Thank you, everyone, for your contributions. I've made revisions to the code to incorporate wildcard logic. You can review the changes here: https://www.drupal.org/project/page_specific_class/issues/3373861