Hello @maicol07 ,
After updating composer dependencies a few days ago, I have been experiencing issues with the PHP plugin to login a user on Flaurm.
The error message:
[22-Oct-2023 12:21:48 America/Chicago] PHP Fatal error: Uncaught Error: Call to undefined function Illuminate\Cache\now() in /home/tinkerhost/app.domain.net/vendor/illuminate/cache/ArrayStore.php:191
Stack trace:
#0 /home/tinkerhost/app.domain.net/vendor/illuminate/cache/ArrayStore.php(180): Illuminate\Cache\ArrayStore->toTimestamp(60)
#1 /home/tinkerhost/app.domain.net/vendor/illuminate/cache/ArrayStore.php(81): Illuminate\Cache\ArrayStore->calculateExpiration(60)
#2 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-api-client/src/Cache.php(81): Illuminate\Cache\ArrayStore->put(7, Object(Maicol07\Flarum\Api\Resource\Item), 60)
#3 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-api-client/src/Traits/UsesCache.php(16): Maicol07\Flarum\Api\Cache->set(7, Object(Maicol07\Flarum\Api\Resource\Item), 'users')
#4 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-api-client/src/Response/Factory.php(46): Maicol07\Flarum\Api\Resource\Item->cache()
#5 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-api-client/src/Client.php(77): Maicol07\Flarum\Api\Response\Factory::build(Object(GuzzleHttp\Psr7\Response))
#6 [internal function]: Maicol07\Flarum\Api\Client->request()
#7 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-api-client/src/Fluent.php(353): call_user_func_array(Array, Array)
#8 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-sso-plugin/src/User.php(115): Maicol07\Flarum\Api\Fluent->__call('request', Array)
#9 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-sso-plugin/src/User.php(46): Maicol07\SSO\User->fetch()
#10 /home/tinkerhost/app.domain.net/vendor/maicol07/flarum-sso-plugin/src/Flarum.php(119): Maicol07\SSO\User->__construct('User5632', Object(Maicol07\SSO\Flarum))
#11 /home/tinkerhost/app.domain.net/action/Login.php(43): Maicol07\SSO\Flarum->user('User5632')
#12 /home/tinkerhost/app.domain.net/action/Login.php(316): forumLogin(Array, Object(PDO), Array)
#13 {main}
thrown in /home/tinkerhost/app.domain.net/vendor/illuminate/cache/ArrayStore.php on line 191
I tried deleting and re-installing both illuminate and your packages, with the same result as above.
My code:
use Maicol07\SSO\Flarum;
use Maicol07\SSO\User;
$options = array(
"url"=>"https://community.domain.net/forum/",
"root_domain"=>"https://domain.net",
"api_key"=>"i=oEPL0i4GpWlmt&jHkkL@M8RrF87Ljn*Q0u_7o*oi6",
"password_token"=>"ugnpwLMkbp33p5KRAIiYUJpLYvmDOqiJ",
"cookies_prefix"=>"community"
);
$flarum = new Flarum($options);
$user = $flarum->user($Data['forum_username']);
$user_alias = $flarum->user();
$user->attributes->email = $Data['forum_email'];
$user->attributes->password = md5($Data['custom_psw']);
$user->attributes->username = $Data['forum_username'];
$user->login();
header('location: https://community.domain.net/forum/');
the code has not been changed since it began working, and I cannot find anything in the documentation or change logs that suggests that something needs to be changed (Unless I missed it of course).
Thanks for any assistance that you can offer
EDIT: After some testing, the issue appears to stem from the newest version of the illuminate package (Which probably should have been obvious from the error message). Rolling back on the illuminate version solves things for now - but it would still be nice to know how to resolve this with the newest version of the package.