password_verify returns true in plain php, but false in Laravel app for the same hash - php

My goal is to make new Laravel app that is going to use old database created by Yii.
The database hash is $2a$07$6c2eb62b00df224f3d20$.qzdiDRZejMnGytXWsA7Jid7RpWazDc6.
When I run password_verify('...','$2a$07$6c2eb62b00df224f3d20$.qzdiDRZejMnGytXWsA7Jid7RpWazDc6) in a test.php (by php test.php) in PHP 7.4, it returns true.
When I run the same code inside Laravel (e.g. in php artisan tinker or a web route), in PHP 8.2, it returns false.
What can be the reason, and how to validate hashes that were previously made by, supposedly, older version of PHP (but they work in 7.4), with laravel in the latest PHP version?
In both cases the algo is unknown:
Array
(
[algo] =>
[algoName] => unknown
[options] => Array
(
)
)

Related

Laravel RefreshDatabase doesn't work in testing

In order to move my current Laravel 5.5 project to the latest version, I was trying to setup some tests (I've never done that before).
To do so, I added <env name="DB_CONNECTION" value="mysql_testing" /> in the phpunit.xml, under the <php> section, and created a copy of the current mysql configuration under config/database.php naming it mysql_testing, which has 'database' => env('DB_NAME_TESTING', 'forge') .
In the .env file I put DB_NAME_TESTING=testDB. The database exists, is empty and the user has all permissions on it.
I haven't created any Test, yet, just tried the Examples provided by Laravel. If I run the tests as they are, they all pass. If I add the RefreshDatabase trait on them, instead, I get
ErrorException : Trying to access array offset on value of type int
C:\[path to project]\vendor\symfony\console\Input\ArrayInput.php:135
which corresponds to } elseif ('-' === $key[0]) {.
After a bit of tracing, I found out that the $key is 'migrate:fresh', which is the Artisan command that RefreshDatabase is trying to run. In later versions this segment has been replaced with } elseif (str_starts_with($key, '-')) {, but this is only available since PHP 8, and I'm currently stuck with PHP 7.4.
My question now is: what am I doing wrong in setting up my testing database?
You cannot use Laravel 9 using PHP 7.4. Take a look at Support policy - max version for PHP 7.4 is Laravel 8 so either use newer PHP version or upgrade to Laravel 8 and not Laravel 9.

Unable to store SplQueue object properly in memcache in ZF2..?

I am creating a data queue using SplQueue php class and storing the queue in memcache :
$queue = new \SplQueue();
$queue->enqueue($data);
print_r($queue);
$this->getServiceLocator()->get('memcached')->setItem('key', $queue);
$queue = $this->getServiceLocator()->get('memcached')->getItem('key');
print_r($queue);
Last print_r is giving blank result like this :
SplQueue Object
(
[flags:SplDoublyLinkedList:private] => 4
[dllist:SplDoublyLinkedList:private] => Array
(
)
)
But first print_r is giving generated queue as expected. This code is working fine on my local system but generating above mentioned issue on production server.
Note:- Memcahced version is same on both machines 1.4
Any help will be appreciated..!!
While googling, i found here that it's a issue with serialization of SplDoublyLinkedList class in PHP version lower that 5.4. SplDoublyLinkedList::serialize was not working on production server (as server was running with PHP 5.3) and there is no alternative solution to do that except upgrading the PHP version to 5.4.

Array index changes case when connecting to MySQL on Windows, but not on Linux

When I connect my local working copy (Windows 7, WAMP, Apache 2.2, MySQL 5.1, PHP 5.3, CakePHP 2.4) to the local MySQL database, it gives me the following error:
Notice (8): Undefined index: Asset [APP\Controller\AssetsController.php, line 241]
Note, when connecting to the remote RHEL MySQL 5.1 server, the issue does not present itself.
Code in question:
Line 241: 'EnvironmentDeploymentStatus.asset_id'=>$conf['Asset']['asset_id'],
When connected to the RHEL MySQL 5.1, doing var_dump($conf), I'll get this:
array (size=3)
'Asset' =>
array (size=6)
When connected to the localhost Windows MySQL 5.1, doing var_dump($conf), I'll get this (notice the case change in the array key):
array (size=3)
'asset' =>
array (size=6)
The view that populates $conf contains this:
...
from
(((((((`assets` `asset`
...
I put in the following configuration in my local MySQL's my.ini file:
lower_case_table_names=2
The tables are already in lower case (and meet CakePHP standards), I don't think this has any impact on what I'm doing however.
the lower_case_table_names = 2 is probably your problem. It says in the docs
This option also applies to database names and table aliases.
(emphasis added)
MySQL Doc on lower_case_table_names
Which means MySQL is changing the table alias provided by Cake to its lowercase version.
The solution is to set this value back to recommended value of 1.

Attempting to use index type '-1' where index types are not allowed (1 or -1 only)

I am using:
$db->collection->find()->sort(array('username' => '-1'));
And I keep getting the error:
MongoCursorException: localhost:27017: Attempting to use index type
'-1' where index types are not allowed (1 or -1 only).
I am using MongoDB 2.4.1 with PHP driver 1.3.x.
Why is this?
You have called sort like so:
sort(array('username' => '-1'));
Which is a problem. In MongoDB 2.4.1 there is a slight quirk (bug?) which means that it will not accept strings any more for sort ordering.
Since this is not in the driver but instead in the server (MongoDB itself) simply changing driver version will not fix this.
This could have existed earlier than MongoDB 2.4.1 however, I merely tested this on MongoDB 2.0.0 and 2.1.x whereby I did not observe this behaviour on the same PHP driver version (1.2.x and 1.3.x).
To fix this you must specify a signed numerical figure like so:
sort(array('username' => -1));
That will work.
Edit
After posting in the mongodb-user Google group, I found out this was not a bug, however, it is still something to be aware of.

PHP mkdir issue

mkdir("/people/jason", 0700, TRUE);
TRUE = Recursive in PHP 5 and the server is running 5.2.5 but I get:
Warning: mkdir() expects at most 2 parameters, 3 given in
/home/net1003/public_html/admin/_createPage.inc on line 5
are you running this particular script through the command line interface instead? it's possible that version of PHP 4, whereas the mod_php version is 5.
That is all of my code.
I want to create a directory on the web server after a user is added to the MySQL database.
Each user gets their own directory with a default index.php page and I am trying to do this programatically rather than manually.

Categories