http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave
Specify 'array $options = array()' as parameter for beforeSave() and error
message will disappear.
четверг, 3 мая 2012 г., 4:21:16 UTC+4 пользователь Conor Manning написал:
>
> I have a web application that has been working fine until recently when I
> switched operating systems. I migrated from Ubuntu to Arch Linux, backing
> up my application online. In the process I lost some directories and my web
> application no longer worked.
>
> To solve this, I downloaded CakePHP again, copied the Controllers, Models
> and Views from my old project into my new copy of Cake, and modified my
> config to reflect my database.
>
> I'm using Cake's AuthComponent and I'm getting this strange error message:
>
>> Fatal error: Class 'String' not found in /srv/http/bfm/app/Model/User.php on
>> line 39
>
>
> I didn't know what to make of the line number because line 39 is the last
> line in the file. I'm not particularly experienced with PHP outside of Cake
> so perhaps somebody else will be able to tell me what that might mean.
>
> Each User has many Podcasts, and each Podcast belongs to a User. It was in
> accessing any page which used find to retrieve Podcasts and associated User
> objects that the error occurred.
>
> Stranger still, actions managed by the UsersController worked fine. I was
> able to access my user login page with no problems, and I was redirected to
> login when I tried to create a new user, which is consistent with my Auth
> settings.
>
> In any case, I decided to track down the cause of this error. I commented
> out my validation code and my beforeSave method, which used
> AuthComponent::password to hash and salt my users' passwords. Once I did
> this, the error vanished. With some further clumsy debugging through
> commenting, I figured out that it was specifically the beforeSave method
> that was causing problems.
> I tried following the trail of functions called from beforeSave, through
> AuthComponent and Security. Both of those files had App::uses('String',
> 'Utility') in them. What's more, I tried adding that line to User.php, and
> it didn't help solve the problem either.
> My beforeSave method looks like this:
>
> public beforeSave() {
> if (isset($this->data[$this->alias]['password']) {
> $password = $this->data[$this->alias]['password'];
> $this->data[$this->alias]['password'] = AuthComponent::password($password);
> }
> return true;
> }
>
> When I replaced AuthComponent::password($password) with $password, the
> error was still there, which confused me, because I was sure String was
> needed for AuthComponent::password (via Security), and that was what was
> causing the trouble.
>
> Maybe this was too long, but I wanted to give all the information I had,
> because I am well and truly stuck. I have no idea what's happening inside
> my code.
> I can provide more information or code if it's useful. I just don't know
> where to begin.
>
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.