cakephpexceptionmodelcontainable

CakePHP: Cannot use modParams with indexes that do not exist


I am writing a datasource to access a external web service, this works fine as expected, but after the web service has run, I get the following error:

CakeException: Cannot use modParams with indexes that do not exist.
in /project/lib/Cake/Utility/ObjectCollection.php on line 128

After a little googling, I found this similar question:

What does this error actually mean?

Unfortunately, this didn't help me solve my answer.

I understand that the error is expecting me to remove (or add extra) params, but I don't understand where I am setting these params to edit them.


Solution

  • (answering my own question to help others with the same issue!)

    The Issue

    The issue I had that in my AppModel, I have set public $actsAs = array('Containable');, I do this so all my models attach the containable behaviour, (I then set recursive to -1 by default for all models, and specify the recursion as required (with the call).

    So in this case, my datasource model (which I use to interact with the datasource), had the containable behaviour attached to it (and so CakePHP thought this was correct and processed it as per normal model (which is not the case as this has no relations or database table).

    The solution

    The solution was to simply add public $actsAs = false; in my datasource model (which removed the inherited containable behaviour).

    ;)