1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Roadmap Version 1.8

Discussion in 'RoadMap' started by shibuya246, Dec 11, 2014.

  1. valMETNG

    valMETNG Administrator Staff Member Admin

    It seems the reason it has a 0 is because when function getUser in libs/UserBase.php runs, it comes in with $userid defined. But when it makes the call on line 252:
    Code:
    $this->settings = $this->getProfileSettingsData($h, 'user_settings', $this->id);
    ...$this->id equals 0. So you probably want to call this function with $user_info->user_id (defined on line 221) instead of $this->id.
     
  2. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    those are the best errors. reward yourself with 2 drinks at least
     
  3. valMETNG

    valMETNG Administrator Staff Member Admin

    How do you think my code got as messed up as it did in the first place?
     
    shibuya246 likes this.
  4. valMETNG

    valMETNG Administrator Staff Member Admin

    A proposal for getting a little crazy...

    To put it mildly, I've always been unhappy with the way Hotaru did its .htaccess file. I've customized my build to allow for many levels of subcategories (and then you could have parts after that, like alerts for example). But that means you have to use rewrite rules that are not only very complex but still limit the slashes in your URL - e.g.:
    Code:
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10&$11=$12&$13=$14&$15=$16 [L]
    I think it's time to get away from this in .htaccess. Taking a queue from here, I'd like to suggest as a starting point that we replace everything in the generic rules portion of .htaccess with:
    Code:
    ##### GENERIC RULES #####
    RewriteRule \.(css|php|png|jpg|gif|ico|js|inc|txt|gz|xml|html|zip)$ - [NC,L]
    RewriteRule ^(.*)$ index.php?page=$1
    That would make $_GET for something like http://mysite.com/category/wall/shibuya246/htaccess-improvements/alert/2 turn into:
    Code:
    Array ( [page] => category/wall/shibuya246/htaccess-improvements/alert/2 )
    From there, we just parse in PHP. I'm not sure the best place to do it, but I assume function makeGetCage (line 138 of libs/extensions/Inspekt/Inspekt.php) has potential - e.g.:
    Code:
    static public function makeGetCage($config_file=NULL, $strict=TRUE) {
      /**
      * @staticvar $_instance
      */
      static $_instance;
      if (!isset($_instance)) {
         $get = $_GET;
         $new_get = array();
         if ($get && isset($get['page']))
         {
           $parts = explode('/', $get['page']);
           if ($parts)
           {
             foreach ($parts as $key => $value)
             { $new_get[$key] = $value; }
           }
         }
    
      $_instance = Inspekt_Cage::Factory($new_get, $config_file, '_GET', $strict);
      }
      $GLOBALS['HTTP_GET_VARS'] = NULL;
      return $_instance;
      }
    I haven't fully worked through it or tested it, but wanted to get some thoughts on the idea. As far as I can tell, we wouldn't have to do the same with $_POST as that doesn't get touched by those .htaccess rules.

    This would give us a whole lot more flexibility going forward as to what we can put into the URL.
     
    Last edited: Jan 30, 2015
    shibuya246 likes this.
  5. valMETNG

    valMETNG Administrator Staff Member Admin

    Well, that totally didn't work :)
     
  6. valMETNG

    valMETNG Administrator Staff Member Admin

    I need to more fully test it, but this does seem to work:

    .htaccess
    Code:
    ##### CORE ADMIN #####
    RewriteRule ^admin/?$ admin_index.php [L]
    RewriteRule ^admin/([a-zA-Z0-9_-]+)/?$ admin_index.php?page=$1 [L]
    RewriteRule ^admin/plugin_settings/plugin/([a-zA-Z0-9_-]+)/?$ admin_index.php?page=plugin_settings&plugin=$1 [L]
    
    ##### GENERIC RULES #####
    RewriteRule \.(css|php|png|jpg|gif|ico|js|inc|txt|gz|xml|html|zip)$ - [NC,L]
    RewriteRule ^(.*)$ index.php?index_page=$1 [L]
    function makeGetCage
    Code:
      static public function makeGetCage($config_file=NULL, $strict=TRUE) {
         /**
          * @staticvar $_instance
          */
         static $_instance;
    
         if (!isset($_instance)) {
           $get = $_GET;
           $new_get = array();
           if ($get && isset($get['index_page']))
           {
             $parts = explode('/', $get['index_page']);
             $parts_count = count($parts);
             $i = 0;
    
             if ($parts)
             {
               do
               {
                 $key = isset($parts[$i]) ? $parts[$i] : false;
                 $value = isset($parts[$i + 1]) ? $parts[$i + 1] : '';
    
                 if ($key) { $new_get[$key] = $value; }
    
                 $i = $i + 2;
               } while ($i < $parts_count);
             }
    
             $_instance = Inspekt_Cage::Factory($new_get, $config_file, '_GET', $strict);
           } else { $_instance = Inspekt_Cage::Factory($_GET, $config_file, '_GET', $strict); }
         }
         $GLOBALS['HTTP_GET_VARS'] = NULL;
         return $_instance;
       }
    I left admin as it is, but that's something that could be changed in the future as well.
     
    shibuya246 likes this.
  7. valMETNG

    valMETNG Administrator Staff Member Admin

    Slight modification if there is only one part in the URL (for calls like /login, /logout, /register):
    Code:
      static public function makeGetCage($config_file=NULL, $strict=TRUE) {
         /**
          * @staticvar $_instance
          */
         static $_instance;
    
         if (!isset($_instance)) {
           $get = $_GET;
           $new_get = array();
    
           if ($get && isset($get['index_page']))
           {
             $parts = explode('/', $get['index_page']);
    
             // remove blanks (e.g., from the last slash)
             $parts = array_filter($parts);
    
             $parts_count = count($parts);
             $i = 1;
    
             if ($parts)
             {
              // make first part page if not certain pages
               $no_page = array('apiAuth', 'user');
               if (in_array($parts[0], $no_page) && $parts > 1)
               {
                 $new_get[$parts[0]] = $parts[1];
                 $i++;
               }
               else { $new_get['page'] = $parts[0]; }
    
               do
               {
                 $key = isset($parts[$i]) ? $parts[$i] : false;
                 $value = isset($parts[$i + 1]) ? $parts[$i + 1] : '';
    
                 if ($key) { $new_get[$key] = $value; }
    
                 $i = $i + 2;
               } while ($i < $parts_count);
             }
    
             $_instance = Inspekt_Cage::Factory($new_get, $config_file, '_GET', $strict);
           } else { $_instance = Inspekt_Cage::Factory($_GET, $config_file, '_GET', $strict); }
         }
         $GLOBALS['HTTP_GET_VARS'] = NULL;
         return $_instance;
       }
    
    There's probably a less kludgy way of doing this but only if PageHandling.php gets re-worked.

    Edits: Changes to code. Also didn't realize API works differently. Another edit as user is a specific case (like api) where we don't want a page. (What other ones am I missing?)
     
    Last edited: Feb 3, 2015
    shibuya246 likes this.
  8. valMETNG

    valMETNG Administrator Staff Member Admin

    I might be a bit too hung up on this cycling thing. Maybe there's a pill I could take...

    I put the following code on line 132 of libs/PageHandling.php:
    Code:
    print "<br/>".__METHOD__."<br.>";if (!isset($h->vars['cycle'])) $h->vars['cycle'] = 0;$h->vars['cycle']++;
    I added code to line 160 so it looks like this:
    Code:
    $index = ($h->home) ? $h->home : ''; print "<br/>index =".$index;if ($h->vars['cycle'] > 3) throw new \Exception('throwing exception');
    The result for going to the home page is as follows:
    This means it cycles 4 times before it finally gets pageName. I don't understand why, after the first run-through, we can't immediately assign it popular as we know there's nothing in the URI.
     
  9. valMETNG

    valMETNG Administrator Staff Member Admin

    I'm somewhat beside myself on this one. After multiple days trying to figure it out, could use some help. I can force a kludge if it isn't resolved, but I'd rather figure out the underlying problem. (I saw this problem back in 1.5 and just kludged it then when I couldn't resolve.)

    In general, some javascript files in their plugin folders don't always load. This includes the javascript file in the theme folder. It might be a caching problem, because I can sometimes get them to load after clearing the server and local caches, but not always. Sometimes they load until a plugin is uninstalled or reinstalled, and then they stop. And some plugins load the javascript files no matter what. (The hotaru.js file seems to never load.)

    I checked on ipadrank and hotaru.js is loading there (e.g., the forgot your password dropdown on the login form works). Can a few of you check your builds to see if the password dropdown works on your /login page (click "Forgot your password?")? If you see the enter your email address field, it's working.

    If I could just figure out what's causing hotaru.js not to load in a base install, that would likely lead to solving the other plugin problems. @shibuya246, any thoughts as to what would cause the .js files not to be picked up (especially hotaru.js)? I've spent many hours looking through libs/IncludeCssJs.php. It appears the cached hotaru_js file isn't refreshing based on header_include calls, although the hotaru_css is. For example, I have a plugin that includes the following:
    Code:
      public function header_include($h)
      {
      if (strpos($h->pageName, 'subscribe') === false) { return false; }
      $h->includeCss();
      $h->includeJs();
      }
    The header_include does get executed and the css is updated (although not via Libs\Hotaru::header_include - more on this in a minute), but the js is not. Only when I clear the cache from admin do I then see the updated js (sometimes). I don't understand why this is happening but, when I put print statements into function combineIncludes in libs/IncludeCssJs.php, I notice that, upon each refresh of the page, the particular plugin isn't in the includes array. This is likely because it's also not in $this->jsIncludes (assigned in function getJsIncludes).

    I then traced all header_include calls and found that not all header_includes are being called via function header_include in Hotaru.php. For example, comments has this:
    Code:
      public function header_include($h)
      {
      $h->includeCss('comments', 'comments');
      $h->includeJs('comments', 'urldecode');
      $h->includeJs('comments', 'comments');
      }
    What's odd is that, although Libs\IncludeCssJs::includeCss is executed for comments, it isn't executed via function header_include in Hotaru.php. So I'm not sure how it's even being called. I put prints into Libs\Hotaru::header_include, Libs\IncludeCssJs::includeCss, and Libs\IncludeCssJs::includeJs. This is part of what the prints show to give you an idea:
    Code:
    Libs\Hotaru::header_include
    variable =
    string(5) "users"
    Libs\IncludeCssJs::includeJs
    variable =
    string(87) "[directory_path/content/plugins/users/javascript/users.js"
    Libs\IncludeCssJs::includeCss
    variable =
    string(81) "[directory_path/content/plugins/users/css/users.css"
    Libs\Hotaru::header_include
    variable =
    string(6) "submit"
    Libs\IncludeCssJs::includeJs
    variable =
    Libs\IncludeCssJs::includeCss
    variable =
    string(83) "[directory_path/content/plugins/submit/css/submit.css"
    Libs\IncludeCssJs::includeCss
    variable =
    string(87) "[directory_path/content/plugins/comments/css/comments.css"
    Libs\IncludeCssJs::includeJs
    variable =
    string(94) "[directory_path/content/plugins/comments/javascript/urldecode.js"
    Libs\IncludeCssJs::includeJs
    variable =
    string(93) "[directory_path/content/plugins/comments/javascript/comments.js"
    Libs\IncludeCssJs::includeJs
    variable =
    string(97) "[directory_path/content/plugins/categories/javascript/suckerfish.js"
    Libs\IncludeCssJs::includeCss
    variable =
    string(91) "[directory_path/content/plugins/categories/css/categories.css"
    Libs\Hotaru::header_include
    variable =
    string(6) "search"
    Libs\IncludeCssJs::includeJs
    variable =
    Libs\IncludeCssJs::includeCss
    variable =
    string(83) "[directory_path/content/plugins/search/css/search.css"
    So you can see that, sometimes header_include brings the css/js in and sometimes it doesn't (e.g., how did categories css and js get pulled in without being called by Libs\Hotaru::header_include?). I haven't any idea why. I also confirmed hooks (e.g., both submit and comments have a row in table hotaru_pluginhooks for header_include; yet submit seems to get executed via Libs\Hotaru::header_include and comments gets executed some other way because there isn't a print reference to Libs\Hotaru::header_include.)

    Where is Libs\IncludeCssJs::includeJs being called from if not Libs\Hotaru::header_include? Or is there some kind of chain that happens (e.g., if submit is loaded, comments and categories must also be loaded)?
     
  10. valMETNG

    valMETNG Administrator Staff Member Admin

    I believe text/css is unnecessary on line 1380 of Hotaru.php:
    Code:
    echo "<script type='text/javascript' src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js' type='text/css' /></script>";
     
  11. valMETNG

    valMETNG Administrator Staff Member Admin

    On line 80 of content/plugins/user_signin/user_signin_login.php, I believe the 'for' should be 'email':
    Code:
      <label for="signinemail"><?php echo $h->lang["user_signin_account_email"]; ?></label>
      <input type='text' size=30 name='email' value='<?php echo $email_check; ?>' />
     
  12. valMETNG

    valMETNG Administrator Staff Member Admin

    Sigh. I just don't get it. I cleared the cache again and now I can't duplicate the problem. Even hotaru.js is loading. Sometimes I clear the cache and see the problem, and sometimes I don't see it. I can't pin down under what circumstances this occurs. Anyway, unless you have a quick answer, better not to waste your time with it.
     
  13. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    I dont have a good answer for this one, but some sites recommend having the type in all script calls

    https://developer.mozilla.org/en-US...uring_your_site/Configuring_server_MIME_types

     
  14. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    When you look in inspect element of chrome browser do you see any js files broken. if so they would block the others from loading properly

    I have had a cold recently so just catching up now
     
  15. valMETNG

    valMETNG Administrator Staff Member Admin

  16. valMETNG

    valMETNG Administrator Staff Member Admin

    I didn't see anything. I think it has something to do with caching, but I'm kind of tired of looking at it :) I put a kludge in and I'll keep monitoring. Too many other things to do. Wishes for a speedy recovery.
     
  17. valMETNG

    valMETNG Administrator Staff Member Admin

    I don't remember if I mentioned this one or not, so apologies if it's a duplicate. I believe line 724 of plugins/user_manager/user_manager_settings.php should be getUser instead of getUserBasic:
    Code:
    $userAuth->getUserBasic($h, 0, $username);
     
  18. valMETNG

    valMETNG Administrator Staff Member Admin

    On line 375 of libs/UserBase.php, I believe you don't want to send the $h as a parameter to the function:
    Code:
    $h->getUser($h, $h->currentUser->id, '', true);  // re-read the database record to get updated info
     
  19. valMETNG

    valMETNG Administrator Staff Member Admin

    As users aren't allowed to update usernames, we shouldn't be doing the username check that starts at line 325 in libs/UserBase.php:
    Code:
          $username_check = $h->cage->post->testUsername('username'); // alphanumeric, dashes and underscores okay, case insensitive
           if (!$username_check) {
             $h->messages[$h->lang('main_user_account_update_username_error')] = 'red';
             $error = 1;
           } elseif($h->nameExists($username_check, '', $viewee->id) || $h->isBlocked('user', $username_check)) {
             $h->messages[$h->lang('main_user_account_update_username_exists')] = 'red';
             $error = 1;
           } else {
             //success
             $viewee->name = $username_check;
           }
     
  20. valMETNG

    valMETNG Administrator Staff Member Admin

    We should not be updating the password when a user only changes his email address on line 406 of libs/UserBase.php:
    Code:
    $this->updatePassword($h, $userid);
     

Share This Page