bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

404 if installed in userdir #691

Closed rompcik closed 10 years ago

rompcik commented 10 years ago

Starting with release 3.3.0, f3 raises a 404 if installed in userdir. Seems it handles the URL wrong (maybe the tilde??). Currently installed in public_html/f3 of user luke, .htaccess RewriteBase set to /~luke/f3/ -> 404 The error comes from somewhere in the foreach ($this->hive['ROUTES'] as $url=>$routes) in base.php, $allowed is always false in this case. Release 3.2.2 does not have this failure.

ikkez commented 10 years ago

Maybe related to https://github.com/bcosca/fatfree/issues/291 Do you run a HTTP/1.1 Server?

rompcik commented 10 years ago

@ikkez: First of all: do not mix topics. We are talking about the Uniform Resource Identifiers (URI), described in RFCs 2396, 3986. You are talking about HTTP Protocol, which uses the URI, but is a totally different topic. But at one thing you are correct: the bug is somewhat related. But as the mentioned old bug was fixed about 2013, it cannot be the one we suffer from now. As mentioned, with release 3.2.2 everything runs fine. From 3.3.0 on, it goes wrong. Try yourself: Install a 3.3.0-release under userdir and adjust .htaccess. Bug confirmed in following envs: Apache 2.4.10 / PHP 5.6.0 Arch Linux & Apache 2.4.9 / PHP 5.5.17 Windows 7

ikkez commented 10 years ago

i was just asking that because it was part of the other issue (encoding base path), but nevermind. I had a look at the current dev code, https://github.com/bcosca/fatfree/blob/dev/lib/base.php#L1777 For me it looks like the changes in that line from #291 had be reverted somehow. https://github.com/bcosca/fatfree/commit/c415e4850458f7babc8c9bb448bca9f52eab4df9#diff-3267a2e9d16decfe96b1574917f584dbL1427 I can't recall what happend or what is the right way. Why not install it in /var/www/ :stuck_out_tongue_closed_eyes:

MINORITYmaN commented 10 years ago

@ikkez probaply cuz its not the first revert

offtop: ich dachte immer blaue frösche sind "cool" wie trockeneis, scheint dem nicht so, kermit ftw.

rompcik commented 10 years ago

Hi guys, thanks for your investigations, hinting to the right direction. I'll check the constructor and hive.... @MINORITYmaN (offtopic): bluefrogs are poison dart frogs, sometimes they can be dangerous...

MINORITYmaN commented 10 years ago

offtop: Leimadophis epinephelus don't caresimmer freundlich bleiben ;) mfg, der mit den reptilien aufwuchs

MINORITYmaN commented 10 years ago

hmm, template test nr 61 on 3.3.1 returns false $tpl->render('templates/test12.htm')== '<test><ok><ok>' // false maybe same core problem?

ikkez commented 10 years ago

Template Test 61 is about to fail on PHP < 5.4 and that is known. That's due to the fact that ReflectionClass->isCloneable isn't there in 5.3, which means the escape mechanism escapes the real object instead of a copy of it.

MINORITYmaN commented 10 years ago

ok, next question 3.3.1/web nr 18 working fine at your env? i got here false too, so i var_dumped it like this

var_dump(
    is_array($rss=$web->rss(
        $url='http://wordpress.org/news/feed/')),
    'RSS feed ('.$url.') '.
    round(1e3*(microtime(TRUE)-$now),1).' msecs'
);

3 requests? the last one false dump of last request

  ["headers"]=>  array(17) {
    [0]=>    string(30) "HTTP/1.1 302 Moved Temporarily"
    [1]=>    string(13) "Server: nginx"
    [2]=>    string(35) "Date: Thu, 25 Sep 2014 08:45:14 GMT"
    [3]=>    string(23) "Content-Type: text/html"
    [4]=>    string(19) "Content-Length: 154"
    [5]=>    string(17) "Connection: close"
    [6]=>    string(42) "Location: https://wordpress.org/news/feed/"
    [7]=>    string(15) "HTTP/1.1 200 OK"
    [8]=>    string(13) "Server: nginx"
    [9]=>    string(35) "Date: Thu, 25 Sep 2014 08:45:14 GMT"
    [10]=>   string(37) "Content-Type: text/xml; charset=UTF-8"
    [11]=>   string(17) "Connection: close"
    [12]=>   string(21) "Vary: Accept-Encoding"
    [13]=>   string(49) "X-Pingback: https://wordpress.org/news/xmlrpc.php"
    [14]=>   string(44) "Last-Modified: Thu, 18 Sep 2014 16:20:10 GMT"
    [15]=>   string(27) "X-Frame-Options: SAMEORIGIN"
    [16]=>   string(17) "X-nc: HIT lax 249"
  }
  ["engine"]=>  string(6) "stream"
  ["cached"]=>  bool(false)
}

bool(true)

string(55) "RSS feed (http://wordpress.org/news/feed/) 3966.2 msecs"
array(4) {
  ["body"]=>  string(154) "<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
"
  ["headers"]=>
  array(7) {
    [0]=>    string(30) "HTTP/1.1 302 Moved Temporarily"
    [1]=>    string(13) "Server: nginx"
    [2]=>    string(35) "Date: Thu, 25 Sep 2014 08:45:18 GMT"
    [3]=>    string(23) "Content-Type: text/html"
    [4]=>    string(19) "Content-Length: 154"
    [5]=>    string(17) "Connection: close"
    [6]=>    string(42) "Location: https://wordpress.org/news/feed/"
  }
  ["engine"]=>  string(6) "socket"
  ["cached"]=>  bool(false)
}
bool(false)
ikkez commented 10 years ago

this is getting offtopic now :D but no, it also fails here in my php 5.5 dev env. much more critial is, that i pull the last changes now to my php 5.3 server, that instantly died now :D

MINORITYmaN commented 10 years ago

"this is getting offtopic now :D" i know but i just dont wanted to start a new issue if this isnt a real one. ;) btw my test server runs PHP version 5.3.28 with no greater problems

ikkez commented 10 years ago

well maybe wordpress just changed the URI? visit us as #fatfree in freenode IRC. there we can talk about your frogs and all those things :D And it won't be that silent there anymore ^^

MINORITYmaN commented 10 years ago

-lach

rompcik commented 10 years ago

After your odyssey I'd like to come back to the topic. Indeed the constructor has been the ugly guy, reverting from line 1656 of base.php from $base=implode('/',array_map('urlencode', explode('/',rtrim($this->fixslashes( dirname($_SERVER['SCRIPT_NAME'])),'/')))); to $base=$this->fixslashes(dirname($_SERVER['SCRIPT_NAME'])); fixes the issue. So we can close the bug.

ikkez commented 10 years ago

hi @rompcik. as long as the commit which fixes the issue hasn't been pushed you should not close the issue. It could be forgotten. Regarding your "investigation", well F3 is a toolkit... use it for whatever structure you like.. F3's Base is just a simple Router, which is only some kind of FrontController... that's why it's your job to create your MVC, HMVC or RMR structure around it... or if you like just a procedural single file app (think about jQuery for JS). All other classes are just plugins/addons. Delete them if you don't need them. Well i don't want to argue about code style with you, and neither me have written the code, nor i know what kind of PHP features you mean, but what i can say is that i was always fascinated about how much things are solved in so less lines of code. You may think it's not clean, i think It's compressed love in detail. And also performs just awesome. And like the main quote says "F3 aims to be usable - not usual." Regarding your other concern about the off-topic thing - well you are probably right, and even if i don't start with blue frogs or something, let me say that this usually does not happen. we just had a great day with lots of enthusiasm ^^

MINORITYmaN commented 10 years ago

@ikkez :+1: :+1:

rompcik commented 10 years ago

Comment edited.

bcosca commented 10 years ago

Fixed. I should have used rawurlencode(), not urlencode().

rompcik commented 10 years ago

Thx. :+1: And sorry to have bothered you.