| Project: | ProjectPier |
| Version: | 0.8.8-stable |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch - code needs review |
When creating a new wiki page, on some occasions submitting the new page throws a fatal error trying to call $revision->getName() in /application/plugins/wiki/views/edit.php
Modified the following line:
if(!$page->isNew()){
and changed it to:
if(!$page->isNew() && isset($revision) && method_exists($revision, 'getName') && method_exists($revision, 'getViewUrl')){
The exact error was: PHP Fatal error: Call to a member function getName() on a non-object in "...." /application/plugins/wiki/views/edit.php on line 10
Myself and other users have run into a similar problem with editing Wiki pages with the following error:
PHP Fatal error: Call to a member function getName() on a non-object in "...." /application/plugins/wiki/models/WikiPage.class.php on line 326
I was temporarily able to get around this problem, simply by breaking the ternary operation up into individual lines as shown in the following chunk of code beginning at line 326 of WikiPage.class.php
//return (instance_of($this->new_revision, 'Revision') ?
// $this->new_revision->getName() :
// $this->getLatestRevision()->getName() );
if (instance_of($this->new_revision, 'Revision')) {
$name = $this->new_revision->getName();
} else {
$name = '';
$rev = $this->getLatestRevision();
if (instance_of($rev, 'Revision'))
$name = $rev->getName();
}