ShMaunder / JMapMyLDAP

LDAP Integration for Joomla! 2.5+
shmanic.com/tools/jmapmyldap
26 stars 19 forks source link

Joomla 3.4 update causes Catchable fatal error: #28

Open kirancheema opened 9 years ago

kirancheema commented 9 years ago

Hi Shaun

Just updated an Install to Joomla 3.4 and the following is happening:

Catchable fatal error: Argument 1 passed to Joomla\Utilities\ArrayHelper::getValue() must be of the type array, string given, called in C:\UniServer\www\scwcsu\libraries\joomla\utilities\arrayhelper.php on line 264 and defined in C:\UniServer\www\scwcsu\libraries\vendor\joomla\utilities\src\ArrayHelper.php on line 242

If you turn off the sync on login for the LDAP Profile plugin It goes through fine ... I have tracked it to

the profile.php line 235 (Ish) $adapter = SHFactory::getUserAdapter($username);

kirancheema commented 9 years ago

quick fix is to turn off "sync on login"

kirancheema commented 9 years ago

factory.php needs changing

150 to $username = strtolower(JArrayHelper::getValue($user, 'username', null, 'array')[0]);

ShMaunder commented 9 years ago

I'll get right on this in a couple of hours.

ShMaunder commented 9 years ago

I can't understand how it can't be an array as there is a check before hand:

if (is_array($user)) { $username = strtolower(JArrayHelper::getValue($user, 'username', null, 'string')); .... }

You sure its occurring from that? I can't get to my test environment for another couple of hours yet.

kirancheema commented 9 years ago

actually ignore the previous..

the issue is 227 I think
if ($password = JArrayHelper::getValue($user, 'password', false))

changed this to if ($password = JArrayHelper::getValue($credentials, 'password', false)) and it works fine

kirancheema commented 9 years ago

Profile.php onLdapSync line 232 is passing in $username as a string to the getuseradapter function

ShMaunder commented 9 years ago

Yes, OK. Can only guess that Joomla have enforced that parameter. Can confirm in a minute.

ShMaunder commented 9 years ago

Yea as expected, they enforced the array in 3.4:

In 2.5 it was https://github.com/joomla/joomla-cms/blob/2.5.x/libraries/joomla/utilities/arrayhelper.php#L277 whereas now its https://github.com/joomla/joomla-cms/blob/staging/libraries/vendor/joomla/utilities/src/ArrayHelper.php#L242

I shouldn't have allowed anything but an array to go through so that is pretty bad. But in previous versions it just returned null if it wasn't an array. I will go round and ensure all calls to ArrayHelper::getValue is checking the first parameter is an array. I cannot start this until I'm back at my computer. Maybe hacking Joomla at /libraries/vendor/joomla/utilities/src/ArrayHelper.php by changing:

public static function getValue(array $array, $name, $default = null, $type = '') to public static function getValue($array, $name, $default = null, $type = '')

is a better temporary solution until I release a proper fix later today.

kirancheema commented 9 years ago

No worries its seems stable for the moment so will leave as is until your official fix

ShMaunder commented 9 years ago

I have just built http://server.shmanic.co.uk/jmml_builds/2.0.3.1/packages/ which I have just started to test. Instead of changing logic in many places, I have just forked the method from Joomla 3.3 and performed a sed across all instances of JArrayHelper::getValue(). Question now is whether there are other changes like this.

ShMaunder commented 9 years ago

If anybody could test http://server.shmanic.co.uk/jmml_builds/2.0.3.1/packages/ then that'll be great. From initial tests, it looks like it works correctly and if no further issues are found I will release this in the coming hours and push an auto-update as well.

nmo-hosting commented 9 years ago

I did a test with lib_shmanic.zip 25-Feb-2015 18:47

  1. Update lib
  2. Update to J3.4
  3. Tested Login again
  4. works

Are you going to push this by the web updater? Thanks!

Rey-Nevan commented 9 years ago

Awesome guys :). Thanks a bunch, you saved me a headache

patgaytx commented 9 years ago

I can also confirm that the updated lib_shmanic.zip 25-Feb-2015 18:47 resolved the issue. Here's what I did:

  1. Visit http://server.shmanic.co.uk/jmml_builds/2.0.3.1/packages/
  2. Download lib_shmanic.zip 25-Feb-2015 18:47
  3. Backup my site
  4. Using the Joomla Installer, install lib_shmanic.zip
  5. Done
conconnl commented 7 years ago

@shmaunder I think this one can be closed