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 Deprecated in qtranslate_utils.php #1263

Closed
sviluppomania opened this issue Nov 30, 2022 · 9 comments
Closed

PHP Deprecated in qtranslate_utils.php #1263

sviluppomania opened this issue Nov 30, 2022 · 9 comments
Labels
need info The submitter must provide more info

Comments

@sviluppomania
Copy link
Contributor

PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /plugins/qtranslate-xt/qtranslate_utils.php on line 389

@herrvigg
Copy link
Collaborator

herrvigg commented Dec 1, 2022

Somehow related to #966 and #1092.

@herrvigg
Copy link
Collaborator

herrvigg commented Dec 1, 2022

Can you explain how to reproduce this? Or get more traces from a callstack?

@herrvigg herrvigg added the need info The submitter must provide more info label Dec 1, 2022
@sviluppomania
Copy link
Contributor Author

Hi,
i got it through active WP Debug.

@herrvigg
Copy link
Collaborator

herrvigg commented Dec 3, 2022

This is how you detected it, but how are we supposed to reproduce it? What is the context? The data?

@sviluppomania
Copy link
Contributor Author

It is an error that occurs only front end

@herrvigg
Copy link
Collaborator

Sorry but this doesn't help, please provide better information so we can reproduce it. This is way too fuzzy. We need to understand the context, with data, traces, call stack, ...

@Juje
Copy link
Contributor

Juje commented Feb 1, 2023

@herrvigg The error he is most likely talking about is this one:

ErrorException: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in file htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php on line 389
Stack trace:
  1. ErrorException->() htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php:389
  2. preg_match() htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php:389
  3. qtranxf_isMultilingual() htdocs/content/plugins/qtranslate-xt/qtranslate_frontend.php:767
  4. qtranxf_translate_metadata() htdocs/content/plugins/qtranslate-xt/qtranslate_frontend.php:843
  5. qtranxf_filter_usermeta() htdocs/cms/wp-includes/class-wp-hook.php:310
  6. WP_Hook->apply_filters() htdocs/cms/wp-includes/plugin.php:205
  7. apply_filters() htdocs/cms/wp-includes/meta.php:632
  8. get_metadata_raw() htdocs/cms/wp-includes/meta.php:571
  9. get_metadata() htdocs/cms/wp-includes/user.php:1159
 10. get_user_meta() htdocs/cms/wp-includes/class-wp-user.php:324
 11. WP_User->__get() htdocs/cms/wp-includes/l10n.php:109
 12. get_user_locale() htdocs/content/plugins/groups/lib/core/class-groups-controller.php:180
 13. Groups_Controller->get_mofile() htdocs/content/plugins/groups/lib/core/class-groups-controller.php:195
 14. Groups_Controller->load_textdomain_mofile() htdocs/cms/wp-includes/class-wp-hook.php:308
 15. WP_Hook->apply_filters() htdocs/cms/wp-includes/plugin.php:205
 16. apply_filters() htdocs/cms/wp-includes/l10n.php:759
 17. load_textdomain() htdocs/content/plugins/copy-the-code/classes/class-copy-the-code.php:98
 18. Copy_The_Code->localization_setup() htdocs/cms/wp-includes/class-wp-hook.php:308
 19. WP_Hook->apply_filters() htdocs/cms/wp-includes/class-wp-hook.php:332
 20. WP_Hook->do_action() htdocs/cms/wp-includes/plugin.php:517
 21. do_action() htdocs/cms/wp-settings.php:480
 22. require_once() htdocs/wp-config.php:32
 23. require_once() htdocs/cms/wp-load.php:55
 24. require_once() htdocs/cms/wp-blog-header.php:13
 25. require() htdocs/index.php:17

Which happens over here: https://github.com/qtranslate/qtranslate-xt/blob/master/qtranslate_utils.php#L389
This error happened on the latest version on PHP 8.1.

@sviluppomania
Copy link
Contributor Author

@herrvigg

@herrvigg The error he is most likely talking about is this one:

ErrorException: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in file htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php on line 389
Stack trace:
  1. ErrorException->() htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php:389
  2. preg_match() htdocs/content/plugins/qtranslate-xt/qtranslate_utils.php:389
  3. qtranxf_isMultilingual() htdocs/content/plugins/qtranslate-xt/qtranslate_frontend.php:767
  4. qtranxf_translate_metadata() htdocs/content/plugins/qtranslate-xt/qtranslate_frontend.php:843
  5. qtranxf_filter_usermeta() htdocs/cms/wp-includes/class-wp-hook.php:310
  6. WP_Hook->apply_filters() htdocs/cms/wp-includes/plugin.php:205
  7. apply_filters() htdocs/cms/wp-includes/meta.php:632
  8. get_metadata_raw() htdocs/cms/wp-includes/meta.php:571
  9. get_metadata() htdocs/cms/wp-includes/user.php:1159
 10. get_user_meta() htdocs/cms/wp-includes/class-wp-user.php:324
 11. WP_User->__get() htdocs/cms/wp-includes/l10n.php:109
 12. get_user_locale() htdocs/content/plugins/groups/lib/core/class-groups-controller.php:180
 13. Groups_Controller->get_mofile() htdocs/content/plugins/groups/lib/core/class-groups-controller.php:195
 14. Groups_Controller->load_textdomain_mofile() htdocs/cms/wp-includes/class-wp-hook.php:308
 15. WP_Hook->apply_filters() htdocs/cms/wp-includes/plugin.php:205
 16. apply_filters() htdocs/cms/wp-includes/l10n.php:759
 17. load_textdomain() htdocs/content/plugins/copy-the-code/classes/class-copy-the-code.php:98
 18. Copy_The_Code->localization_setup() htdocs/cms/wp-includes/class-wp-hook.php:308
 19. WP_Hook->apply_filters() htdocs/cms/wp-includes/class-wp-hook.php:332
 20. WP_Hook->do_action() htdocs/cms/wp-includes/plugin.php:517
 21. do_action() htdocs/cms/wp-settings.php:480
 22. require_once() htdocs/wp-config.php:32
 23. require_once() htdocs/cms/wp-load.php:55
 24. require_once() htdocs/cms/wp-blog-header.php:13
 25. require() htdocs/index.php:17

Which happens over here: https://github.com/qtranslate/qtranslate-xt/blob/master/qtranslate_utils.php#L389 This error happened on the latest version on PHP 8.1.

@ludiccc
Copy link

ludiccc commented Mar 13, 2023

This can be fixed changing the line 389 on qtx_utils.php with

return !is_null($str) && preg_match( "/<!--:$lang_code-->|\[:$lang_code]|{:$lang_code}/im", $str );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need info The submitter must provide more info
Projects
None yet
Development

No branches or pull requests

4 participants