Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#37071 closed defect (bug) (fixed)

PHP 7.1.0 changed how they handle string vs array-indexes.

Reported by: simonvik's profile simonvik Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: Cc:

Description

Login to wordpress fails with Warning: Illegal string offset 'user_login' under php 7.1.0 alpha 1.

wp-login.php sends an empty string to wp_signon that expects an array.

The following patch to wp-login.php seems to solves the issue:


@@ -790,7 +790,7 @@ function retrieve_password() {
  
        $reauth = empty($_REQUEST['reauth']) ? false : true;
  
 -      $user = wp_signon( '', $secure_cookie );
 +      $user = wp_signon( array(), $secure_cookie );
  
        if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
                if ( headers_sent() ) {

Attachments (1)

fix-wp-login-error.patch (366 bytes) - added by simonvik 9 years ago.
Attached patch that might solve the issue.

Download all attachments as: .zip

Change History (14)

@simonvik
9 years ago

Attached patch that might solve the issue.

#1 @Compute
9 years ago

  • Keywords has-patch added

+1 good catch. Hope this gets into trunk soon.

#2 @SergeyBiryukov
9 years ago

  • Component changed from General to Users
  • Milestone changed from Awaiting Review to 4.6

#3 @SergeyBiryukov
9 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @jorbin
9 years ago

Might make sense to fix this in wp_signon as well, just in case plugins copied core's implementation.

#5 @dd32
9 years ago

#37083 was marked as a duplicate.

#6 @dd32
9 years ago

From #37083:

[Mon Jun 13 00:24:29 2016] PHP Warning: Illegal string offset 'remember' in /tmp/wordpress/wp-includes/user.php on line 41
[Mon Jun 13 00:24:29 2016] PHP Stack trace:
[Mon Jun 13 00:24:29 2016] PHP 1. {main}() /tmp/wordpress/router.php:0
[Mon Jun 13 00:24:29 2016] PHP 2. require_once() /tmp/wordpress/router.php:51
[Mon Jun 13 00:24:29 2016] PHP 3. wp_signon() /tmp/wordpress/wp-login.php:784

[Mon Jun 13 00:24:29 2016] PHP Warning: Cannot assign an empty string to a string offset in /tmp/wordpress/wp-includes/user.php on line 41
[Mon Jun 13 00:24:29 2016] PHP Stack trace:
[Mon Jun 13 00:24:29 2016] PHP 1. {main}() /tmp/wordpress/router.php:0
[Mon Jun 13 00:24:29 2016] PHP 2. require_once() /tmp/wordpress/router.php:51
[Mon Jun 13 00:24:29 2016] PHP 3. wp_signon() /tmp/wordpress/wp-login.php:784

[Mon Jun 13 00:24:29 2016] PHP Warning: Illegal string offset 'user_login' in /tmp/wordpress/wp-includes/user.php on line 56
[Mon Jun 13 00:24:29 2016] PHP Stack trace:
[Mon Jun 13 00:24:29 2016] PHP 1. {main}() /tmp/wordpress/router.php:0
[Mon Jun 13 00:24:29 2016] PHP 2. require_once() /tmp/wordpress/router.php:51
[Mon Jun 13 00:24:29 2016] PHP 3. wp_signon() /tmp/wordpress/wp-login.php:784
[Mon Jun 13 00:24:29 2016] PHP Fatal error: Uncaught Error: Cannot create references to/from string offsets in /tmp/wordpress/wp-includes/user.php:56

Moved here as it's all related.

#7 @ocean90
9 years ago

  • Version trunk deleted

#8 @SergeyBiryukov
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37697:

Users: wp_signon() expects an array as the $credentials argument, not a string.

If an empty string was passed, redeclare it as an empty array to avoid a warning and a fatal error in PHP 7.1.0 Alpha 1.

Props simonvik.
Fixes #37071.

#9 @jorbin
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#11 @SergeyBiryukov
9 years ago

In 37720:

Embeds: In WP_oEmbed::get_provider() and WP_oEmbed::get_html(), parse the $args string to an array, as we treat it as an array later.

See #37071.

#12 @ocean90
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Upstream ticket for the change: https://bugs.php.net/bug.php?id=53432

Tests are running fine with PHP 7.1.0alpha2, closing as fixed. Feel free to reopen if you find another case which needs to be fixed.

#13 @ocean90
9 years ago

#37606 was marked as a duplicate.

Note: See TracTickets for help on using tickets.