quickapps / cms

Modular CMS powered by CakePHP
GNU General Public License v3.0
164 stars 69 forks source link

Unable to edit content when running on cakePHP 3.4.2 #174

Closed paulrwest closed 7 years ago

paulrwest commented 7 years ago

Please note my additional comment with the fix I'm now not sure if this was due to updating cakePHP or the CMS...

On editing content the system thinks there's no data submitted for all EAV's even though there is. I think this is due to how CakePHP has changed the data model in the request class data() is depreciated and getData() is the new function. Something in the version update is breaking the entire CMS edit abilities.

https://book.cakephp.org/3.0/en/appendices/3-4-migration-guide.html

Running on: PHP Version 7.0.13-0ubuntu0.16.04.1 Packages:

"name": "cakephp/cakephp", "version": "3.4.2", "name": "quickapps-plugins/cms", "version": "dev-master",

The log file shows this error for each Field:

2017-02-28 14:50:22 Warning: Warning (2): Invalid argument supplied for foreach() in [/var/www/site/vendor/quickapps-plugins/user/src/Model/Entity/AccessibleEntityTrait.php, line 41] Request URL: /admin/content/manage/edit/232 Referer URL: http://nbpwest.rwd.lan/admin/content/manage/edit/232 Client IP: 172.18.0.1 Trace: Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 153 Content\Model\Entity\Content::isAccessible() - ROOT/vendor/quickapps-plugins/user/src/Model/Entity/AccessibleEntityTrait.php, line 41 Cake\ORM\Entity::set() - CORE/src/Datasource/EntityTrait.php, line 245 Cake\ORM\Marshaller::merge() - CORE/src/ORM/Marshaller.php, line 574 Cake\ORM\Table::patchEntity() - CORE/src/ORM/Table.php, line 2492 Content\Controller\Admin\ManageController::edit() - ROOT/vendor/quickapps-plugins/content/src/Controller/Admin/ManageController.php, line 229 Cake\Controller\Controller::invokeAction() - CORE/src/Controller/Controller.php, line 440 Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 119 Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 93 Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 60 [main] - ROOT/webroot/index.php, line 36

paulrwest commented 7 years ago

OK after some debugging a simple fix is checking for not an array as well as empty:

/vendor/quickapps-plugins/user/src/Model/Entity/AccessibleEntityTrait.php, line 36

if (empty($roles) || !is_array($roles)) {
    return true;
}

I'm not sure why it's suddenly sending a string rather than an array to isAccessible so I wont do a PR or anything until you take a further look Chris.

botchris commented 7 years ago

Hi Paul,

What you mention was already fixed days ago here: https://github.com/quickapps/cms/commit/27d44a1935a006dcd5c5d59a50a76faf2ad035c6

The problem is caused by CakePHP introducing its own isAccesible method which collides with QACMS's AccessibleEntityTrait::isAccesible

The commit I mentioned should solve this situation.

paulrwest commented 7 years ago

Thanks Chris, when is this commit likely to be merged to dev-master and released?

botchris commented 7 years ago

Damn, I forgot to split after this change, sorry for that. Everything should be up to date now.


I think I should document this:

This repo (quickapps/cms) is used for CI proposes only. Each plugin has its own separated (and independent) repo, these repos are the ones used by composer actually.

This repo (quickapps/cms) holds all latest changes for each plugin, however those changes must be manually propagated to each plugin repo using this splitter script: https://github.com/quickapps/cms/blob/2.0/splitter.php