Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:10:16+00:00 2026-06-09T20:10:16+00:00

What I’m trying to do: I want to install the LogableBehavior by Alkemann in

  • 0

What I’m trying to do:

I want to install the LogableBehavior by Alkemann in Cakephp.

The error I get:

When I want to make an edit, an error is returned:

Error:

Notice (8): Undefined variable: logData [APP\Model\Behavior\LogableBehavior.php, line 431]

Context given in standard cakephp error:

LogableBehavior::afterSave() – APP\Model\Behavior\LogableBehavior.php, line 431
ObjectCollection::trigger() – CORE\Cake\Utility\ObjectCollection.php, line 130
call_user_func – [internal], line ??
CakeEventManager::dispatch() – CORE\Cake\Event\CakeEventManager.php, line 246
Model::save() – CORE\Cake\Model\Model.php, line 1755
Model::saveField() – CORE\Cake\Model\Model.php, line 1582
ChantiersController::inPlaceDateUpdate() – APP\Controller\ChantiersController.php, line 370
ReflectionMethod::invokeArgs() – [internal], line ??
Controller::invokeAction() – CORE\Cake\Controller\Controller.php, line 485
Dispatcher::_invoke() – CORE\Cake\Routing\Dispatcher.php, line 186
Dispatcher::dispatch() – CORE\Cake\Routing\Dispatcher.php, line 161
[main] – APP\webroot\index.php, line 92

Code given in standard cakephp error:

$Model = object(Chantier) {}
$created = false
  $keys = array(
      (int) 0 => 'id',
      (int) 1 => 'Date_de_debut_MOA',
      (int) 2 => 'modified'
)
$diff = array(
    (int) 1 => 'Date_de_debut_MOA',
    (int) 2 => 'modified'
)
$id = '126'

What I tried to do:

I checked that all the installation steps where properly done, according to the docs there are three:

    Requires the following to work as intended :
 * 
 * - "Log" model ( empty but for a order variable [created DESC]
 * - "logs" table with these fields required :
 *     - id         [int]           : 
 *     - title      [string]        : automagically filled with the display field of the model that was modified.
 *     - created    [date/datetime] : filled by cake in normal way
 * 
 * - actsAs = array("Logable"); on models that should be logged

It seems to me I did everything fine:

my logs table

    CREATE TABLE IF NOT EXISTS `logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `description` varchar(400) NOT NULL,
  PRIMARY KEY (`id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=45 ;

My Log Model:

   <?php
App::uses('AppModel', 'Model');
class Log extends AppModel {
var $order=array("Log.created"=>"DESC");

}

And in App/Model/Chantier:

var $actsAs = array('Containable','Logable');

Then I search for people having a similar issue:

  • Github
  • Google code
  • the Bakery
  • stackoverflow

Found nothing.

Let’s dive in the code:

Here is the code.

The error talks of an error line 431:

        $this->_saveLog($Model, $logData); //line 431

It seems that $logData has not been declared.

This line is in a function, afterSave(&$Model,$created):

This function is serie of test, where line 431 is called a the very end. There are numerous declarations of $logData, but always nested in a if statement.

function afterSave(&$Model,$created) {
        
        if (isset($this->settings[$Model->alias]['skip']['add']) && $this->settings[$Model->alias]['skip']['add'] && $created) {
            return true;
        } elseif (isset($this->settings[$Model->alias]['skip']['edit']) && $this->settings[$Model->alias]['skip']['edit'] && !$created) {
            return true;
        }
        $keys = array_keys($Model->data[$Model->alias]);
        $diff = array_diff($keys,$this->settings[$Model->alias]['ignore']);
        if (sizeof($diff) == 0 && empty($Model->logableAction)) {
            return false;
        }
        if ($Model->id) {
            $id = $Model->id;
        } elseif ($Model->insertId) {
            $id = $Model->insertId;
        }       
        if (isset($this->Log->_schema[$this->settings[$Model->alias]['foreignKey']])) {
            $logData['Log'][$this->settings[$Model->alias]['foreignKey']] = $id;
        }
        if (isset($this->Log->_schema['description'])) {        
            $logData['Log']['description'] = $Model->alias.' ';
            if (isset($Model->data[$Model->alias][$Model->displayField]) && $Model->displayField != $Model->primaryKey) {
                $logData['Log']['description'] .= '"'.$Model->data[$Model->alias][$Model->displayField].'" ';
            }

            if ($this->settings[$Model->alias]['description_ids']) {
                $logData['Log']['description'] .= '('.$id.') ';
            }

            if ($created) {
                $logData['Log']['description'] .= __('added',TRUE);
            } else {
                $logData['Log']['description'] .= __('updated',TRUE);   
            }  
        }     
        if (isset($this->Log->_schema['action'])) {                 
            if ($created) {
                $logData['Log']['action'] = 'add';
            } else { 
                $logData['Log']['action'] = 'edit';         
            }  

        }
        if (isset($this->Log->_schema['change'])) {
            $logData['Log']['change'] = '';
            $db_fields = array_keys($Model->_schema);
            $changed_fields = array();
            foreach ($Model->data[$Model->alias] as $key => $value) {
                if (isset($Model->data[$Model->alias][$Model->primaryKey]) && !empty($this->old) && isset($this->old[$Model->alias][$key])) {
                    $old = $this->old[$Model->alias][$key];
                } else {
                    $old = '';
                }
                if ($key != 'modified' 
                    && !in_array($key, $this->settings[$Model->alias]['ignore'])
                    && $value != $old && in_array($key,$db_fields) ) 
                    {
                        if ($this->settings[$Model->alias]['change'] == 'full') {
                            $changed_fields[] = $key . ' ('.$old.') => ('.$value.')';
                        } else if ($this->settings[$Model->alias]['change'] == 'serialize') {
                            $changed_fields[$key] =  array('old'=>$old, 'value'=>$value);
                        } else {
                            $changed_fields[] = $key;   
                        }                   
                    }
            }
            $changes = sizeof($changed_fields);
            if ($changes == 0) {
                return true;
            } 
            if ($this->settings[$Model->alias]['change'] == 'serialize') {
                $logData['Log']['change'] = serialize($changed_fields);
            } else {
                $logData['Log']['change'] = implode(', ',$changed_fields);
            }
            $logData['Log']['changes'] = $changes;      
        }  
        $this->_saveLog($Model, $logData);//line 431
    }

My question:

Ideally I would like some advice from someone knowing this Behabior on how to fix the error, but any general method on how to debug it would be gladly accepted.

Edit: I use Cakephp 2.2.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:10:17+00:00Added an answer on June 9, 2026 at 8:10 pm

    you seem to use a very very old version of it. it has been improved greatly since then. if you are using cake2.x here is a working one that should be up to date (and all test cases pass):
    https://github.com/dereuromark/tools/blob/2.0/Model/Behavior/LogableBehavior.php

    it uses an own log table/model. but other than that it should be pretty straight forward.
    the sql for the logs table is in Config / sql / log.sql but should probably be the same as yours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.