Code Monkey home page Code Monkey logo

Comments (18)

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

Don't have any idea yet. What version do you use?
Try to use this one: https://github.com/goFrendiAsgard/No-CMS/tree/80247c81b1eb42dfb7ae0420412d6c286cc8f812
I've check the error path (cms_model.php line 1071) and it seems to be okay.
Do you have any screenshot?

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

I just cloned the repo from github and ran the installer.
The screen is just blank with the fatal error as I described above.

Will try with your link above

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

Or you can do git fetch
Please tell me if there is still an error

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

clean install, still the same problem. I am going to try and backtrace it as well.

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

I think there is a problem with anonymous function in CodeIgniter's model. Or it might be related to MX_Controller
Not quite sure, because there is nothing wrong when I try it in my system (ubuntu, apache2, php 5.3)

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

its almost like there is something being called statically, which is then trying to load the CMS_Model. MX has a lot of static methods, I will look there./

By the way, I can still access the default CI welcome controller.

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

Hi, just to make sure if the problem is in (or not in) MX Controller,
I need your help to change line 9 of application/core/CMS_Controller.php
https://github.com/goFrendiAsgard/No-CMS/blob/master/application/core/CMS_Controller.php

From

class CMS_Controller extends MX_Controller {

into

class CMS_Controller extends CI_Controller {

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

the issue seems to be that for whatever reason, CMS_Model is not receiving the CI instance when it is instantiated. It is probably something mis-configured on my side.

Changing from MX to CI on the controller made no difference

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

I see. I'll try to figure it out too. Maybe I should use other system

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

I commented out this line in CMS_Model (1071) -

return $this->cms_lang($arr[1]);

and it started working. I have not tested it fully to see what problems that might cause. Can you tell me what the intended behavior of the callback is?

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

It will search for appropriate language in language setting.
So {{ language:Home }} Will be replaced with current language of "Home"

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

I think the problem is variable scope. I believe that $this is not supported inside of an anonymous function until php 5.4.0.

I have changed the code to the following:

    $_this = clone $this;
    $replacement = function($arr) use ($_this) {
        $_this->cms_lang($arr[1]);
};

Unless this creates some other downstream problem, I believe it will work properly.

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

I see. I'll try this solution in some other anonymous function. Thanks for your hard work :)

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

No problem. Let me know if there are any other issues you would like a second set of eyes to look at.

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

I add a bit version checking here:

        // php 5.4.0 or below doesn't support $this in anonymous function
        if (strnatcmp(phpversion(),'5.4.0') >= 0){ 
            $replacement = function($arr){
                return $this->cms_lang($arr[1]);    
            };
        }else{
            $_this = clone $this; 
            $replacement = function($arr){
                return $_this->cms_lang($arr[1]);   
            };
        }

https://github.com/goFrendiAsgard/No-CMS/tree/faa80def868413ed02f0b79dcc38778a652d40ce
Thanks again for your hardwork 👍
We owe you :)

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

everything seemed fine, then I did a clean install with the updated code and it broke again.
I will work on it later today. It is like the clone stopped working all of a sudden.

it is kicking out the following.

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: _this

Filename: models/cms_model.php

Line Number: 1079

Fatal error: Call to a member function cms_lang() on a non-object in /path/to/No-CMS/application/models/cms_model.php on line 1079

from no-cms.

AndrewPodner avatar AndrewPodner commented on July 29, 2024

Fixed. Change your code to:

$replacement = function($arr) use ($_this) {

It makes $_this available to the function.

from no-cms.

goFrendiAsgard avatar goFrendiAsgard commented on July 29, 2024

Okay, and I think this is more general:

$replacement = function($arr) use ($this){
            return $this->cms_lang($arr[1]);    
        };

EDIT : okay, what I write before is a bad idea, since $this can't be used in "use" part
And this one should fix everything :p

        // php 5.4.0 or below doesn't support $this in anonymous function
        if (strnatcmp(phpversion(),'5.4.0') >= 0){ 
            $replacement = function($arr){
                return $this->cms_lang($arr[1]);    
            };
        }else{
            $_this = clone $this; 
            $replacement = function($arr) use ($_this){
                return $_this->cms_lang($arr[1]);   
            };
        }

So I hope this gonna be work https://github.com/goFrendiAsgard/No-CMS/tree/92feec55e025e6774982b8c409e5f604f55be37f
Thank's again

from no-cms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.