Updated Model.php File - Changes dont show

tajhay

Well-known member
Hi guys,
I am trying to update the Model.php file for a custom addon i had someone develop for me. I wanted to update the sort order in the Model.php file for the addon. Everything looks good and i have checked on phpmyadmin with the generated SQL that it should now be sorting the records correctly.

However when i go back to the addon view, the sort order does not seem to have changed. Do i need to do something to invoke the changes? Perhaps restart the VPS? Rebuild the caches - i dont think a cache for the addon exists. Any help would be greatly appreciated :)
 
Make sure the php code is being reloaded. Aka don't mess with 'opcache.revalidate_freq' php.ini setting, as it leads to weird and difficult to understand error cases.

Otherwise, put a print statement in and make sure you code is actually being executed.
 
Thanks Xon, im not actually a developer...just trying to correct some code by the addon developer:
Code:
public function getSeasonGameInfo($playerName, $from, $to) {
        $db = $this->_getSourceDb();
        static $results = array();
      
        $queryResult = $db->query('
            SELECT  stats.*, details.round, details.venue, details.date
            FROM player_stats AS stats
                INNER JOIN match_details AS details ON (stats.match_id = details.match_id)
            WHERE stats.name = ?
                AND details.date > ?
                AND details.date < ?
                 ORDER BY stats.match_id ASC
        ', array($playerName, $from, $to));

        $i = 0;
        while ($row = $queryResult->fetch())
        {
            $i++;
            $results[isset($row['id']) ? $row['id'] : $i] = $row;
        }

The only thing changed in the model is the addition of :
"ORDER BY stats.match_id ASC"

What would i need to put in the called template to spit out the sql code?
 
Last edited:
Additionally the code is executed within a tab (of about 10) on the page...so debug doesnt show the sql query for the tab

If theres a way to print out the sql that is being executed im all ears.
 
The tab will be calling a URL.

In the content that loads inside the tab, on your browser right click and select Inspect Element. Work up the code from there and you should see an <li> element with a data-loadurl attribute.

That is the URL that tab is getting its content from.

You can go to that URL directly in your browser and from there you can see the SQL queries executed on that page.

However, the point Xon is making is valid. If that setting in php.ini has a value of 0 then changes to files won't actually take effect until the cache is cleared.
 
Thanks Chris.

Still cant see the sql query even when i go and debug the following page mate.

(debug has been enabled at the bottom)
Code:
http://www.nzwarriors.com/player-profiles/roger-tuivasa-sheck.336/?f=2015-01-01&t=2015-12-31#stats-3

Can see for yourself...no queries mentioning 'stats' as per my sql query above.

Is there anyway i can invoke a clearing of the cache?
 
I suspect you are looking at the wrong URL. The correct URL will only load the contents of the stats tab and not the rest of the profile page.

Another way will be to right click and view source of the page and search for "data-loadurl". There may be a few in the source but one of the specifically is the URL for the data loaded into the tab.

Is the value of that setting in php.ini 0? You can check in phpinfo to be sure.
 
I suspect you are looking at the wrong URL. The correct URL will only load the contents of the stats tab and not the rest of the profile page.
its only outputting the stats tab mate...the rest of the profile is above the tabs.

data-loadurl"
found it...the url was slightly different.
Code:
http://www.nzwarriors.com/player-profiles/roger-tuivasa-sheck.336/player-rating?f=2015-01-01&amp;t=2015-12-31
When i go there...it says i dont have permission to view the page! lol

But that cant be right as i can see the stats via the following url that shows only that tabs info:
Code:
http://www.nzwarriors.com/player-profiles/roger-tuivasa-sheck.336/?f=2015-01-01&t=2015-12-31#stats-3
s the value of that setting in php.ini 0? You can check in phpinfo to be sure.
Its set as 60 mate. Is that 60 minutes? Maybe i just need to chillax for 60 mins and check again?
 
I still think you found the wrong URL.

This is the correct one which loads only the content for that tab (by which I mean, it doesn't load any of the surrounding profile or tab information):

http://www.nzwarriors.com/player-pr...ck.336/player-stats?f=2015-01-01&t=2015-12-31


I still can't see the query information from your post above, this would lead me to believe that either the add-on caches the data and you're seeing cached data on this page, or you've edited the wrong code. Looking at the queries that are on the page, I actually suspect the former - I think the add-on must be doing some caching internally.
 
Thanks Chris. Ill wait a day and hopefully the cache has been cleared and see how it goes.

Is there a way to invoke the clearing of cache manually? Perhaps restart the VPS?
 
The caching I was referring to was something integral to the add-on, so I'm unsure how long that would last for or how to clear it.

The opcode cache Xon and I were referring to doesn't seem to be at play here. In the list of queries on that page, the one you edited doesn't appear there at all (nothing similar either).

Generally, however, that would be cleared by restarting PHP/your web server (depending how it's set up). To answer your earlier question, the "60" is actually 60 seconds so if that ever was at play, the changes would have taken effect fairly quickly.
 
Restarting the vps (probably) won't do it because he's likely using either the "simple cache" system or the data registry model. In either case, it's logged in the database and not in system memory.

You would have to find out which method they're using and then we could force it to update. We're getting to the point now where we would need to see code though.

[Edit] Ninja'd
 
You would have to find out which method they're using and then we could force it to update. We're getting to the point now where we would need to see code though.
Where is the caching code generally written? Any hints so i could try to scan for it?
 
Where is the caching code generally written? Any hints so i could try to scan for it?
If you're using an IDE, you could probably do a "Find In Path" command for the word cache and find some results. Generally people would build their caching mechanisms into the model files though it could be in the controller.
 
thanks guys, i tried renaming the model.php file to model_backup.php and the page still worked (atleast after 10 mins later) so it does feel like some cache is in play...ive put it back to model.php now.

Ill wait out for a day to see if the changes made their way through or not.

Thanks @Chris D @Xon and @Daniel Hood
 
Back
Top Bottom