I'm not sure it belongs anywhere. It's only used in two places: by update.module, to look for .info.yml files, and install.inc, to detect... a database driver, of all things.
So I'd suggest removing this one from the patch and filing a separate issue to deprecate and get rid of it entirely. It has two usages that are not even really conceptually related. Seems like a legacy thing.
Follow-up
#3115143: Remove deprecated DRUPAL_PHP_FUNCTION_PATTERN
Notes for developers after this change
It should be mentioned that ExtensionDiscovery::PHP_FUNCTION_PATTERN is NOT identical with DRUPAL_PHP_FUNCTION_PATTERN.
ExtensionDiscovery::PHP_FUNCTION_PATTERN contains regex delimiters and start/end symbols.
DRUPAL_PHP_FUNCTION_PATTERN does/did not have delimiters and start/end symbols.
DRUPAL_PHP_FUNCTION_PATTERN could be used as a fragment of a bigger regular expression.
ExtensionDiscovery::PHP_FUNCTION_PATTERN cannot be used as a fragment of a bigger regular expression.
class ExtensionDiscovery {
[..]
const PHP_FUNCTION_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/';
const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | 2936105-33.patch | 2.09 KB | sershevchyk |
Comments
Comment #2
rosk0Original implementation.
Comment #3
rosk0Comment #7
volegerDeprecation message need to be updated
Comment #8
volegerComment #9
sershevchykComment #10
sershevchykComment #11
volegerThis is not correct deprecation message.
Refer to the deprecation policy to find correct deprecation message structure https://www.drupal.org/core/deprecation
Comment #12
ghost of drupal pastAdded the issue which added this regular expression. git hash is 203b6a88. I do not know whether it's relevant still, I am just doing the git archeology.
Comment #13
sershevchykUpdated patch for Drupal:8.8.0
Comment #14
sershevchykComment #15
volegerComment #16
sershevchykLooks good for me
Comment #17
ghost of drupal pasthttp://grep.xnddx.ru/search?text=DRUPAL_PHP_FUNCTION_PATTERN&filename= seems it is not used much in contrib either, only API uses it.
Comment #18
catch@larowlan pointed out we already have https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...
Also given we have this, update module should probably be using it.
Comment #19
sershevchykComment #20
sershevchykComment #22
sershevchykComment #23
sershevchykComment #24
sershevchykComment #25
sershevchykComment #26
ghost of drupal pastconst DRUPAL_PHP_FUNCTION_PATTERN = ExtensionDiscovery::PHP_FUNCTION_PATTERN;that's valid PHP code?? o_O I always said a day when I learn nothing new is a day wasted, thanks for making this day not wasted.Comment #27
sershevchykComment #28
ghost of drupal pastNow I lost you, I am not sure what the goal is here because there are no comments as to what is happening in all these patches but I know from git archeology this pattern was introduced to catch false positive results -- not sure whether that applies here but I feel by dropping it from update.inc we change the meaning of the code, is this what we want? Instead of DRUPAL_PHP_FUNCTION_PATTERN .info.yml we now parse *.info.yml. Is this the desired new workings of the code? And, are we just dropping the constant, wasn't the plan to deprecate it...?
Comment #29
sershevchykYou wrote the only API uses this constant. I checked core and saw only files from the patch used this constant in 2 places.
But
DRUPAL_PHP_FUNCTION_PATTERNdifferent instidExtensionDiscovery::PHP_FUNCTION_PATTERN.We can't use almost
ExtensionDiscovery::PHP_FUNCTION_PATTERNfor mask.In the patch I returned back const DRUPAL_PHP_FUNCTION_PATTERN
Comment #30
sershevchykComment #31
volegerThe deprecation message needs to be updated.
Comment #32
sershevchykUpdated message for const
DRUPAL_PHP_FUNCTION_PATTERNComment #33
sershevchykUpdated the deprecation message for const
DRUPAL_PHP_FUNCTION_PATTERNComment #34
volegerYes, that finally looks good.
Comment #36
sershevchykTested for 8.9.x-dev patch works as expected
Comment #38
longwaveSome CI hiccups, back to RTBC.
Comment #42
catchSince this was deprecated originally in 8.5.x and we're just fixing the deprecation docs and removing usages here I think this is still fine for 8.8.x. Committed 618f0bc and pushed to 9.0.x. Thanks!
Comment #44
donquixote commentedIt should be mentioned that ExtensionDiscovery::PHP_FUNCTION_PATTERN is NOT identical with DRUPAL_PHP_FUNCTION_PATTERN.
ExtensionDiscovery::PHP_FUNCTION_PATTERN contains regex delimiters and start/end symbols.
DRUPAL_PHP_FUNCTION_PATTERN does/did not have delimiters and start/end symbols.
DRUPAL_PHP_FUNCTION_PATTERN could be used as a fragment of a bigger regular expression.
ExtensionDiscovery::PHP_FUNCTION_PATTERN cannot be used as a fragment of a bigger regular expression.