I am upgrading cakephp 3.10 to 4.0 then 4.5 and so on upto 5.o.
I currently have php 7.2 installed
When i am using your upgrade tool so first u have upgraded to php 8.
can u tell me on which step i can update php version. also tell me how to update all the core files . i tries with CakeDC | CakeDC CakePHP Upgrade Guide | The minds behind CakePHP
but there are no. of errors in core files. I am opeing my login page and it is saying the page is not redirecting properly. my controller action code is
public function login()
{
$connection = ConnectionManager::get(‘default’);
$subdomain = $_SERVER[‘HTTP_HOST’];
$details = $this->Usercom->client_details($subdomain);
setcookie(‘loggedIn’, ‘true’, time() + 3600);
$this->request->getSession()->write(‘pending_task_popup’, true);
$this->set(‘details’, $details);
if ($this->Auth->user()) {
// $this->Flash->error(__(‘You are already logged in!’));
//return $this->redirect($this->Auth->redirectUrl());
$allprojectsuser = $this->Global->getUserProjects($this->Auth->user(‘id’));
$project_info_checkaccountadmin = $this->Pcc->CheckAccountAdmin($this->Auth->user('id'));
if ($project_info_checkaccountadmin == 0 && $allprojectsuser->count() == 0) {
$this->Flash->error('Your account has been deactivated. Please contact your account administrator.');
return $this->redirect($this->Auth->logout());
}
if ($allprojectsuser->count() == 1) {
setcookie('loggedInProject', 'true', time() + 3600);
$this->request->getSession()->write('pending_task_popup', true);
return $this->redirect(array('controller' => 'Projects', 'action' => 'projectdetails', $allprojectsuser->first()->id));
} else {
return $this->redirect(array("controller" => "Projects", "action" => "index"));
}
}
$this->viewBuilder()->setLayout('login_v1');
if ($this->request->is('post')) {
try {
$user_id = $this->Auth->user();
$email = $this->request->data['email'];
$result = $this->Users->find('All')->where(['email' => $email, 'status' => 0])->count();
if ($result == 0) {
$this->Flash->set('Your account is disabled. Please contact account administrator', ['key' => 'status']);
} else {
$user = $this->Auth->identify();
if ($user) {
$this->Global->updateLastLogin($user['id'], 'web');
// get user token for todo dashboard data populate ----- code starts --- added by Siva
// $apiLogin = $this->Global->apiLogin($this->request->data['email'], $this->request->data['password']);
// $user['api_token'] = $apiLogin['data'][0]['token'];
// $ppEncryptKey = 'wt1U5MACWJFTXGenFoZoiLwQGrLgdbHA';
// $ppEncryptResult = Security::encrypt($this->request->data['password'], $ppEncryptKey);
// $user['pp_api_secret'] = $ppEncryptResult;
// get user token for todo dashboard data populate ----- code ends --- added by Siva
$user['zepth_client_id'] = $details[0]['id'];
$user['zepth_client_subdomain'] = $subdomain;
$this->Auth->setUser($user);
// $this->request->getSession()->write('zepth_client_id', $details[0]['id']);
if (!empty($this->request->getQuery('redirect'))) {
//pr($this->request->getQuery('redirect'));exit;
return $this->redirect($this->request->getQuery('redirect'));
} else {
$allprojectsuser = $this->Global->getUserProjects($this->Auth->user('id'), $subdomain);
$project_info_checkaccountadmin = $this->Pcc->CheckAccountAdmin($this->Auth->user('id'), $subdomain);
if ($project_info_checkaccountadmin == 0 && $allprojectsuser->count() == 0) {
$flash_msg = "There isn’t an account on " . $subdomain . " tied to this email address.You can always try again with a different email or contact your Zepth account administrator.";
$this->Flash->error($flash_msg);
return $this->redirect($this->Auth->logout());
}
if ($allprojectsuser->count() == 1) {
// code is done by siva to check if user having only one project then check zepth lite subscription and redirect to index page
$companies = $connection->execute('select DISTINCT(clients.id),clients.company_name as name,clients.logo from clients inner join projects on projects.client_id=clients.id inner join projects_users on projects_users.project_id=projects.id where projects_users.user_id=:user_id AND projects_users.user_activated=1 order by clients.company_name ASC ', ['user_id' => $user['id']])->fetchAll('assoc');
$subscription_type = $this->checkZepthSubscriptionType($companies[0]['id']);
if ($subscription_type == 2) {
return $this->redirect(array("controller" => "Projects", "action" => "index"));
}
// code is done by siva to check if user having only one project then check zepth lite subscription and redirect to index page
//this code is normal condition
return $this->redirect(array('controller' => 'Projects', 'action' => 'projectdetails', $allprojectsuser->first()->id));
} else {
return $this->redirect(array("controller" => "Projects", "action" => "index"));
}
}
//return $this->redirect($this->Auth->redirectUrl());
}
// $errors = $validator->errors($this->request->getData());
if (!empty($errors)) {
$this->set(compact('errors'));
}
$this->Flash->set('The email or password is not correct. Did you forget your password?', ['key' => 'alert']);
}
} catch (\Cake\Http\Exception\InvalidCsrfTokenException $e) {
$this->Flash->set('CSRF token invalid', ['key' => 'alert']);
}
}
}
and routes code is
$routes->scope(‘/’, function (RouteBuilder $builder): void {
/*
* Here, we are connecting ‘/’ (base path) to a controller called ‘Pages’,
* its action called ‘display’, and we pass a param to select the view file
* to use (in this case, templates/Pages/home.php)…
*/
$builder->connect(‘/’, [‘controller’ => ‘Users’, ‘action’ => ‘login’, ‘login’]);
/*
* ...and connect the rest of 'Pages' controller's URLs.
*/
/*
* Connect catchall routes for all controllers.
*
* The `fallbacks` method is a shortcut for
*
* ```
* $builder->connect('/{controller}', ['action' => 'index']);
* $builder->connect('/{controller}/{action}/*', []);
* ```
*
* You can remove these routes once you've connected the
* routes you want in your application.
*/
$builder->fallbacks();
});