Got errors : Property 'type' does not have a setter

Hello,guys: I got errors like this:

string(1124) " Phalcon\Mvc\Model\Exception: Property 'type' does not have a setter. File=/usr/share/nginx/html/sitewww/app/sharelibrary/Apc.php Line=22

#0 [internal function]: Phalcon\Mvc\Model->__set('type', NULL)

#1 [internal function]: Phalcon\Mvc\Model->unserialize('a:11:{s:2:"id";...')

#2 [internal function]: unserialize('a:6:{s:5:"model...')

#3 [internal function]: Phalcon\Mvc\Model\Resultset\Simple->unserialize('a:6:{s:5:"model...')

#4 /usr/share/nginx/html/sitewww/app/sharelibrary/Apc.php(22): apc_fetch('attachuserid16a...')

#5 /usr/share/nginx/html/site_www/app/controllers/AuthController.php(566): Apc->get('attachuserid16a...')

#6 /usr/share/nginx/html/site_www/app/controllers/AuthController.php(272): AuthController->getBanners('16', 0)

#7 [internal function]: AuthController->indexAction()

#8 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(AuthController), 'indexAction', Array)

#9 [internal function]: Phalcon\Dispatcher->_dispatch()

#10 [internal function]: Phalcon\Dispatcher->dispatch()

#11 /usr/share/nginx/html/site_www/public/index.php(204): Phalcon\Mvc\Application->handle()

#12 {main} "

Apc.php line 22 is :

public function get($key) {

     return apc_fetch($key);    -------- line 22

 }

Other info

var_dump($application->handle());die;

echo $application->handle()->getContent();

There is a apc key. when I use this in the header of index.php like this: it got infos.

apc_fetch('aaa');

try {

$config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config.ini');

...

but when I used in the page like this: it got errors above.

public function get($key) {

   apc_fetch('aaa');

  return apc_fetch($key);

}

How can I resolve this?

Thanks in advance!



1.9k
edited Jun '17

Are you sure APC is installed on your server ?

According to http://php.net/manual/fr/function.apc-fetch.php apc_fetch() need PECL apc >= 3.0.0 to works.

On this tutorial you can found how see if APC is enable:

https://www.digitalocean.com/community/tutorials/how-to-install-alternative-php-cache-apc-on-a-cloud-server-running-ubuntu-12-04

"To see if APC is now enabled, you can check on the PHP info page. If you don't have one, you can create an empty php file in your /var/www folder:"

nano /var/www/info.php

"And paste in the following code:"

<?php phpinfo(); ?>

"Save, exit, and open that file in the browser. There you will find all sorts of information regarding the PHP installed on your cloud server, and if APC is enabled, it should show up there. It's probably not a good idea to leave that file there in production, so make sure you delete it after you are done checking."

In vokuro project, "/app/library/Acl/Acl.php" control function exist before calling it : https://github.com/phalcon/vokuro/blob/master/app/library/Acl/Acl.php

public function getAcl()
    {
        // Check if the ACL is already created
        if (is_object($this->acl)) {
            return $this->acl;
        }

        // Check if the ACL is in APC
        if (function_exists('apc_fetch')) {
            $acl = apc_fetch('vokuro-acl');
            if (is_object($acl)) {
                $this->acl = $acl;
                return $acl;
            }
        }

        $filePath = $this->getFilePath();

        // Check if the ACL is already generated
        if (!file_exists($filePath)) {
            $this->acl = $this->rebuild();
            return $this->acl;
        }

        // Get the ACL from the data file
        $data = file_get_contents($filePath);
        $this->acl = unserialize($data);

        // Store the ACL in APC
        if (function_exists('apc_store')) {
            apc_store('vokuro-acl', $this->acl);
        }

        return $this->acl;
    }


143
edited Jun '17

Thank you for your reply. Yes I'm sure apc is installed. I use apc_fetch('aaa'), in the header of the index.php I can get values.!

object(Phalcon\Mvc\Model\Resultset\Simple)#1 (13) {

["_result":protected]=>

bool(false)

["_cache":protected]=>

NULL

["_isFresh":protected]=>

bool(true)

["_pointer":protected]=>

int(0)

["_count":protected]=>

int(0)

["_activeRow":protected]=>

NULL

["_rows":protected]=>

array(0) {

}

["_row":protected]=>

NULL

["_errorMessages":protected]=>

NULL

["_hydrateMode":protected]=>

int(0)

["_model":protected]=>

object(_PHPIncomplete_Class)#2 (1) {

["__PHP_Incomplete_Class_Name"]=>

string(6) "Attach"

}

["_columnMap":protected]=>

NULL

["_keepSnapshots":protected]=>

bool(false)

}

but when I put it in the method

public function get($key) {

apc_fetch('aaa');

return apc_fetch($key);

}

the error displayed.

my phpinfo shows:

apc

APC support Emulated

apcu

APCu Support enabled

Version 4.0.2

APCu Debugging Disabled

MMAP Support Enabled

MMAP File Mask no value

Serialization Support php, eval

Revision $Revision: 328290 $

Build Date Feb 19 2014 09:18:08

Directive Local Value Master Value

apc.coredump_unmap Off Off

apc.enable_cli Off Off

apc.enabled On On

apc.entries_hint 4096 4096

apc.gc_ttl 3600 3600

apc.mmapfilemask no value no value

apc.preload_path no value no value

apc.rfc1867 Off Off

apc.rfc1867_freq 0 0

apc.rfc1867name APCUPLOADPROGRESS APCUPLOAD_PROGRESS

apc.rfc1867prefix upload upload_

apc.rfc1867_ttl 3600 3600

apc.serializer php php

apc.shm_segments 1 1

apc.shm_size 32M 32M

apc.slam_defense On On

apc.smart 0 0

apc.ttl 0 0

apc.userequesttime On On

apc.writable /tmp /tmp



1.9k
edited Jun '17

I've you tried to put in your index, apc_fetch('aaa'); inside your try to see behaviour ?

There is a apc key. when I use this in the header of index.php like this: it got infos.

try {

apc_fetch('aaa');

$config = new Phalcon\Config\Adapter\Ini(DIR . '/../app/config/config.ini');

...

Or a vardump(apcfetch('aaa'));



143
edited Jun '17

I got this :

object(Phalcon\Mvc\Model\Resultset\Simple)#1 (13) {

["_result":protected]=>

bool(false)

["_cache":protected]=>

NULL

["_isFresh":protected]=>

bool(true)

["_pointer":protected]=>

int(0)

["_count":protected]=>

int(0)

["_activeRow":protected]=>

NULL

["_rows":protected]=>

array(0) {

}

["_row":protected]=>

NULL

["_errorMessages":protected]=>

NULL

["_hydrateMode":protected]=>

int(0)

["_model":protected]=>

object(PHPIncompleteClass)#2 (1) {

["_PHPIncompleteClassName"]=>

string(6) "Attach"

}

["_columnMap":protected]=>

NULL

["_keepSnapshots":protected]=>

bool(false)

}



1.9k

can you var dump apc_fetch('aaa') to see what is returned ?



143

Sorry, It can't display. only display errors.

can you var dump apc_fetch('aaa') to see what is returned ?



1.9k

There is a apc key. when I use this in the header of index.php like this: it got infos.

apc_fetch('aaa');

try {

     $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config.ini');

...

Can you var_dump there and comment everything else to see what's happen ?

In second part, can you show your model class and code where it's called ?

Another clue is using a debugger in your IDE to show step by step where exception is called.

You can try this one :

free 30 days trial : https://www.jetbrains.com/phpstorm/

https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html



143

can you var dump apc_fetch('aaa') to see what is returned ?

nothing, but errors display:

string(1124) " Phalcon\Mvc\Model\Exception: Property 'type' does not have a setter. File=/usr/share/nginx/html/sitewww/app/sharelibrary/Apc.php Line=22

#0 [internal function]: Phalcon\Mvc\Model->__set('type', NULL)

#1 [internal function]: Phalcon\Mvc\Model->unserialize('a:11:{s:2:"id";...')

#2 [internal function]: unserialize('a:6:{s:5:"model...')

#3 [internal function]: Phalcon\Mvc\Model\Resultset\Simple->unserialize('a:6:{s:5:"model...')

#4 /usr/share/nginx/html/sitewww/app/sharelibrary/Apc.php(22): apc_fetch('attachuserid16a...')

#5 /usr/share/nginx/html/site_www/app/controllers/AuthController.php(566): Apc->get('attachuserid16a...')

#6 /usr/share/nginx/html/site_www/app/controllers/AuthController.php(272): AuthController->getBanners('16', 0)

#7 [internal function]: AuthController->indexAction()

#8 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(AuthController), 'indexAction', Array)

#9 [internal function]: Phalcon\Dispatcher->_dispatch()

#10 [internal function]: Phalcon\Dispatcher->dispatch()

#11 /usr/share/nginx/html/site_www/public/index.php(204): Phalcon\Mvc\Application->handle()

#12 {main} "