Help OJS 2 Error DB :table.comment doesnt exist

We use OJS 2.4.4.1, in one of our journal have problem error DB: table.comment doesnt exist

in error.log show
26-Jul-2018 12:31:46 UTC] ojs2 has produced an error
Message: CAUGHT EXCEPTION: Object of class PublishedArticle could not be converted to string
In file: /journal/cache/t_compile/%%2C^2C1^2C1F000D%%issue.tpl.php
At line: 65
Stacktrace:
Server info:
OS: Linux
PHP Version: 5.5.38
Apache Version: N/A
DB Driver: mysql
DB server version: 10.1.34-MariaDB

What should we do to fix this problem? Thanks…

Hi @azmi007,

For this error:

DB: table.comment doesnt exist

Can you turn on the show_stacktrace option in config.inc.php, trigger the error, and post the full stack trace?

For this error:

Message: CAUGHT EXCEPTION: Object of class PublishedArticle could not be converted to string
In file: /journal/cache/t_compile/%%2C^2C1^2C1F000D%%issue.tpl.php
At line: 65

What does the code around line 65 of /journal/cache/t_compile/%%2C^2C1^2C1F000D%%issue.tpl.php look like?

Note that OJS 2.4.4-1 is now quite old, and I’d strongly suggest upgrading.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher here show stacktrace

DB Error: Table ‘syekh_jurnal.comments’ doesn’t exist
Stack Trace:
File: /home/syekh/public_html/jurnal/lib/pkp/classes/comment/CommentDAO.inc.php line 52
Function: DAO->retrieve(“SELECT * FROM comments WHERE submission_id = ? AND par…”, 2920)

File: /home/syekh/public_html/jurnal/pages/article/ArticleHandler.inc.php line 83
Function: CommentDAO->getRootCommentsBySubmissionId(“2920”)

File: (unknown) line (unknown)
Function: ArticleHandler->view(Array(1), Object(Request))

File: /home/syekh/public_html/jurnal/lib/pkp/classes/core/PKPRouter.inc.php line 362
Function: call_user_func(Array(2), Array(1), Object(Request))

File: /home/syekh/public_html/jurnal/lib/pkp/classes/core/PKPPageRouter.inc.php line 220
Function: PKPRouter->_authorizeInitializeAndCallRequest(Array(2), Object(Request), Array(1), False)

File: /home/syekh/public_html/jurnal/lib/pkp/classes/core/Dispatcher.inc.php line 134
Function: PKPPageRouter->route(Object(Request))

File: /home/syekh/public_html/jurnal/lib/pkp/classes/core/PKPApplication.inc.php line 178
Function: Dispatcher->dispatch(Object(Request))

File: /home/syekh/public_html/jurnal/index.php line 64
Function: PKPApplication->execute()

What we do next? Thank you

Hi @azmi007,

Your first post mentioned a table called comment, but the stack trace talks about a table called comments. I’ll assume comment was a typo and the actual table name is comments.

It sounds to me like something outside of OJS has deleted this table, which definitely should appear. I’m not sure what deleted this table or why, but if you just want to re-create it (without any contents), you can use tools/dbXMLtoSQL.php to tell you what SQL to run. For OJS 2.4.4-1, I run this command:

php tools/dbXMLtoSQL.php -schema print lib/pkp/xml/schema/comments.xml

…which gives me the following SQL…

CREATE TABLE comments (
comment_id               BIGINT NOT NULL AUTO_INCREMENT,
submission_id            BIGINT NOT NULL,
parent_comment_id        BIGINT,
num_children             INTEGER NOT NULL DEFAULT 0,
user_id                  BIGINT,
poster_ip                VARCHAR(15) NOT NULL,
poster_name              VARCHAR(90),
poster_email             VARCHAR(90),
title                    VARCHAR(255) NOT NULL,
body                     TEXT,
date_posted              DATETIME,
date_modified            DATETIME,
                 PRIMARY KEY (comment_id)
);

ALTER TABLE comments ADD  INDEX comments_submission_id  (submission_id);

ALTER TABLE comments ADD  INDEX comments_parent_comment_id  (parent_comment_id);

ALTER TABLE comments ADD  INDEX comments_user_id  (user_id);

Running those statements should re-create the table. But again, I’d be curious about why it’s missing; deleting it is not something OJS itself would do.

Regards,
Alec Smecher
Public Knowledge Project Team