WordPress 致命错误:require():需要打开失败


WordPress Fatal error: require(): Failed opening required

( !致命错误:require():第 265 行需要 ''/mvc_controller.php 打开失败

尽管在论坛,堆栈交换等中尝试了很多建议,但我还是得到了上述错误。

我正在使用WP MVC

在WordPress 4.0.1中开发一个插件,它还封装了WP MVC内置的ORM概念。我找不到解决方案。

下面是代码:(公共控制器)

/

app/controllers/geozone_rules_controller.php

    <?php
class GeozoneRulesController extends MvcPublicController {
    var $after = array('set_geozonerules');
        public function set_geozonerules() {
            $this->load_model('GeozoneRule');           
            $geozonerules = $this->GeozoneRule->find();
            $this->set('geozonerules', $geozonerules);
        }
        // Overwrite the default index() method to include the 'is_public' => true condition
        public function index() {
        $objects = $this->GeozoneRule->find(array(
                                    'joins'     =>  array('Geozone', 'Country', 'Zone'),
                                    'includes'  =>  array('Geozone', 'Country', 'Zone'),
                                    'selects'   =>  array('Geozone.id, Geozone.geozone_name',
                                                    array('Country.id, Country.country_name',
                                                    array('Zone.id', 'Zone.zone_name',
                                                    array('GeozoneRule.id', 'GeozoneRule.ordering')
                                                    )
                                            )))
                                    );
        $this->set('objects', $objects);
        // pagination
        $this->params['page'] = empty($this->params['page']) ? 1 : $this->params['page'];
        $this->params['conditions'] = array('is_public' => true);
        $collection = $this->model->paginate($this->params);
        $this->set('objects', $collection['objects']);
        $this->set_pagination($collection);
        echo '<a href="admin.php?page=mvc_geozone_rules-add">Add New Geozone Rule</a>';
    }
    // GeozoneRule selects only GeozoneRule names and ids by default; to select all fields from GeozoneRule,
    // we'll overwrite the default show() method
    public function show() {
        $object = $this->model->find_by_id($this->params['id'], array(
            'includes' => array(
                            'Geozone',
                            'Country',
                            'Zone',
                            'GeozoneRule' => array(
                                                'selects' => 'GeozoneRule.*'
                                                )
                            )
                            ));
        if (!empty($object)) {
            $this->set('object', $object);
            $this->render_view('show', array('layout' => 'public'));
        }
    }
}
?>

型:

    <?php
class GeozoneRule extends MvcModel {
    var $table = '{prefix}w2store_geozonerules';
    var $primary_key = 'id';
    var $display_field = 'id';
    var $default_order = 'sort_name';
    var $includes = array('Geozone', 'Country', 'Zone');
    var $has_and_belongs_to_many = array(
                        'GeozoneRule' => array(
                                        'join_table' => array('{prefix}w2store_geozones',
                                                            'fields' => array('id', 'geozone_name')),
                                                        array('{prefix}w2store_countries',
                                                            'fields' => array('id', 'country_name')),
                                                        array('{prefix}w2store_zones',
                                                            'fields' => array('id', 'zone_name')),
                                                            'fields' => array('id', 'ordering')
                                                            )
                                        );
    public function after_find($object) {
        if (isset($object->geozonerules)) {
            $geozonerule_names = array();
            foreach($object->geozonerules as $geozonerule) {
                $geozonerule_names[] = $geozonerule->name;
            }
        }
    //  print_r ($object);
    //  exit;
    }
    public function after_save($object) {
        $this->update_sort_name($object);
    }
    public function update_sort_name($object) {
        $sort_name = $object->geozonerule_name;
        $this->update($object->__id, array('sort_name' => $sort_name));
    }

}
?>

现在我得到的错误:

Warning: require(): Filename cannot be empty in /mvc_controller.php

在线 265 调用堆栈 时间记忆功能位置 ..11 0.0659 3870616

任何可能的解决方案都将有很大帮助。多谢。

问题已解决。简单的错误大惊小怪。

在views/admin/文件夹中,模型GeozoneRule有一个文件夹,名称为"geozonerules",它被重命名为"geozone_rules"。现在没事了。

文件夹和文件的命名需要特别注意。

谢谢大家。