warning: array_search()

azovsky - October 28, 2008 - 17:15
Project:Secure Password Hashes (phpass)
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

Download phpass 6.x-1.x-dev (2008-Okt-25).
After change the files on my site have got error:
warning: array_search() [function.array-search]: Wrong datatype for second argument in ...\www\sites\all\modules\phpass\phpass.module on line 16.

#1

steev_initsix - November 4, 2008 - 19:02

yep, we have this too. Will post a fix if i find one.

#2

steev_initsix - November 4, 2008 - 20:01

well, we seem to have fixed the error, not sure its dealt with the problem tho.

We were using the phpass module to migrate over phpbb3 users with the phpbb2(HEAD) module. Phpass was giving us this error after a successful migration.

the offending line is :

14. function phpass_form_alter(&$form, $form_state, $form_id) {
15. // check for any login process
16. $validate = array_search('user_login_authenticate_validate', $form['#validate']);

array_search ($needle, $haystack)

$form['#validate'] i think is a callback to the page you're on (in our tests this was 'poll_view_voting_validate' i think), but we gave up at this point and tried an alternative solution which seems to have worked.

1. login as admin in f/f
2. disable phpbb2drupal module
3. change user settings to use drupal standard hashing
4. then disabled phpass module

THEN we did 5 and 6, although 7 would probably work better!

5. logged out, requested new passwd and couldnt login (still getting the error from the phpass.module file! even tho uninstalled)
6. Deleted folder /sites/all/modules/phpass, requested new passwd and it worked fine.
alternatively
7. will probably work better if you uninstall the module, then logout and request a new passwd

if in doubt, just stay logged in as admin in one browser (f/f) and login/out as a user in opera or something.

I hope this helps a bit!

#3

steev_initsix - November 4, 2008 - 20:22

Perhaps this should be filed under the Secure password hash 6.x-1.x-dev thread, but i just tried to implement step 7 above to test, and it seems that you cant uninstall the Secure Password hash module! similarly, the phpass.module file still seems to be referenced even tho its disabled.

So, in short, you need to ignore step 7 above if you dont need the Secure password hash module after upgrading using phpbb2drupal

#4

Connor Gilbert - November 9, 2008 - 18:30
Status:active» needs review

I will begin by stating that I am by no means an expert at PHP, and I've never actually used arrays in any of my extremely simple projects. However, looking at the documentation for array_search(), the proper datatype for the second argument (as referenced in the error) is an array. In the code on line 16, the second argument is $form['validate'], which to me appears to be an element of the array. Again, forgive me if I am wrong because I don't have experience with this.

So, what got rid of the error for me was to change $form['validate'] (the element) to $form (the array). This got rid of the error that had previously been showing up (identical to the one referenced at the top of this thread) and, although I don't have a good enough understanding of PHPass to be able to tell, it appears that everything is still working.

I hope this helps.

#5

Connor Gilbert - November 9, 2008 - 18:32
Assigned to:azovsky» Anonymous

#6

jmpoure - November 21, 2008 - 23:07

This issue still exists. It is a blocking bug. I cannot test migration of my 500.000 phpBB3 board. Can you provide a patch or a hack ?

#7

nbz - November 28, 2008 - 16:42

I think this has been fixed in the newer nightlies.

In any case, I have updated the patched version of this module made with the other fix too for people migrating from phpbb3. The new file is available from here: http://www.theraggedyedge.co.uk/project/phpbb-2-drupal

Or you can apply the md5 patch that is attached to #290124: errors when defaulting to md5 authentication method. onto the new nightly to get to the same result.

Another note: the phpass module has been designed to only allow being disabled once there are no longer ANY phpass based passwords left. I think this is by design to not allow admins to lose user passwords.

 
 

Drupal is a registered trademark of Dries Buytaert.