Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index 'comment' in DBStructure #6119

Closed
fabrixxm opened this issue Nov 12, 2018 · 3 comments · Fixed by #6151
Closed

Undefined index 'comment' in DBStructure #6119

fabrixxm opened this issue Nov 12, 2018 · 3 comments · Fixed by #6151
Labels
Milestone

Comments

@fabrixxm
Copy link
Collaborator

In line 332

if (isset($database[$name]["table_status"]["Comment"])) {
if ($database[$name]["table_status"]["Comment"] != $structure['comment']) {
$sql2 = "COMMENT = '".DBA::escape($structure['comment'])."'";

I didn't check, could be an issue with my addon. Nevertheless the code should check the index before accessing it.
Something like:

 if (isset($database[$name]["table_status"]["Comment"])) {
        $structurecomment = isset($structure["comment"]) ? $structure["comment"] : "";
	if ($database[$name]["table_status"]["Comment"] != $structurecomment) {
             $sql2 = "COMMENT = '".DBA::escape($structurecomment)."'";
@MrPetovan MrPetovan added the Bug label Nov 12, 2018
@MrPetovan
Copy link
Collaborator

Related to #5932

@annando
Copy link
Collaborator

annando commented Nov 12, 2018

Could you check whether your addon does contain comment fields at all? All core tables do have these fields.

@fabrixxm
Copy link
Collaborator Author

My addon does not contains "comments" field:
https://kirgroup.com/projects/fabrixxm/friendica-projects/tree/master/projects.php#L2319

I could add it, but I think a better approach is to be prepared for it to be missing.
either:

  • the field is optional, then we check for it and have a default value
  • the field is mandatory, then we raise an hard error, so developers know that is missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants