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

  • Home
  • SEARCH
  • 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 6037101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:01:27+00:00 2026-05-23T06:01:27+00:00

I ran into a problem the other day where the PagesController was throwing the

  • 0

I ran into a problem the other day where the PagesController was throwing the following error:

Fatal error: Call to a member function
find() on a non-object in
/home/jmccreary/www/thoroughbredsource.com/cakephp/app/app_controller.php
on line 20

app_controller.php line 20:

$this->current_user = $this->User->find('first', array('recursive' => 0,
  'conditions' => array('User.id' => $this->logged_in_user_id)));

In this case $this was an instance of PagesController, but for whatever reason had not inherited the User model from app_controller.php.

For completeness, here’s the relevant code:

pages_controller.php

var $name = 'Pages';
var $uses = null;

function beforeFilter() {
    parent::beforeFilter();

    $this->Auth->allow('*');
}

app_controller.php

var $uses = array('User');
var $components = array('Session', 'Cookie', 'RequestHandler', 'DebugKit.Toolbar', 'Auth' => array('autoRedirect' => false, 'loginRedirect' => array('controller' => 'users', 'action' => 'dashboard'), 'flashElement' => 'error', 'loginError' => 'The username or password you provided are incorrect.', 'authError' => 'Please log in first.', 'fields' => array('username' => 'email', 'password' => 'passwd'), 'userScope' => array('User.active' => 1)));
var $helpers = array('Html', 'Form', 'Session');

function beforeFilter() {
    parent::beforeFilter();

    // configure Cookie Component
    // ...

    $this->logged_in_user_id = $this->Auth->user('id');
    if ($this->logged_in_user_id) {
        // NOTE: the following runs on each request for the logged in user
        $this->current_user = $this->User->find('first', array('recursive' => 0, 'conditions' => array('User.id' => $this->logged_in_user_id)));
    }
}

I got past this error by change var $uses = null; to var $uses = array();. Note that removing this line completely resulted in the same error.

In the end, I don’t fully understand the original problem or my solution. I would appreciate a better explanation or what the appropriate solution should be. BTW, running CakePHP 1.3.10.

  • 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-05-23T06:01:28+00:00Added an answer on May 23, 2026 at 6:01 am

    According to the Controller class’ source source which you can see at http://api.cakephp.org/view_source/controller/:

    /**
     * An array containing the class names of models this controller uses.
     *
     * Example: `var $uses = array('Product', 'Post', 'Comment');`
     *
     * Can be set to array() to use no models.  Can be set to false to
     * use no models and prevent the merging of $uses with AppController
     *
     * @var mixed A single name as a string or a list of names as an array.
     * @access protected
     * @link http://book.cakephp.org/view/961/components-helpers-and-uses
     */
        var $uses = false;
    

    By using $uses = array(), you’re telling the PagesController to “use no model and merge with AppController’ $uses” so it works. You can see the merge in the source code starting on line 399. From what I can see, it treats “null” the same as “false” which means that it won’t load any model including the ones from the AppController.

    You can also see http://book.cakephp.org/view/961/components-helpers-and-uses for additional information on $uses.

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

Sidebar

Related Questions

I've ran into a problem while trying to test following IRepository based on NHibernate:
Ok, so I just ran into the following problem that raised an eyebrow. For
I ran into the problem that my primary key sequence is not in sync
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
I recently ran into a problem with a COM object that was using a
I'm writing a C parser using PLY, and recently ran into a problem. This
I know this question has been asked before, but I ran into a problem.
Today, I ran into this weird problem with a user using Mac OS X.
A problem I ran into a while back I never found a good solution
Here's a problem I ran into recently. I have attributes strings of the form

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.