New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP Warnings re: LinksEncoder.php fails with "... preg_match_all(): Compilation failed: recursive call could loop indefinitely at offset 20" #3848
Comments
PHP Warning: preg_match_all(): Compilation failed: recursive call could loop
indefinitely at offset 20 in
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php
on line 173
```
You can search for the error using google and may find different
proposal how to counter this issue but without knowing the text that
causes the warning there is not much we can do from here. Above line
173 in `LinksEncoder` you'll find the pattern explanation and that has
been proven to be valid and working.
It could also be that you are using an outdated PCRE library. Again,
without knowing the specifics this going to be difficult to answer.
PHP Warning: Invalid argument supplied for foreach() in
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php
on line 182
This shouldn't happen but I'm guessing because of the above failed
`preg_match_all`, the referenced `$matches` is most likely to be
empty. So, a check on the validity of `$matches[0]`should help avoid
the above message.
### Task
- [ ] Find the text that causes the issue
- [ ] Use an online PCRE tester using the pattern (from
`LinksEncoder`) and the specific text
- [ ] Based on the above outcome make an proposal on how to counter the issue
- [ ] Check and validate `$matches[0]`
Cheers
…On 3/25/19, Jeremi Plazas ***@***.***> wrote:
### Setup and configuration
- SMW version: 3.0.1
- MW version: 1.31.1
- PHP version: 7.0.33 (apache2handler)
- DB system and version: MySQL 5.6.42-log
### Issue
I'm encountering the following recurring errors when executing runJobs.php:
```
PHP Warning: Invalid argument supplied for foreach() in
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php
on line 182
PHP Warning: preg_match_all(): Compilation failed: recursive call could loop
indefinitely at offset 20 in
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php
on line 173
```
Any clues what is causing this? Is it SMW version or other extensions
needing updating?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#3848
|
The server looks like a Debian 9, so https://packages.debian.org/stretch/libpcre3 is at 8.39 If this is about links in values then perhaps |
Thanks for the replies so far. @mwjames i am looking into trying to identify what exactly is triggering the warnings. I'm sorry if my lack of developer skills takes me a little while. Will get back to you on that... @kghbln I will look into the PCRE version and make sure we don't need to update it. We did have issues with this |
Ok so it looks like we're running the latest version of PCRE that we can... We're on an amazon ec2 and are running the latest we can:
|
Ok so it looks like we're running the latest version of PCRE that we can...
We're on an amazon ec2 and are running the latest we can:
This is good to know, yet without the specific text we cannot isolate
the pattern or use an online PCRE validator to see what causes the
"... preg_match_all(): Compilation failed: recursive call could loop
indefinitely at offset 20 ...".
…On 3/26/19, Jeremi Plazas ***@***.***> wrote:
Ok so it looks like we're running the latest version of PCRE that we can...
We're on an amazon ec2 and are running the latest we can:
```
***@***.*** ~]$ yum list | grep pcre
pcre.x86_64 8.21-7.8.amzn1
@amzn-updates
pcre.i686 8.21-7.8.amzn1
amzn-updates
pcre-devel.x86_64 8.21-7.8.amzn1
amzn-updates
pcre-static.x86_64 8.21-7.8.amzn1
amzn-updates
pcre-tools.x86_64 8.21-7.8.amzn1
amzn-updates
***@***.*** ~]$ yum list installed | grep pcre
pcre.x86_64 8.21-7.8.amzn1
@amzn-updates
```
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#3848 (comment)
|
Yes i'm painfully aware of this. I'm having a hard time isolate what does it though. How would i go about isolating what change is causing this issue? The error is sprinkled all throughout the output of the runJobs.php command without a clear correlation to the lines that come right above it. |
Yes i'm painfully aware of this. I'm having a hard time isolate what does it
though. How would i go about isolating what change is causing this issue?
The error is sprinkled all throughout the output of the runJobs.php command
without a clear correlation to the lines that come right above it.
To find a text the causes such issue I would modify `LinksEncoder` and
add something like below after the `preg_match_all` call where we
assume that a failure will cause `$matches` to be empty or null and in
those cases outputs the text to the log (see
`wgDebugLogFile`/`wgDebugLogGroups` for details).
```
if ( $matches === [] || $matches === null ) {
wfDebugLog( 'smw-issue-3848', $text );
}
```
It should be noted that changes to classes/functions (as above) are
only activated after all jobs have run (because the PHP environment
caches the class instance).
Cheers
…On 3/26/19, Jeremi Plazas ***@***.***> wrote:
Yes i'm painfully aware of this. I'm having a hard time isolate what does it
though. How would i go about isolating what change is causing this issue?
The error is sprinkled all throughout the output of the runJobs.php command
without a clear correlation to the lines that come right above it.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#3848 (comment)
|
So i did as you suggested. From the debug log, it seems the only lines of interest may be:
|
Here we are, following with an example from the log:
[error] [8f2342302817f1436585405c] /index.php/Category:2015_Applications ErrorException from line 173 of /mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php: PHP Warning: preg_match_all(): Compilation failed: recursive call could loop indefinitely at offset 20
with the log output being:
[smw-issue-3848] This is a category page.
It lists all of the pages in category "2015 Applications" as well as
all subcategories of category "2015 Applications" if any exist.
Using above in [0] shows that something is wrong with your PCRE
library or the PHP version because `preg_match_all` [0] only fails on
some old PHP versions with the specific message of yours.
[0] https://3v4l.org/TeuQA
Cheers
…On 3/26/19, Jeremi Plazas ***@***.***> wrote:
So i did as you suggested. From the debug log, it seems the only lines of
interest may be:
```
[runJobs] smw.update Category:2015_Applications
origin=EntityRebuildDispatcher requestId=e45953a175ba6afc73ba0b7c
(id=26753,timestamp=20190326180927) STARTING
[ContentHandler] Created handler for wikitext: WikitextContentHandler
[error] [e45953a175ba6afc73ba0b7c]
/index.php?title=Special:SemanticMediaWiki&tab=rebuild ErrorException from
line 173 of
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php:
PHP Warning: preg_match_all(): Compilation failed: recursive call could loop
indefinitely at offset 20
#0 [internal function]: MWExceptionHandler::handleError(integer, string,
string, integer, array)
#1
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php(173):
preg_match_all(string, string, NULL)
#2
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php(41):
SMW\Parser\LinksEncoder::matchAndReplace(string,
SMW\Parser\InTextAnnotationParser)
#3
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/Parser/InTextAnnotationParser.php(160):
SMW\Parser\LinksEncoder::findAndEncodeLinks(string,
SMW\Parser\InTextAnnotationParser)
#4
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Hooks/InternalParseBeforeLinks.php(134):
SMW\Parser\InTextAnnotationParser->parse(string)
#5
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Hooks/InternalParseBeforeLinks.php(65):
SMW\MediaWiki\Hooks\InternalParseBeforeLinks->performUpdate(string)
#6
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Hooks/HookListener.php(267):
SMW\MediaWiki\Hooks\InternalParseBeforeLinks->process(string)
#7 /mnt/tsadra/websites/MediawikiFarm/includes/Hooks.php(177):
SMW\MediaWiki\Hooks\HookListener->onInternalParseBeforeLinks(Parser, string,
StripState)
#8 /mnt/tsadra/websites/MediawikiFarm/includes/Hooks.php(205):
Hooks::callHook(string, array, array, NULL)
#9 /mnt/tsadra/websites/MediawikiFarm/includes/parser/Parser.php(1305):
Hooks::run(string, array)
#10 /mnt/tsadra/websites/MediawikiFarm/includes/parser/Parser.php(443):
Parser->internalParse(string)
#11
/mnt/tsadra/websites/MediawikiFarm/includes/content/WikitextContent.php(323):
Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#12
/mnt/tsadra/websites/MediawikiFarm/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean,
ParserOutput)
#13
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/includes/ContentParser.php(183):
AbstractContent->getParserOutput(Title, integer, ParserOptions, boolean)
#14
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/includes/ContentParser.php(144):
SMW\ContentParser->fetchFromContent()
#15
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(196):
SMW\ContentParser->parse()
#16
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(136):
SMW\MediaWiki\Jobs\UpdateJob->parse_content()
#17
/mnt/tsadra/websites/MediawikiFarm/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(93):
SMW\MediaWiki\Jobs\UpdateJob->doUpdate()
#18 /mnt/tsadra/websites/MediawikiFarm/includes/jobqueue/JobRunner.php(296):
SMW\MediaWiki\Jobs\UpdateJob->run()
#19 /mnt/tsadra/websites/MediawikiFarm/includes/jobqueue/JobRunner.php(193):
JobRunner->executeJob(SMW\MediaWiki\Jobs\UpdateJob,
Wikimedia\Rdbms\LBFactorySimple, BufferingStatsdDataFactory, integer)
#20 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(1002):
JobRunner->run(array)
#21 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(988):
MediaWiki->triggerSyncJobs(integer, MediaWiki\Logger\LegacyLogger)
#22 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(912):
MediaWiki->triggerJobs()
#23 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(727):
MediaWiki->restInPeace(string, boolean)
#24 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(750):
MediaWiki->{closure}()
#25 /mnt/tsadra/websites/MediawikiFarm/includes/MediaWiki.php(557):
MediaWiki->doPostOutputShutdown(string)
#26 /mnt/tsadra/websites/MediawikiFarm/index.php(42): MediaWiki->run()
#27 {main}
```
I am attaching the full log for details.
[debug.log](https://github.com/SemanticMediaWiki/SemanticMediaWiki/files/3009640/debug.log)
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#3848 (comment)
|
As above tests shows there is nothing wrong with our pattern, so the issue most likely relates to the PHP/PCRE library in use. If for some reason you cannot make any administrative changes to your PHP environment then remove the |
I am getting the same message due to a planned migration of a server. Old server: PCRE version 7.8.7.el6, no warning messages I could not find any hint on which version should be used. |
Getting the same error To: Started getting the errors pcre.x86_64 8.32-17.el7 @anaconda/7.4 |
I changed my config to: MediaWiki | 1.31.6 Still same error. my homepage showing the error 3 times, I went through all my extensions and I found that extension DynamicPageList3 3.3.3 (2019-04-03) Warning: Invalid argument supplied for foreach() in /app/mediawiki/extensions/SemanticMediaWiki/src/Parser/LinksEncoder.php on line 182 |
I think I was pretty clear in my previous answer #3848 (comment) on the matter of "Compilation failed: recursive call could loop indefinitely at offset 20". To give a bit more background, the
This is an outdated version bundled with your environment (Version 8.32 30-November-2012, see [2]).
This is an outdated version bundled with your environment (Version 8.32 30-November-2012, see [2]).
I added #4576, so users can see which PCRE is used as part of the CI environment. For example, the CI with PHP 7.1.11 uses 8.38 2015-11-23 while PHP 7.3.15 uses 10.32 2018-09-10 [3]. There are no issues with those versions otherwise the integration tests would have shown a similar message as above. Furthermore, you can use [4] to test string manipulation independent of SMW and get feedback about the PCRE version in connection with the used regular expression in SMW [0]. [0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/Parser/LinksEncoder.php#L173 |
@kghbln I don't know if you want to mentioned this somewhere but if users rely on a software from let's say 30-November-2012 as in case of As for [0]http://www.pcre.org/original/changelog.txt |
Yes I do. Added it prominently. |
Thanks |
Setup and configuration
Issue
I'm encountering the following recurring errors when executing runJobs.php in this wiki farm of ours (just 2 wikis on there at the moment):
Any clues what is causing this? Is it SMW version or other extensions needing updating?
Thank you for any help, it would be much appreciated.
The text was updated successfully, but these errors were encountered: