Skip to content
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 Error - preg_replace_callback(): Compilation failed #3087

Open
3 tasks done
Pantos opened this issue Feb 14, 2025 · 15 comments · May be fixed by #3105
Open
3 tasks done

PHP Error - preg_replace_callback(): Compilation failed #3087

Pantos opened this issue Feb 14, 2025 · 15 comments · May be fixed by #3105
Labels

Comments

@Pantos
Copy link

Pantos commented Feb 14, 2025

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

  • I have read the CONTRIBUTING.md and followed the provided tips
  • I accept that the issue will be closed without comment if I do not check here
  • I accept that the issue will be closed without comment if I do not fill out all items in the issue template.

Explain the Problem

After upgrading to NC 30.0.6 i get the PHP error:
[PHP] Fehler: preg_replace_callback(): Compilation failed: digits missing after \x or in \x{} or \o{} or \N{U+} at offset 3 at /www/nextcloud/www/apps/news/vendor/pear/net_url2/Net/URL2.php#1200 von ? von -- um 14.02.2025, 22:30:07

Steps to Reproduce

The error occurs every time the cronjob updates the feeds.

System Information

  • News app version: 25.2.0
  • Nextcloud version: 30.0.6
  • Cron type: system cron
  • PHP version: 8.3.16
  • Database and version: MySQL 10.11.10
  • Browser and version: Firefox 135.0
  • OS and version: FreeBSD 14.2
Contents of nextcloud/data/nextcloud.log
{"reqId":"qhP25lmMuX7zj3Tk9Mzd","level":3,"time":"2025-02-14T21:30:07+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"preg_replace_callback(): Compilation failed: digits missing after \\x or in \\x{} or \\o{} or \\N{U+} at offset 3 at /www/nextcloud/www/apps/news/vendor/pear/net_url2/Net/URL2.php#1200","userAgent":"--","version":"30.0.6.2","data":{"app":"PHP"},"id":"67afb5dff2211"}
@Pantos Pantos added the bug label Feb 14, 2025
@Grotax Grotax added help wanted API Impact API/Backend code labels Feb 16, 2025
@Pantos
Copy link
Author

Pantos commented Feb 16, 2025

The bug still exists in version 25.2.1.

@nomoo
Copy link

nomoo commented Feb 17, 2025

also hit that.

News app version: 25.2.1
Nextcloud version: 30.0.6
Cron type: system cron
PHP version: 8.2.27
Database and version: MySQL 8.0.39
OS and version: FreeBSD 14.2

@Pantos
Copy link
Author

Pantos commented Feb 17, 2025

I had entered the OS version incorrectly in the bug report. I also use FreeBSD. With a fresh install on Linux with NC 30.0.6 and News 20.5.1 I could not reproduce the bug. Maybe the problem is OS related?

@hc42
Copy link

hc42 commented Feb 18, 2025

Hi, I can also reproduce the issue on FreeBSD. The reason is that the Net_URL2 library uses an invalid regex at the mentioned line. The single \x is invalid here.
See for example, the definition here: https://pcre.org/pcre.txt (or ask your favorite LLM).

There is an issue here at the library repository about this problem: pear/Net_URL2#17
It seems \x was used as shorthand for \x00. This however, is problematic and support was removed in PHP v8.3.16 and v8.4.3.
I wonder why that was allowed in the first place?

@hc42
Copy link

hc42 commented Feb 18, 2025

This behavior was changed in the pcre2 project, where this broken regex support was removed. PCRE2Project/pcre2@4d2bb33

It is part of version 10.45. The FreeBSD port was updated on 6 Feb 2025 https://www.freshports.org/devel/pcre2/ . This is why it probably affects our systems now (At least I updated the package to 10.45).
As a temporary hotfix, you could build an older version of this port until this issue is resolved here and see if that will work.

@Pantos
Copy link
Author

Pantos commented Feb 19, 2025

That works perfectly! Instead of building a new (old) pcre2 version, I simply added the two zeros to line 1201 in /www/nextcloud/www/apps/news/vendor/pear/net_url2/Net/URL2.php (pear/Net_URL2@2639e87):

'([\x00-\x20\x22\x3C\x3E\x7F-\xFF]+)',

@Pantos Pantos closed this as completed Feb 20, 2025
@SMillerDev SMillerDev mentioned this issue Feb 24, 2025
3 tasks
@Grotax Grotax reopened this Feb 24, 2025
@Grotax Grotax changed the title No feed update after upgrading to NC 30.0.6 - PHP Error - preg_replace_callback(): Compilation failed PHP Error - preg_replace_callback(): Compilation failed Feb 24, 2025
@ugjka
Copy link

ugjka commented Feb 25, 2025

I was losing my marbles because some update caused all feeds output "No parser can handle this stream"

@Pantos hotfix did the trick

@dersebi
Copy link

dersebi commented Feb 26, 2025

This is strange. I applied the hotfix, which made feed updates work in general again, but some of my feeds still don't update with "No parser can handle this stream". I tried those with the feed-io command line tool and they worked just fine. Is the change in line 1201 the only thing you need to do?

@XDjackieXD
Copy link

I have the same issue as @dersebi after applying the "hotfix".
Still a few feeds that worked before and now say "No parser can handle this stream".

@Narrat
Copy link

Narrat commented Feb 28, 2025

Had the same trouble. Or have?
The workaround did work for most of the feeds (would there be a different way to resolve the errors without deleting and readding those?)
But some still fail. Example. Maybe there is something wrong with the XML, but the feed worked before updating to pcre2 10.45

Edit: Okay, the question about the errors can be disregarded. Manual refresh didn't do a thing, but shortly I wrote the post the remaining errors went away.

@distinctjuggle
Copy link

Like others, I applied the hotfix of editing the one line in the URL2.php file. I restarted my entire server, and mysteriously after some amount of time (between 10 minutes to an hour, ish) the fix worked.

For whatever reason, it takes a bit of time to actually, "fix" things. Seems to be reproducible at least.

@dersebi
Copy link

dersebi commented Mar 3, 2025

Unfortunately I still see the "No parser can handle this stream" errors with the hotfix. Even after a server reboot. Tried a downgrade of pcre as well which did not help either. I guess something got messed up in my install :(
Edit: Re-adding the failing feeds fixed it for me finally (with hotfix in place).

@nextcloud486153
Copy link
Contributor

I'm also facing this issue, my system info is below. After applying the patch, and a few minutes passed (cron was executed multiple times, so 10-15 minutes), the issue was resolved. Executing cron directly did not immediately fix the issue.

News app version: 25.2.1
Nextcloud version: 30.0.6
Cron type: system cron
PHP version: 8.2.27
Database and version: MariaDB 11.7.2
OS and version: ArchLinux

@Pantos
Copy link
Author

Pantos commented Mar 3, 2025

I can confirm that some feeds do not work for me, which could be retrieved before ("No parser can handle this stream"). Deleting and re-adding the affected feeds seems to be the way to go (as suggested by @dersebi #3087 (comment)). Now it works again.

@Grotax Grotax linked a pull request Mar 4, 2025 that will close this issue
@XDjackieXD
Copy link

Re-Adding them worked for me too except for one (https://dmitry.gr/rss.php) which seems to have some slightly invalid HTML that was parsed without issues before but now errors (did the parser get stricter?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants