Browse files

Adding a catch for the edge case of a model's table not existing duri…

…ng verify_settings() in MvcPostAdapter to bypass a fatal error that stops the user from being able to reactivate the plugin
  • Loading branch information...
1 parent 638845e commit a7413c3b568fb9d283a29ca6491c1e572019699a @tombenner committed Sep 19, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 core/models/wp_models/mvc_post_adapter.php
@@ -3,7 +3,9 @@
class MvcPostAdapter {
public function verify_settings($model) {
- if (!isset($model->schema['post_id'])) {
+ if (empty($model->schema)) {
+ MvcError::warning('The schema for '.$model->name.' is empty. It\'s likely that the plugin generating this table isn\'t working, or you may need to deactivate and activate it. Please make sure that the table "'.$model->table.'" exists.');
+ } else if (!isset($model->schema['post_id'])) {
MvcError::fatal('To associate posts with '.$model->name.', its table needs to have a column named "post_id" of type BIGINT(20). Please run the following SQL to add and index the column:
ALTER TABLE '.$model->table.' ADD COLUMN post_id BIGINT(20);

0 comments on commit a7413c3

Please sign in to comment.