Error thrown cannot create references to from string offsets

I get this error when I try to access the /wp-login.php : Warning: Illegal string offset 'remember' in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 41 ...

@Knogobert

I get this error when I try to access the /wp-login.php :

Warning: Illegal string offset 'remember' in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 41

Warning: Cannot assign an empty string to a string offset in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 41

Warning: Illegal string offset 'user_login' in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 56

Fatal error: Uncaught Error: Cannot create references to/from string offsets in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php:56 Stack trace: #0 /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-login.php(784): wp_signon('', '') #1 {main} thrown in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 56

As you can see i exchanged my USERNAME and PROJECTNAME.

When I change PHP version from 7.1.0 to 7.0.13 I can access the login page as usual.
So this is just a heads up for you guys! Great work!


Bedrock version: 1.7.3

WordPress version: 4.7.1

PHP version: 7.1

OS: macOS 10.11.6 (El Capitan)

@retlehs

@Knogobert

Excuse me, I only believed so because of a new installation. I was on wp 4.7 when this happened. Now I have updated to WP 4.7.1. Should I check if the problem persists for you guys?

EDIT
This is probably just WP’s error. Sorry to use your precious time!

@retlehs

@Knogobert

Nope! Dunno why it didn’t work for me on 4.7 :/

@bormat

I fixed it easily by adding

	if ( empty($credentials) ) {
		$credentials = [];

on line 39 in wp_signon of user.php in wp-includes.

Knogobert, raphaelfreitas, paulqlove, fpinzn, Riverlance, MasaSip, ptyagi911, codingcereal, ollie-pinksquid, acachy, and 37 more reacted with thumbs up emoji
truecounterfeit, aungmyohtet, mAAdhaTTah, retlehs, NotAmaan, and k1sul1 reacted with thumbs down emoji
TranHuuTrung reacted with laugh emoji
ndls, TranHuuTrung, danlherman, and MaxiKata reacted with hooray emoji
mayakokits, viniciusferrao, thangdangblog, CameronColensoBBDO, wesood, ndls, TranHuuTrung, and MaxiKata reacted with heart emoji
ndls, TranHuuTrung, and MaxiKata reacted with rocket emoji
thangdangblog, Dark-Matterr, mattia-beta, and TranHuuTrung reacted with eyes emoji

@marciobera

I returned to 5.6 php version and done!

@randelsr

This problem still persists. composer create-project roots/bedrock installs dependency johnpblock/wordpress v4.3 which is significantly behind the current WordPress release.

This is considered a security risk as php 5.6 is deprecated.

To resolve:
a. set php version on host to 5.6 or 7.0
b. install via composer create-project roots/bedrock .
c. go through the typical WordPress install via instructions
d. Upgrade WordPress Core
e. Change php version on host to latest version (tested on 7.1.24 and verified working)

@ndls

I fixed it easily by adding

	if ( empty($credentials) ) {
		$credentials = [];

on line 39 in wp_signon of user.php in wp-includes.

You are a hero, thank you.

@retlehs

35 upvotes on that comment? are y’all using bedrock? don’t modify wordpress core… or any other dependencies, since every time you composer install those changes are going to be wiped

this was already fixed upstream in wordpress core. not sure what y’all are running into…. but update WP, and update PHP…. but don’t modify WP core files. especially if you’re using bedrock

hacky option if for some reason you need to actually do this: https://github.com/cweagans/composer-patches

@randelsr

Host PHP version was off, forcing an older version of Bedrock. Update php / composer and you’ll be all set

@kapilk2io

I fixed it easily by adding

	if ( empty($credentials) ) {
		$credentials = [];

on line 39 in wp_signon of user.php in wp-includes.

This worked like a charm!!!

@roots
roots

locked and limited conversation to collaborators

May 19, 2020

First post on here.

I am a developer for the company I work for and we have a word press site that is public (we host it). For this query lets say the url is http://mywordpresssite

We have just copied the site internally to our DEV server so we can perform development on it. The mySQL database has been copied as well and if I browse to the internal URL I can view the page. Lets say the url is http://mywpsite.

The problem comes when I try to access the admin console on the dev site. On the public site I would use http://mywordpresssite/wp-login.php and this works fine. If I use http://mywpsite/wp-login.php I get the following web page.

screenshot of error message

I am not that familiar with word press, does anyone have any tips on how to resolve this or where I should be looking to change files etc.

Thanks

UPDATE

I am still having an issue with this but I am a bit further through identifying the issue.

I enabled error logging on the site and when I try to navigate to the admin page the error log displays the following:

[04-Apr-2017 07:31:22 UTC] PHP Warning: Illegal string offset
‘remember’ in D:mywordpressstiewp-includesuser.php on line 39
[04-Apr-2017 07:31:22 UTC] PHP Warning: Cannot assign an empty string
to a string offset in D:mywordpressstiewp-includesuser.php on line
39 [04-Apr-2017 07:31:22 UTC] PHP Warning: Illegal string offset
‘user_login’ in D:mywordpressstiewp-includesuser.php on line 54
[04-Apr-2017 07:31:22 UTC] PHP Fatal error: Uncaught Error: Cannot
create references to/from string offsets in
D:mywordpressstiewp-includesuser.php:54 Stack trace:

0 D:mywordpressstiewp-login.php(775): wp_signon(», »)

1 {main} thrown in D:mywordpressstiewp-includesuser.php on line 54

I have been googling it but my php/wordpress knowledge is limited. I found the following URL link to patch, bit no idea how to use this.

Can anyone help?

asked Mar 16, 2017 at 12:00

Silentbob's user avatar

SilentbobSilentbob

5211 gold badge4 silver badges8 bronze badges

3

I fixed it!!! Woohoo.

Using this link — link to patch

I edited the line it advises and it works fine.

answered Apr 4, 2017 at 8:03

Silentbob's user avatar

SilentbobSilentbob

5211 gold badge4 silver badges8 bronze badges

3

If you copy everything from the actual site, you probably need to check the following:

  1. Check wp-config.php to make sure that the host, database credential is consistent to the local database setup;
  2. Make sure the wordpress directories are belong to the correct owner. Try sudo chown -R www-data:, replace www-data with whoever owner that have the access for web page;
  3. Make sure the directories have the correct access permissions, you can find further information here

If you still have problem, edit your post and provide update.

answered Mar 16, 2017 at 12:33

hcheung's user avatar

hcheunghcheung

3191 gold badge3 silver badges12 bronze badges

It seems that your site migration might have missed some steps. Since you mention that you are able to access the home page that means that you have changed the wp-config.php with your local db details.

Did you update the wp-options table ? The table contains two important rows which specify the site and home URL.

You can find more about Moving WordPress site : https://codex.wordpress.org/Moving_WordPress. You can cross check to see if you missed any steps while migrating.

If you are using a mac for your local dev site — you find detailed explanation : http://egalo.com/2012/05/15/clone-live-wordpress-to-local-env/

Also please check if you have copied live site’s .htaccess over to dev — they might contain some re-write rules — which will not work on dev. You might want to rename the file to see if it is the cause of this problem.

answered Mar 16, 2017 at 12:36

Sheeba's user avatar

2

I got this error after installing wordpress with composer enter image description here

Edited the user.php in plugin-wordpresswpwp-includesuser.php

Changed the following lines from

function wp_signon( $credentials = array(), $secure_cookie = '' ) {
}

to:

This solved the error and a wordpress login form entry shows up.

function wp_signon() {
     $credentials = array(); $secure_cookie = '' ;
}

fuxia's user avatar

fuxia

105k34 gold badges246 silver badges447 bronze badges

answered Jan 2, 2022 at 8:27

lailah grant's user avatar

Bug #80039 Illegal string offset and Cannot create references to/from string offsets
Submitted: 2020-08-31 09:03 UTC Modified: 2020-08-31 09:43 UTC
From: miloslav dot hula at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.4.9 OS:
Private report: No CVE-ID: None

 [2020-08-31 09:03 UTC] miloslav dot hula at gmail dot com

Description:
------------
This is probably related to https://bugs.php.net/bug.php?id=80037

The test scripts emits warning and fatal error when creating a reference to static variable.

The test script is reduced to show the error. In production code, there is a relation between referenced value in fromArray() and $prop = &$cache ...

For example, when I call:

A::fromArray(['a' => 'foo']);

the error is emmited, the exception handler executed and

$prop = &$cache[$class][$name];

normally pass. But, the $prop contains 'foo' string.

Test script:
---------------
<?php

final class A
{
	public string $a;

	public static function fromArray(array $props): self
	{
		$me = new static;
		foreach ($props as $k => &$v) {
			$me->{$k} = &$v;
		}
		return $me;
	}

	public function __get($name)
	{
		throw new LogicException("Property '$name' is not defined.");
	}
}

class ObjectHelpers
{
	public static function hasProperty(string $class, string $name)
	{
		static $cache = [];
		$prop = &$cache[$class][$name];  # <-- emits error
	}
}

set_exception_handler(function ($e) {
	ObjectHelpers::hasProperty(A::class, 'a');
});

A::fromArray(['a' => 'foo']);

Expected result:
----------------
(no error)

Actual result:
--------------
Warning: Illegal string offset 'a' in bug.php on line 27

Fatal error:  Uncaught Error: Cannot create references to/from string offsets in bug.php:27
Stack trace:
#0 bug.php(32): ObjectHelpers::hasProperty('A', 'a')
#1 [internal function]: {closure}(Object(Error))
#2 {main}
  thrown in bug.php on line 27


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2020-08-31 09:12 UTC] nikic@php.net

Hm, I can't reproduce this on current 7.4/master HEAD, just get empty output. Possibly this has been fixed recently?

 [2020-08-31 09:19 UTC] miloslav dot hula at gmail dot com

And when you

$prop = &$cache[$class][$name];
var_dump($prop);

the $prop is NULL?

 [2020-08-31 09:43 UTC] nikic@php.net

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic

 [2020-08-31 09:48 UTC] miloslav dot hula at gmail dot com

Thank you. But I think that test may fail in future. IMHO the exception should not be thrown at all. I reported this as a consequence of https://bugs.php.net/bug.php?id=80037

Понравилась статья? Поделить с друзьями:
  • Error thrown call to undefined function eregi
  • Error threshold reached replacing the hard drive is recommended что это
  • Error thread is not a member of std
  • Error this was not captured for this lambda function
  • Error this value is not valid