Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

404 on backend admin #15

Closed
zomars opened this issue Sep 13, 2017 · 8 comments
Closed

404 on backend admin #15

zomars opened this issue Sep 13, 2017 · 8 comments

Comments

@zomars
Copy link

zomars commented Sep 13, 2017

I get my site's 404 when trying to open the extension route: /bolt/extend/tinypng/files

@cdowdy
Copy link
Owner

cdowdy commented Sep 13, 2017

Have you updated to the latest? Should be fixed by #12

@cdowdy
Copy link
Owner

cdowdy commented Sep 13, 2017

And I just realized I still have the old version compare in the route checker too... Are you on 3.3 or 3.2?

@zomars
Copy link
Author

zomars commented Sep 14, 2017

I'm on 3.2.11 and I'm afraid I can't do composer update ATM. I'm afraid it will break because of local extensions.

@cdowdy
Copy link
Owner

cdowdy commented Sep 14, 2017

Ok what version of the extension are you on? If you can't update can apply the changes manually? If so I'll paste right here what you'll need to change

Who woulda thought bolt changing the backed extension mount point would cause so much havoc haha

@zomars
Copy link
Author

zomars commented Sep 14, 2017

I'm on 1.1.1 :)

@cdowdy
Copy link
Owner

cdowdy commented Sep 14, 2017

Ok if you can go to this line

'/extensions/tinypng' => new TinyPNGBackendController($config),
and reverse them. That is

  

        if ( Version::compare('3.3.0', '>=')) {
            return [
                '/extend/tinypng' => new TinyPNGBackendController($config),
            ];
        } else {
            return [
                '/extensions/tinypng' => new TinyPNGBackendController($config),
            ];
        } 

For some reason the logic is reversed and I'll get an actual update for the extension tomorrow to fix it properly!

@cdowdy
Copy link
Owner

cdowdy commented Sep 14, 2017

second thought I decided to fire up my laptop and the version compare for bolt is still really wonky.

For your use case on bolt 3.2.x you can use this for a quick fix:

in this method:

protected function registerBackendControllers() {
$config = $this->getConfig();
if ( Version::compare('3.3.0', '>=')) {
return [
'/extensions/tinypng' => new TinyPNGBackendController($config),
];
} else {
return [
'/extend/tinypng' => new TinyPNGBackendController($config),
];
}
}

protected function registerBackendControllers() {
  $config = $this->getConfig();
  
    return [
      '/extend/tinypng' => new TinyPNGBackendController($config),
    ];
}  

I'm putting the below here so I can think it out haha....

when getting the file path for both bolt 3.2.x and 3.3.x we need to do a version compare and reverse the logic.

That means instead of thinking the below code says "my current bolt version is greater than or equal too 3.3.0" with a bolt install of 3.3.0

if (Version::compare( '3.3.0', '>=')) {
  // the new filepath for bolt 3.3 +
  return $this->app['path_resolver']->resolve('files');
} else {
  // the old resources for bolt less than 3.3 so anyting 3.2 or "older" 
    return $this->app['resources']->getPath( 'filespath' );
 }  

we need to flip it:

if (Version::compare( '3.3.0', '>=')) {
  return $this->app['resources']->getPath( 'filespath' );
} else {
  return $this->app['path_resolver']->resolve('files');
 }  

For some reason the same 'reversed' logic isn't working to register a backend controllers route

@cdowdy
Copy link
Owner

cdowdy commented Sep 14, 2017

hey @zomars I think I knocked this one out ... I'll put a release out here in a bit if you could try it out and let me know that'd be great! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants