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

String not found in serialized object #68

Closed
borekb opened this Issue Feb 14, 2018 · 10 comments

Comments

6 participants
@borekb
Contributor

borekb commented Feb 14, 2018

I'm not sure if I'm using the search-replace command incorrectly or if this is a bug. When I search for the string using wp db search, it finds occurrences:

image

But search-replace doesn't:

image

It happens in the wpml_language_switcher_template_objects option, it looks like this:

MySQL [e3pjiwcm]> select * from ds_options where option_id=7020 \G
*************************** 1. row ***************************
   option_id: 7020
 option_name: wpml_language_switcher_template_objects
option_value: a:6:{s:20:"wpml-legacy-dropdown";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:104:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown";}s:7:"version";s:1:"1";s:4:"name";s:8:"Dropdown";s:4:"slug";s:20:"wpml-legacy-dropdown";s:8:"base_uri";s:110:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown/";s:3:"css";a:1:{i:0;s:119:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown/style.css";}s:2:"js";a:1:{i:0;s:119:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown/script.js";}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:2:{i:0;s:8:"sidebars";i:1;s:17:"shortcode_actions";}s:14:"force_settings";a:1:{s:29:"display_link_for_current_lang";i:1;}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:104:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}s:26:"wpml-legacy-dropdown-click";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:110:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click";}s:7:"version";s:1:"1";s:4:"name";s:14:"Dropdown click";s:4:"slug";s:26:"wpml-legacy-dropdown-click";s:8:"base_uri";s:116:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click/";s:3:"css";a:1:{i:0;s:125:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click/style.css";}s:2:"js";a:1:{i:0;s:125:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click/script.js";}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:2:{i:0;s:8:"sidebars";i:1;s:17:"shortcode_actions";}s:14:"force_settings";a:1:{s:29:"display_link_for_current_lang";i:1;}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:110:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}s:27:"wpml-legacy-horizontal-list";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:111:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal";}s:7:"version";s:1:"1";s:4:"name";s:15:"Horizontal List";s:4:"slug";s:27:"wpml-legacy-horizontal-list";s:8:"base_uri";s:117:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal/";s:3:"css";a:1:{i:0;s:126:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal/style.css";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:3:{i:0;s:8:"sidebars";i:1;s:6:"footer";i:2;s:17:"shortcode_actions";}s:14:"force_settings";a:0:{}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:111:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}s:25:"wpml-legacy-vertical-list";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:109:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical";}s:7:"version";s:1:"1";s:4:"name";s:13:"Vertical List";s:4:"slug";s:25:"wpml-legacy-vertical-list";s:8:"base_uri";s:115:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical/";s:3:"css";a:1:{i:0;s:124:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical/style.css";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:3:{i:0;s:8:"sidebars";i:1;s:6:"footer";i:2;s:17:"shortcode_actions";}s:14:"force_settings";a:0:{}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:109:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}s:29:"wpml-legacy-post-translations";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:113:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-post-translations";}s:7:"version";s:1:"1";s:4:"name";s:17:"Post translations";s:4:"slug";s:29:"wpml-legacy-post-translations";s:8:"base_uri";s:119:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-post-translations/";s:3:"css";a:1:{i:0;s:128:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-post-translations/style.css";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:1:{i:0;s:17:"post_translations";}s:14:"force_settings";a:0:{}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:113:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-post-translations";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}s:14:"wpml-menu-item";O:16:"WPML_LS_Template":10:{s:26:" WPML_LS_Template template";a:12:{s:4:"path";a:1:{i:0;s:98:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item";}s:7:"version";s:1:"1";s:4:"name";s:9:"Menu Item";s:4:"slug";s:14:"wpml-menu-item";s:8:"base_uri";s:104:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item/";s:3:"css";a:1:{i:0;s:113:"//prime.wpvyvoj.cz/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item/style.css";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:1:{i:0;s:5:"menus";}s:14:"force_settings";a:0:{}}s:23:" WPML_LS_Template model";a:0:{}s:24:" WPML_LS_Template prefix";s:8:"wpml-ls-";s:38:" WPML_Templates_Factory custom_filters";a:0:{}s:40:" WPML_Templates_Factory custom_functions";a:0:{}s:17:" * template_paths";a:1:{i:0;s:98:"/var/www/html/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item";}s:39:" WPML_Templates_Factory cache_directory";N;s:18:" * template_string";N;s:30:" WPML_Templates_Factory wp_api";N;s:28:" WPML_Templates_Factory twig";N;}}
    autoload: yes
@JanVoracek

This comment has been minimized.

Contributor

JanVoracek commented Feb 14, 2018

The problem is that the class WPML_LS_Template does not exist. Then PHP unserializes it as __PHP_Incomplete_Class for which is_object returns false and it skips this condition in SearchReplacer.
See an example here: https://3v4l.org/P5mC3.

__PHP_Incomplete_Class is object since PHP 7.2.0. See the changelog.

@gitlost

This comment has been minimized.

Contributor

gitlost commented Feb 14, 2018

Thanks for the report @borekb and the reason @JanVoracek , wondering if we could provide some warning diagnostic about this....

@schlessera

This comment has been minimized.

Member

schlessera commented Feb 14, 2018

I think we might need additional PHP 7.2+ treatment (check for __PHP_Incomplete_Class and act accordingly).

@borekb

This comment has been minimized.

Contributor

borekb commented Feb 14, 2018

@schlessera You mean pre-7.2, right? On 7.2, the problem seems to be fixed (my host uses 7.1).

@schlessera

This comment has been minimized.

Member

schlessera commented Feb 14, 2018

@borekb Yes, you are right, that way around it is.

@gitlost

This comment has been minimized.

Contributor

gitlost commented Feb 14, 2018

@borekb when you say fixed on 7.2, do you mean that it worked without the class being defined? Testing here suggests that attempting to set data on an __PHP_Incomplete_Class fails on 7.2 (and 7.0) and throws a PHP Notice: The script tried to execute a method or access a property of an incomplete object.... (if WP_DEBUG is true) and nothing gets set. Which seems reasonable as modifying an object with no class definition seems dubious.

So I think we need to add a check to WP_CLI/SearchReplacer.php#L90 to make sure it's not __PHP_Incomplete_Class to avoid throwing notices on 7.2, and also should provide a diagnostic warning that a class definition isn't loaded (all PHP versions).

@borekb

This comment has been minimized.

Contributor

borekb commented Feb 15, 2018

@gitlost You're right, I didn't try, just made some assumptions on the example @JanVoracek posted.

@gitlost

This comment has been minimized.

Contributor

gitlost commented Feb 15, 2018

Ah okay thanks @borekb.

@danielbachhuber

This comment has been minimized.

Member

danielbachhuber commented Feb 17, 2018

So I think we need to add a check to WP_CLI/SearchReplacer.php#L90 to make sure it's not __PHP_Incomplete_Class to avoid throwing notices on 7.2, and also should provide a diagnostic warning that a class definition isn't loaded (all PHP versions).

👍 to this approach as the resolution to the issue.

@david-treblig

This comment has been minimized.

david-treblig commented Apr 4, 2018

I just ran into this issue trying to use search-replace on php 7.2.1. Is there something I can do as a quick fix to avoid rolling back my php version?


EDIT

I realized that my MAMP installation still had 7.1.12 installed so I changed my PATH variable scoped to the current command by doing that :

env PATH="/Applications/MAMP/bin/php/php7.1.12/bin:$PATH" wp search-replace [...]

So, no need to go in my .bash_profile untill it's fixed. Keep up the good work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment