Automattic / studio

Studio by WordPress.com, a free desktop app that helps developers streamline their local WordPress development workflow.
https://developer.wordpress.com/studio/
GNU General Public License v2.0
193 stars 18 forks source link

Import fails when using a site with PHP 7 #558

Closed fluiddot closed 1 month ago

fluiddot commented 1 month ago

Quick summary

Importin a backup file on a site that uses PHP 7 fails with the following error:

PHPExecutionFailureError: PHP.run() failed with exit code 255 and the following output: PHP Fatal error:  Uncaught Error: Call to undefined function str_ends_with() in /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-lexer.php:2291
Stack trace:
#0 /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-lexer.php(1490): WP_SQLite_Lexer->parse_unknown()
#1 /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-lexer.php(1442): WP_SQLite_Lexer->lex()
#2 /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php(775): WP_SQLite_Lexer->__construct('CREATE TABLE `w...')
#3 /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php(622): WP_SQLite_Translator->execute_mysql_query('CREATE TABLE `w...')
#4 /tmp/sqlite-command/src/Import.php(49): WP_SQLite_Translator->query('CREATE TABLE `w...')
#5 /tmp/sqlite-command/src/Import.php(33): Automattic\WP_CLI\SQLite\Import->execute_sta in /var/www/html/wp-content/mu-plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-lexer.php on line 2291

Steps to reproduce

  1. Create a site.
  2. Change the PHP version of the site to 7.4.
  3. Import a backup file.
  4. Observe the process fails when importing the database.

What you expected to happen

No failures when importing a back up filebackup.

What actually happened

Importing a backup file failed.

Impact

Most (> 50%)

Available workarounds?

No but the app is still usable

Platform

Mac Silicon, Mac Intel, Windows

Logs or notes

The function mentioned in the error logs (str_ends_with) is only supported in PHP 8: https://www.php.net/manual/en/function.str-ends-with.php

fluiddot commented 1 month ago

This issue will be solved in https://github.com/Automattic/studio/pull/559.