Forums | Mahara Community

Support /
Cannot redeclare add_feedback_form_validate()


anonymous profile picture
Account deleted
Posts: 4

18 November 2011, 14:41

We have been running Mahara 1.4 since August without a hitch.  Today we noticed that is not working.  

You can still log into Mahara.  Home, Profile, Groups, Settings and Logout all allow you to navigate to them.  Site Administration and My Portfolio create a 500 error:  

The website encountered an error while retrieving *servername*/admin/. It may be down for maintenance or configured incorrectly.

When I check the apache log I get the following error message:  PHP Fatal error:  Cannot redeclare add_feedback_form_validate() (previously declared in /usr/share/mahara/artefact/comment/lib.php:872) in /usr/share/mahara/lib/view.php on line 2818, referer: http://*servername*/

Any suggestions?  We have not changed anything on the server since the initial setup.  

Thanks in adavnce for any assistance.  

 

Kyle

anonymous profile picture
Account deleted
Posts: 808

20 November 2011, 14:55

Hi Kyle, it does sound like something has gone wrong.  Version 1.4.x should only have one copy of that function, and it should be in artefact/comment/lib.php.  Could you have a look in the file /usr/share/mahara/lib/view.php and see if there is a add_feedback_form_validate on line 2818?  If there is, then Mahara probably has been updated on the server since the initial setup.

The other time I've seen these sorts of errors is when the server is using apc, and the cache has not been cleared when the code in the docroot was updated, so if you're using apc or some other php accelerator you may want to clear the cache and see if that fixes the problem.

anonymous profile picture
Account deleted
Posts: 4

23 November 2011, 13:10

I have this for /lib/view.php:  

function add_feedback_form_validate(Pieform $form, $values) {    global $USER, $view;    if (!$USER->is_logged_in()) {        $token = get_cookie('viewaccess:'.$view->get('id'));        if (!$token || get_view_from_token($token) != $view->get('id')) {            $form->set_error('message', get_string('placefeedbacknotallowed', 'view'));        }    }}

And I have this in /artefact/comment/lib.php:  

function add_feedback_form_validate(Pieform $form, $values) {    if ($form->get_property('spam')) {        require_once(get_config('libroot') . 'antispam.php');        $spamtrap = new_spam_trap(array(            array(                'type' => 'body',                'value' => $values['message'],            ),        ));
        if ($form->spam_error() || $spamtrap->is_spam()) {            $msg = get_string('formerror');            $emailcontact = get_config('emailcontact');            if (!empty($emailcontact)) {                $msg .= ' ' . get_string('formerroremail', 'mahara', $emailcontact, $emailcontact);            }            $form->set_error('message', $msg);        }    }    if (empty($values['attachments']) && empty($values['message'])) {        $form->set_error('message', get_string('messageempty', 'artefact.comment'));    }}

They look like they have seperate purposes and we didn't modify 1.4.X at all.  So commenting out in view.php will fix it?  And if it does?  Why did it work before, we have had Mahara running for a few months now.  Can mahara modify it's own php files?

anonymous profile picture
Account deleted
Posts: 808

23 November 2011, 15:35

No, Mahara can't modify its own php files, something or someone else must have done it.  And if that file has got corrupted or is the wrong version, and you don't know why or how that happened, other things may be wrong too.  So I think it'd be unwise just to comment out the function in view.php - chances are something else would cause errors, or worse, just silently create inconsistent or bad data.  You should replace the entire code directory with a fresh copy that you know is good (but make sure you save your config.php file).

4 results