Updating from 1.3.1 to 1.4

edited April 2017 in Bug Reports
Hi,

I've been trying to do an update, but I'm getting the following errors and wondering if you know what I can look for to fix them. I replaced these folders: codeigniter, data_backup, install, licenses, modules, scripts and the root index.php only.

$ php index.php fuel/installer/update A PHP Error was encountered Severity: Notice Message: Use of undefined constant EXT - assumed 'EXT' Filename: C:\xampp\htdocs\Nordegg\fuel\modules\fuel\core\Router.php Line Number: 201 A PHP Error was encountered Severity: Notice Message: Use of undefined constant EXT - assumed 'EXT' Filename: C:\xampp\htdocs\Nordegg\fuel\application\third_party\MX\Modules.php Line Number: 168 Fatal error: Call to undefined method MY_Router::_set_404override_controller() i n C:\xampp\htdocs\Nordegg\fuel\modules\fuel\core\Router.php on line 161 A PHP Error was encountered Severity: Error Message: Call to undefined method MY_Router::_set_404override_controller() Filename: C:\xampp\htdocs\Nordegg\fuel\modules\fuel\core\Router.php Line Number: 161

Oh ya, I also added the new /fuel/application/views/errors folder

Thanks so much,
Chris.

Comments

  • edited 6:57PM
    The the fuel/application/thrid_party/MX folder as well.
  • edited 6:57PM
    Awesome, that was it. Now, I have to fix errors from the prior version of CodeIgniter.

    Thanks!
  • edited 6:57PM
    Hi,
    I just updated to 1.4. I got the backend working, but in the frontend all urls are redirected to the codeigniter default 404 page.
    In CodeIgniter.php $e404 always results in true. Any idea which point ist the best to start debugging?
  • edited 6:57PM
    I'm not quite sure I understand when you say $e404 always results to true.
  • edited 6:57PM
    In line 410 of CodeIgniter.php (Sanity Checks) the variable $e404 is introduced.
    The following lines always result in $e404 being true, so that the default codeigniter 404 page is shown.
    I don't know why the Fuel CMS route handling does not work any more. Do you have an idea, how I can check if the Fuel CMS module is called? Is there a hook I can debug for example?
  • edited May 2017
    ok... got a step further.
    First issue was that in my installation not all custom files had the prefix MY in uppercase. Some where in lowercase my ... so my custom MY_page_router wasn't found...
    Now I have the 404 page of my fuel cms installation. I will do further debugging :-)

    UPDATE: strange behaviour... the homepage is handled via the 404_override ... _remap method of MY_page_router (which extends Page_router) is entered with uri_path(TRUE) = MY_page_router
    Why is the controller name returned by uri_path?
    uri_path is called 3 times on loading the base url. First and second time returns empty array, last time returns the controller name...

    uri_path(TRUE) results in controller name, uri_path(FALSE) results in empty string.

    MY_page_router content is as discussed in http://forum.getfuelcms.com/discussion/2611/redirecting-to-404#Item_16

    include_once($_ENV["DOC_ROOT"] . "/fuel/modules/fuel/controllers/Page_router.php"); class MY_page_router extends Page_router { public function _remap($method = NULL) { if (!in_array(uri_path(TRUE), $this->fuel->pages->cms()) && uri_path(TRUE) != "offline") { $uri_path = uri_path(TRUE); if (substr($uri_path, -1) == "/") { $uri_path = rtrim($uri_path, "/"); } elseif (is_numeric(substr($uri_path, strrpos($uri_path, "/") + 1))) { $uri_path = rtrim($uri_path, substr($uri_path, strrpos($uri_path, "/"))); } if (!in_array($uri_path, $this->fuel->pages->cms())) { $this->location = "404_error"; } else { $this->location = uri_path(TRUE); } } else { $this->location = uri_path(TRUE); } // if the rerouted file can't be found, look for the non-routed file' if (!file_exists(APPPATH . 'views/' . $this->location . EXT)) { $non_routed_uri = uri_path(FALSE); if (file_exists(APPPATH . 'views/' . $non_routed_uri . EXT)) { $this->location = $non_routed_uri; } unset($non_routed_uri); } if (empty($this->location)) $this->location = $this->fuel->config('default_home_view'); $config = array(); $config['location'] = $this->location; if ($this->fuel->pages->mode() == 'views') { $config['render_mode'] = 'views'; $page = $this->fuel->pages->create($config); $this->_remap_variables($page); } // using FUEL admin else { if ($this->fuel->pages->mode() != 'cms') { $config['render_mode'] = 'auto'; if ($this->fuel->config('uri_view_overwrites')) { // loop through the pages array looking for wild-cards foreach ($this->fuel->config('uri_view_overwrites') as $val) { // convert wild-cards to RegEx $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $val)); // does the RegEx match? if (preg_match('#^' . $val . '$#', $config['location'])) { $config['render_mode'] = 'views'; } } } $page = $this->fuel->pages->create($config); if ((!$page->has_cms_data() AND $config['render_mode'] == 'auto') OR $config['render_mode'] == 'views') { $this->_remap_variables($page); return; } } else { $config['render_mode'] = 'cms'; $page = $this->fuel->pages->create($config); } $this->_remap_cms($page); } } }
  • edited 6:57PM
    did a little more debugging.
    The URL http://dev.feuerwehr-bs.de/technik/fahrzeuge/16 is working. Here in CodeIgniter.php line 403 $class= My_page_router and method = index
    The URL http://dev.feuerwehr-bs.de is not working. $class = "" and $method = "index"
    The URL http://dev.feuerwehr-bs.de/aktuelles/einsaetze/2922 is also not working. $class = "Einsaetze" $method = "2922".
    First and third URL should go through exact the same Routing...
  • edited 6:57PM
    How are those pages constructed, meaning are they pages with controllers, are they in the CMS or are they view files? Note that there were some changes made between 1.3.2 and 1.4 due to how CI 3 handles it's routing. Primarily, 1.3.2 had an extra hook called "pre_controller" that was called from the fuel/modules/fuel/hooks/Fuel_hook.php file that would check if a method didn't exist on a controller it would get routed to the 404 route (e.g. Page_router).
  • edited May 2017
    I am using several types of pages on my site:
    1. "normal" cms page created in the backend -> works fine
    2. "normal" cms page with additional controller (for form processing) -> page loading works fine but form submit fails in 404
    3. "module" cms page created in the backend but gets the content from simple modules -> some work, others not
    4. homepage cms page created in the backend but gets its content from a controller -> does not work

    I have created 2 layout libraries Main_layout and Module_layout. Main_layout handles type 1 + 2. Module_layout handles 3 + 4.

    The most strange thing at the moment for me is that http://dev.feuerwehr-bs.de/technik/fahrzeuge/16 is working and http://dev.feuerwehr-bs.de/aktuelles/einsaetze/2922 is not working. Both pages are handled via Module_layout. But the second one ends up in 404 before being routed to the layout library.

    What is the replacement for the Fuel_hook pre_controller? Where is that handled now?

    As I continue debugging I will just note here all things I find as difference between the two mentioned pages.

    1. in fuel/core/Router.php: I added a var_dump and die for $segments in line 183 just before $this->_set_rsegments call. The working page does not pass this line of code, the not working page stops here with:
    array(2) { [0]=> string(9) "einsaetze" [1]=> string(4) "2922" }
    UPDATE: ok... for this page I got a little bit further... I have a page aktuelles/presse which has a form, which is handled by a controller method... because of this I have a subfolder aktuelles in my application/controller folder. Now fuel/core/Router.php line 282 finds this subdirectory and removes the array key with the subfolder name from the $segments array.
    I got it working with following code:
    /* application sub-directory controller exists? */ if ($directory) { if (is_file(APPPATH . 'controllers/' . $module . '/' . ucfirst($directory) . $ext)) { $this->directory = $module . '/'; return array_slice($segments, 1); } /* application sub-sub-directory controller exists? */ if ($controller) { if (is_file(APPPATH . 'controllers/' . $module . '/' . $directory . '/' . ucfirst($controller) . $ext)) { $this->directory = $module . '/' . $directory . '/'; return array_slice($segments, 2); } } } else { /* application controllers sub-directory exists? */ if (is_dir(APPPATH . 'controllers/' . $module . '/')) { $this->directory = $module . '/'; return array_slice($segments, 1); } } /* application controller exists? */ if (is_file(APPPATH . 'controllers/' . ucfirst($module) . $ext)) { return $segments; }
    I added an else branch to check for sub-directory only if $directory is empty. Now type 3 works for all pages. I go on checking for type 2 and 4

    UPDATE 2: I think the issue was that my controllers where also named lowercase and not with first letter in UC... I go on checking...
  • edited 6:57PM
    yes... that did it... so only change is the else statement.
    Do you think this causes problems in other scenarios?
  • edited 6:57PM
    had to make some adjustments in the form module... Controller and Models had also not a UC first char
  • edited 6:57PM
    Ok. was not the whole solution...
    I have another page feuerwehr-bs.de/aktuelles which is defined as redirect to feuerwehr-bs.de/aktuelles/news in the cms... because I have the folder aktuelles in controllers this results in 404...
    keep on checking ;-)
  • edited 6:57PM
    hmmm what exactly should the check "application controllers sub-directory exists?" achieve?
    On uncommenting the whole block
    //else { // /* application controllers sub-directory exists? */ // if (is_dir(APPPATH . 'controllers/' . $module . '/')) { // $this->directory = $module . '/'; // return array_slice($segments, 1); // } // }
    it worked for me...
    What should happen, if the controller directory exists, but no further parameters are given?
  • edited 6:57PM
    I'm a bit confused... those lines weren't commented out in the original FUEL code correct?
  • edited 6:57PM
    Hi,

    I've just updated to 1.4 and got assets output problem,
    when setting assets output to 'combine' or TRUE :

    <?=css($css, null, array('output' => 'combine')); ?>

    I get the broken link:
    /assets/807e9bc71a0de8c3bae403db24394c75_.css

    it should be like this:

    /assets/cache/807e9bc71a0de8c3bae403db24394c75_.css

    in app/config/asset.php got this line:
    $config['assets_cache_folder'] = 'cache/';

    but cache folder steel don't appear in link path
  • edited 6:57PM
    Try changing it to without the ending slash:
    $config['assets_cache_folder'] = 'cache';
  • edited 6:57PM
    Unfortunately it did not help.

    No matter what value the variable has, the path remains unchanged.
  • edited 6:57PM
    Are you having this problem with a fresh version of 1.4?
  • edited 6:57PM
    No, the problem appeared after the update.
    I checked the behavior on a fresh version of 1.4 and there was no such problem.

    It turned out that problem was in config file app/config/asset.php,
    my version had this var:
    $config['assets_folders'] = array( 'images' => 'images/', 'css' => 'css/', 'js' => 'js/', 'pdf' => 'pdf/', 'swf' => 'swf/', 'media' => 'media/', 'captchas' => 'captchas/', 'docs' => 'docs/', );

    and it should be:
    $config['assets_folders'] = array( 'images' => 'images/', 'css' => 'css/', 'js' => 'js/', 'pdf' => 'pdf/', 'swf' => 'swf/', 'media' => 'media/', 'captchas' => 'captchas/', 'docs' => 'docs/', 'cache' => 'cache/' );

    My bad, sorry.

    Thanks for help!
  • edited 6:57PM
    Hey, speaking of assets, I'm wondering if you might know what's causing the "The filetype you are attempting to upload is now allowed" error?

    I just got into the CI->Upload.php file and in the function is_allowed_filetype I changed $ignore_mime to TRUE and it was able to upload, so for some reason, it's not passing something into that method properly after my upgrade from 1.3 to 1.4.

    Any ideas? I can leave the $ignore_mime as TRUE for my purposes, but I would be curious of an answer :)

    Thanks.
  • edited June 2017
    Hi,
    sorry I had no time to answer for 2 weeks...
    Coming back to my confusing posts :-)

    This is your Router.php
    /* application sub-directory controller exists? */ if($directory) { if(is_file(APPPATH.'controllers/'.$module.'/'.ucfirst($directory).$ext)) { $this->directory = $module.'/'; return array_slice($segments, 1); } /* application sub-sub-directory controller exists? */ if($controller) { if(is_file(APPPATH.'controllers/'.$module.'/'.$directory.'/'.ucfirst($controller).$ext)) { $this->directory = $module.'/'.$directory.'/'; return array_slice($segments, 2); } } } /* application controllers sub-directory exists? */ if (is_dir(APPPATH.'controllers/'.$module.'/')) { $this->directory = $module.'/'; return array_slice($segments, 1); } /* application controller exists? */ if (is_file(APPPATH.'controllers/'.ucfirst($module).$ext)) { return $segments; }

    My adjusted file:
    /* application sub-directory controller exists? */ if ($directory) { if (is_file(APPPATH . 'controllers/' . $module . '/' . ucfirst($directory) . $ext)) { $this->directory = $module . '/'; return array_slice($segments, 1); } /* application sub-sub-directory controller exists? */ if ($controller) { if (is_file(APPPATH . 'controllers/' . $module . '/' . $directory . '/' . ucfirst($controller) . $ext)) { $this->directory = $module . '/' . $directory . '/'; return array_slice($segments, 2); } } } /* application controller exists? */ if (is_file(APPPATH . 'controllers/' . ucfirst($module) . $ext)) { return $segments; }

    My application/controllers directory has following content:
    aktuelles/Presse.php
    mission_admin/Mission_admin.php
    terminimport/Terminimport.php
    Homepage.php
    Impressum.php
    Kontakt.php
    Maintenance.php
    MY_page_router.php
    Ticketshop.php

    In my CMS I have a page defined as redirect with the route "aktuelles".
    Now with your code the check "application controllers sub-directory exists?" finds the subdirectory and redirects to 404 page. By removing the check I achieved, that my scenario works.

    KR
    Habib
  • edited 6:57PM
    edival, what filetype are you trying to upload and is the mime type specified correctly in the fuel/application/config/mimes.php file?
  • edited 6:57PM
    It's just a standard JPG image and as far as I can tell from looking at the config files, I haven't made any adjustments. The /fuel/modules/fuel/config/fuel/fuel.php file has the following and I haven't updated it in any of my config files:
    $config['editable_asset_filetypes'] = array( 'images' => 'jpg|jpeg|jpe|gif|png|zip|svg', 'pdf' => 'pdf|zip', 'media' => 'mov|mp3|aiff|mpeg|zip', 'assets' => 'jpg|jpeg|jpe|png|gif|mov|mpeg|mp3|wav|aiff|pdf|css|zip|svg' );
  • edited 6:57PM
    edival,

    There are 2 places in the code where that error can be thrown. One is in the CI_Upload class itself. The other is in the Fuel_assets::upload() method around line 166. Is the error being thrown there?
Sign In or Register to comment.