Ticket #794 (closed defect: fixed)

Opened 16 months ago

Last modified 15 months ago

Improperly setup type table causes php error

Reported by: sp Owned by: somebody
Priority: important Milestone: 2.1
Component: Codegen Version: 2.0 HEAD
Keywords: invalid argument Cc:

Description

If you set up a type table and do not give the "name" column a unique index, you get a php error in the main.tpl file that says "Invalid argument supplied for foreach()". Older versions of qcubed completed the codegen, and showed a friendly error message at the bottom of the codegen results page stating that the "second column is not a unique VARCHAR". To recreate this problem in the test database, delete the unique index on the "name" column in the project_status_type table and then run codegen.

Attachments

ticket794.patch Download (0.8 KB) - added by vakopian 16 months ago.

Change History

follow-up: ↓ 2   Changed 16 months ago by vakopian

sp, do you know what was the last version where this worked better?

in reply to: ↑ 1   Changed 16 months ago by sp

Replying to vakopian:

sp, do you know what was the last version where this worked better?

Works fine in 2.0.2.

  Changed 16 months ago by vakopian

2.0.2 was using the special templates with PHP eval() for the code generation, so eval() was hiding errors that were happening during the evaluation. Now, since we use PHP based templates (without any eval()), these errors are throw and the code doesn't get a chance to display the analysis errors on lines 66-69 in codegen.php.

The simplest fix would be to "ignore" the errors on line 65 when calling GenerateAll(), like in the attached patch.
What do you think?

Changed 16 months ago by vakopian

  Changed 16 months ago by vakopian

  • status changed from new to in_QA

  Changed 15 months ago by sp

I think this is OK. Maybe needs to be revisited later, but trying to go back and fix the template files, given there may be customized template files out there that have duplicated this code, would be a little problematic. Tested and appears to work fine.

  Changed 15 months ago by vakopian

  • status changed from in_QA to closed
  • resolution set to fixed

(In [1424]) reviewed by sp. Fixes #794

Note: See TracTickets for help on using tickets.