Cakephp Upgrade


#1

Hi, if I would like to upgrade my application from
“cakephp/cakephp”: “~3.2”,
to
“cakephp/cakephp”: “3.6.*”,

If I use composer, is there a check list what to change with my application?
First try ran in several errors.
Regards


#2

I would suggest to migrate from 3.2 to 3.3 thand 3.3 to 3.4, etc.

Read this: https://book.cakephp.org/3.0/en/appendices/3-x-migration-guide.html

From 3.4 to 3.5, and from 3.5 to 3.6 you can use composer for the update.

However some files (like config/bootstrap.php or Application.php) can not be updated automatically. So what I normally do is to cretae a new cake project and see a diff of all files (I using Meld for this) and go file by file. It takes 5-10 minutes, but in the end you totally up to date.


#3

A while back I gave an answer here: Upgraded cake from 3.3 to 3.6 getting below warning

Point is you have to not only update vendor stuff, but app stuff as well when it’s a major change.


#4

Hi, I have now managed the upgrade to cakephp “3.6.*” and the application is running fine, exept one feature. I have implemented Ajax Calls based on the sandbox examples von Dereuromark.
I tried to find a hint in the documentation, but there is nothing mentioned related to cake versions.
After checking the code, I see no error, so my more general question is:
Is there a difference using this feature in a newer cake version?

The ajax-call is working fine and the needed data are collected, but the response is ‘undefined’. The view in the ajax-folder is not starting.

**account_costs_ajax.ctp:**
<?php
$confSelect =$this->get('appConfig');

if ($costcenters->toArray()) {
	echo '<option value="">' . $confSelect['defaultBefore'] . __('KDWpleaseSelect') . $confSelect['defaultAfter'] . '</option>';
	foreach ($costcenters as $k => $v) {
		echo '<option value="' . $k . '">' . h($v) . '</option>';
	}
} else {
	echo '<option value="0">' . $confSelect['naBefore'] . __('KDWnoOptionAvailable') . $confSelect['naAfter'] . '</option>';
}



**Controller-Function:**
    public function accountCostsAjax() {
        //$this->autorender -> false;
        $this->request->allowMethod('ajax');
        $id = $this->request->query('id');
        $this->log("ID " . $id);
        $kontotype = $this->divTools->getAccountType($id);
        $this->set('kontotype', $kontotype);
        $this->log("Kontotyp " . $kontotype);
        if ($kontotype < 3) {
            if (!$id) {
                throw new NotFoundException();
            }

            $this->viewClass = 'Ajax.Ajax';
            $this->loadModel('Costcenters');

            $costcenters = $this->Costcenters->getListByAccount($id);
            foreach ($costcenters as $key => $value) {
                $this->log('[value]'. $value);
            }

            if (empty($costcenters)) {
                  $this->log("No Subaccounts");
            }

            $this->set(compact('costcenters'));
        }
    }



**js-script starting ajax call:**

    $(function () {
        $('#passive').change(function () {
            var selectedValue = $(this).val();
            var targeturl = $(this).attr('rel') + '?id=' + selectedValue;
             console.log(targeturl);
            $.ajax({
                type: 'get',
                url: targeturl,
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                },
                success: function (response) {
                    console.log('response '+response.content);
                    if (response.content) {
                        console.log(response.content);
                        $('#costcenter').html(response.content);
                        if(response.content == '<option value=\"0\"> -- noOptionAvailable -- </option>') {
                             $('#extension').html(response.content);
                        }
                    }
                },
                error: function (e) {
                    alert("Unterkonto nicht gefunden: " + e.responseText.message);
                    console.log(e);
                }
            });

        });

    });

#5

Upgrading should not have effect on your code. However I think your solution is a little bit overcomplicated.
Please open another thread for this question.