
celfred
Members-
Posts
195 -
Joined
-
Last visited
Everything posted by celfred
-
Last thing for the moment while trying to update to PW 3.x : in backend, my modulemanager page tries to read a modulemanager.cache file in files/assets/cache which doesn't exist hence error messages : Warning: fread(): Length parameter must be greater than 0 in /home/celfred/PlanetAlert/site/modules/ModulesManager/ModulesManager.module on line 812 ProcessWire: ModulesManager: cannot read cache file /home/celfred/PlanetAlert/site/assets/cache/ModuleManager.cache (with debug true)
-
Here's what I did : Restarted mysql to be back with the initial fatal error. Found out that commenting out the line : $allPlayers = $pages->find("template=player, team=$team, sort=group"); got rid of the error Replaced the line with : $allPlayers = $pages->find("template=player, team=$team")->sort("group"); and... It works That's indeed a cleaner solution better than changing my mysql settings. I guess the 'bug' was on my side with the 'sort' command included in my 'find' query. I have to revise the PW doc to see where I saw that syntax or if I made it up without noticing that it never worked (which is possible !). So thanks for pointing this out to me !
-
EDIT : As a follow-up, still digging on my updating issues : I have found that post : https://stackoverflow.com/questions/23921117/disable-only-full-group-by#36033983 Along with the namespace line on my particular page, it works EDIT #2 : Sorry ! I validated another post instead of editing the first one.
-
I must admit I'm completely lost on those issues. I have turned off the compiler on my first fatal error that occurred with another module : Pages2Pdf. As I said earlier, I downloaded the last Github version of that module and noticed in the source the FileCompiler=0 line, so I simply did the same in the Service Pages modules Now when trying to get rid of all lines (FileCompiler and namespace) it seems to work as well (?) . Maybe I'm still having a cache somewhere messing up with all my tests, but it seems to work anyway so that's good ! I am now continuing debugging my local site. I have to add the namespace line at some places to get rid of error messages. But all in all, it looks quite correct. One of my pages trigger a 'big' fatal error that is again over my head for the moment : Error: Exception: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'planetalert._sort_page_group_name.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (in /home/celfred/PlanetAlert/wire/core/PageFinder.php line 384) (The page worked fine with PW 2.8). But that's another problem and it's not on a 'major' page Thanks for your concern @adrian
-
So cool ! I can't believe it was so... simple... I added this line on my templates files, but didn't think it was needed in modules as well. Now, I'll try and face the other issues by myself, but it went a little further. That's cool ! Thanks a lot for your help !
-
Hello, I'm desperately trying to update my website to PW 3.0.62 and I'm facing issues to to module compatibility. I was stuck with Pages2Pdf which I managed to solve bu updating the module from Github, but now it's the Pages Web Service module... and this time, I don't know wht to do The Module is found there. But it is quite old and I can't find it in the modules catalogue... and my site is making quite a use of it (I can't think of a way to do otherwise, sorry...) After adding the FileCompiler=0 to the module pages, the error I'm stuck with is : Fatal error: Class 'WireData' not found in /home/celfred/PlanetAlert/site/modules/ServicePages/ServicePages.module on line 22 and I have no idea on what to do... I must admit I'm not a programmer but a middle-school teacher... (for your information, here's the site I'm talking about : http://planetalert.tuxfamily.org ) but I'm struggling hard to solve the different issues I have to face and I'm wlling to understand things. I have just spent many hours trying to make 2.8 work on my localhost (and it seems ok ) but I'd like to switch to 3.x to prepare the future If anyone had the will to spend a few minutes to try and help me, I would greatly appreciate. Thanks in advance ! If you need more information to understand my problem, feel free to ask.
-
I feel a little dumb once again... Your explanation is perfect and I guess I want the 2nd one. I think I was mistaken on that 'not()' filter. I'll have to check everywhere I've used it. The 'further filtered' was the key in your explanation. Thanks !
- 6 replies
-
- optimisation
- functions
-
(and 1 more)
Tagged with:
-
The $prevEvents->count() is fine. This part works as expected Your post reminded me of trying to cut down through my page to see where the ALL pages request was (ou could be), and reducing things little by little, I saw my checkStreak() function in which I look over the history of each player ti find if the last 10 consecutive events are positive, in which case the player becomes an 'AMbassador' and here was my code : $lastEvents = $player->get("name=history")->find("template=event, sort=-date")->not("task.name=donated|donation|absent, limit=10"); I bet you can see right through it : the 'limit=10' is misplaced and useless where it is !!! The code should be (I think) : $lastEvents = $player->get("name=history")->find("template=event, sort=-date, limit=10")->not("task.name=donated|donation|absent"); Now my 'loaded page' is reduced to about 480. What a gain ! And this checkStreak() function is called each time I save a new event for a player (to check if he needs to become an ambassador...) So I'll keep digging because I can imagine I have the same sort of mistake at other places, but I am already glad of this improvement. So thanks a lot !
- 6 replies
-
- optimisation
- functions
-
(and 1 more)
Tagged with:
-
Thanks @kongondo for the 1st tip. I get the difference between children('-date')->first() and child('-date'). Although I've just tried to change this line and nothing changed in my Tracy 'Processwire Debug' panel... still many many loaded pages... I'll dig that later when I have more time. Maybe I have the same kind of error somewhere else... About the date>=$prevDay : this solved an issue I had because of the time appended to the date. Actually in my code, I take the last event, get the date, change the time to 0:0:0 and eventually get the >= to find all those events having the same day, but with a superior time. Maybe (I'm sure actually...) there's a better solution. I remember at the time I implemented this, I was surprised not to be able to retrieve the same day events and this was the only workaround I found
- 6 replies
-
- optimisation
- functions
-
(and 1 more)
Tagged with:
-
Hello, I've been struggling ALL day on my loading time problem and I'm stuck... As I said somewhere else on the Forum, I'm discovering TracyDebugger module to try and help me (and it does help !), but I'm still in a dead-end. Tracy told me one of my page loads about 4,500 pages and I can't find any way to make it less (and let me tell you that my website is far from having so many users/visitors or whatever, it's just a teacher's website to try to work differently in class). I have a feeling I am mis-understanding some concepts here. The page can be seen there : http://planetalert.tuxfamily.org/players/4d (for example, but the problem is the same for all teams in my site). As you can see, there are many information on this page, but not that much either I guess for a computer, but it takes 20 seconds to load ! It feels like my page loads just about EVERYTHING that resides in the backend, but I just can't understand by looking a tmy code. For example, the little green and red circles next to the player's names show the actions that have been saved on the last day (so usually 3-5 actions at most, except for players doing online exercises who may have 10 actions). My query is : $lastEvent = $player->child("name=history")->children("sort=-date")->first(); // Get all events on same day $prevDay = date("m/d/Y", $lastEvent->date); $prevDate = $prevDay.' 0:0:0'; // Select events for the whole day $prevEvents = $player->child("name='history'")->children("date>=$prevDate"); $trend = ''; foreach ($prevEvents as $event) { $HP = $event->task->HP; $title = $event->task->title; if ($HP < 0) { $trendClass = 'negativeTrend'; } else { $trendClass = 'positiveTrend'; } if ($event->summary !== '') { $summary = ' ('.$event->summary.')'; } else { $summary = ''; } $trend .= '<span class="'.$trendClass.'" data-toggle="tooltip" data-html="true" title="'.strftime("%d/%m", $event->date).': '.$title.$summary.'"> </span>'; } But in Tracy pages, I see that the COMPLETE history for EACH player is loaded ! I thought my code was limiting it to the events appearing on the same day as the last saved event. Do you see where I am wrong ? What's more : I feel like I must do the same mistake for the players (they are all in althought I'm limiting to the particular team). I must say though, that I'm caching (supposively) ALL players when Admin is logged in so he can have a faster access in the top menu. More? All places and people that players can free are loaded as well. Why is this? I just want to load the places and people that are actually freed by players and show the names (not complete info). I'm not putting an example of the code here because I have a feeling the problem resides in my way of organising the complete thing... and that's what worries me the most... Maybe it's gonna be hard for one of you to understand (and have the time) my awkward way of organizing things (even though I'm trying hard to be well-organized ). So I'd rather point to the Github repository : https://github.com/celfred/PlanetAlertProfile/tree/master/site/templates The file I'm talking about above is team.inc.php. It is included in list-all.php which includes head.inc and foot.inc as well. Things have changed quite a bit on my local site today, but I'm getting in such a mess that I'd rather not commit to remote. I've corrected some things, but what I have just explained above is still there While I'm at it. Other page, other problem detected : my adminTable.php page which you can a look at at : http://planetalert.tuxfamily.org/players/adminTable/4d (I've just noticed that it should be acess restricted, but nevermind for today, don't submit just in case I forgot other things... _ yes, I'm desperate tonight...) and which submits to submitForms.php. Well, I had to put AJAX request for that because it was running into a timeout because of the loading time. It worked (althought I ended up waiting 30 seconds to record my table !) but today, Tracy and debug ON showed me the 'Maximum 100 nested functions limit fatal error' after hours of research, I endend up... writing this post I know my function updateScore() (in my-functions.php) is difficult, but what?? It just updates the scores depending on the task being recorded then checks the impact on other players and if it does have an impact, it triggers itself back to update the score of that other player. But yes, I know it can be some sort of never-ending story, but how can I do differently ? I wonder if it's ok to have wire('pages') in so many of my functions. But again, how can I do in another way? Well, sorry for such a long post, folks, but as you can understand, I'm facing a wall here and I hope someone around here will find some time to try and find his or her way into my code and give me a hint on where I could improve. I have had so many help from this community in the past and it felt such a relief and a revelation (Ended up telling my wife : "Wow, it looks so simple for these guys ! I've spent so many hours on that and... Of course ! Now I get it !! I'm getting better ! No next time !") Well, today is a 'next time'... Thanks if you've read up to this point and THANKS if you go and have a look at my code ! Fred.
- 6 replies
-
- optimisation
- functions
-
(and 1 more)
Tagged with:
-
Just as a follow-up in case people wonder, here's a copy of the message I sent to @adrian
-
@adrian Thanks for your reply. My site is at http://planetalert.tuxfamily.org . I have just installed TracyDenugger there. It doesn't appear but from what I've read in the settings, that's normal, everything is stored in log files. Ok, but how do I give you access to useful things (admin access?). Sorry if you feel like I'm messing things up and being a nuisance... Actually, I've just tested 1 thing : forcing the DEV mode so I can see Tracy's bar. I saw the 'Processwire Debug Panel' and clicked on the 'Pages loaded' link, and it went to my 404 page like I said... I turned the setting back to DETECT. Feel free to tell me if you want me to do some things or to private message you some logs or whatever... Edit : PM sent. Thank you so much.
-
@kongondo : I was definitely thinking of starting a new topic and ask you, guys, about my optimisation issue, but I wanted to find some clues by myself first... and believe me, I am trying to find something (hence my discovering of TracyDebugger ) but at the moment, I stay also curious about why I have to load 5000 pages ! (Except I am the creator of these pages, so this is rather shameful...) So I'll start a new topic soon ! But I still think the expected behavior of my TracyDebugger shouldn't be to redirect me when I click on the 'Pages loaded' link, no? Edit : WHile I'm at it, the 'Show bar in backend' option is NOT ticked and the bar displays in backend anayway And it triggers the 'Fatal Error Maximum function nesting level of '100' reached, aborting!'... Do you think I did something wrong? Should I try and re-install the module?
-
Hi everyone - Absolute newbie question (I'm discovering the module and actually I'm also discovering PHP debug stuff, so sorry if my question is rather stupid) I've just installed the module and it loads fine on my localhost with the bottom bar. If I look at the 'Processwire Debug Mode' (which I've set ON in my config.php), I see many infos such as 'Pages loaded', 'API Variables', 'Session'... with numbers. I'm very interested since I have a page which loads 4991 pages and so takes quite a long time (and I'm desperately trying to optimize it), BUT, and here's my problem : if I click on the link to see the pages, the menu drops down (cool!) but it triggers a page load which in its turn redirects immediately to my 404 error page... and I lose the current information I am spending quite a while trying to understand how to dive into this PHP debug tool (I have to admit it's for the moment way over my coder's skills), but here, I'm a little stuck on what seems to be... not much. So if anyone can give me hint on that one, I'd appreciate. Thanks ! PS : Maybe I should have opened a new question in the forum rather than following this topic ?
-
Hello, I'm facing this issue at the moment... A PHP script that seems to take too long and the browser returns a timeout. Flushing works fine on my localhost but doesn't on remote I have no idea what I can do, so if @renobird or anybody else has some advice, I would appreciate Thanks !
-
Thanks for the replies ! I had tried the OR statement before (like Robin S mentionned), but I had an issue because of those players having 2 places and 1 people and not being concerned (or 1 place and 2 people), but Kixe showed me the way by adding all possibilities in the OR statement. I hadn't thought about this possibility. Anyway, that would be more difficult if I wanted to pick players having more than a cumulated 10 number of free elements. I guess I would have to use my first 'foreach' solution in such a case. Thanks again for your ideas !
-
Hello, I'm having a little question with this part of code : $rank = $pages->get("template=team, name=$selectedTeam")->rank->name; if ( $rank == '4emes' || $rank == '3emes' ) { $allPlayers = $pages->find("template=player, team.name=$selectedTeam"); $allConcerned = new pageArray(); $notConcerned = new pageArray(); foreach($allPlayers as $p) { // Find players having at least 3 free elements if ($p->places->count()+$p->people->count() >= 3) { $allConcerned->add($p); } else { $notConcerned->add($p); } } $notConcerned = $notConcerned->implode(', ', '{title}'); /* $allConcerned = $pages->find("template=player, team.name=$selectedTeam, (people.count+places.count>=3)"); // Find players having at least 3 places OR 3 people */ /* $notConcerned = $pages->find("template=player, team.name=$selectedTeam, (places.count+people.count<3)")->implode(', ', '{title}'); */ It works fine the way it is, but I just want to make sure that the commented part is not possible with PW (yet?) : having a selector such as people.count+places.count>=3. I feel like it would be more concise and more readbable/maintainable (2 lines instead of 11). Thanks in advance for your insight and advice
-
Thanks for the answer. HP field can be less than zero. It is an 'Integer' field that holds a negative value when the task is... negative so I'm not sure why it doesn't return the expected result. I like the 'break;' tip. Again, I have a feeling I have missed that 'basic' one in my slow discovery of PHP (and coding)... Sorry about that. Anyway, I'm not at home right now, but I'll do some testing and come back here to edit my post and try and understand something about this nextUntil(). Thanks again ! Edit : After testing further and struggling about half an hour, here's my mistake : prevUntil() was what I was supposed to use (I feel a little bit ashamed...) Yes. I guess my 'sort=-date' in my previous statement was the clue. What I imagined being my first event (hence my nextUntil) was in fact my last event, that's why prevUntil was to be used... Eventually, the most readable code (to me) is your 'foreach' with the 'break' instruction, so I'll go with that Thanks !
-
Hello, I'm stuck with a nextUntil() use I can't figure out. The following function works if I use the commented part instead of the last 2 lines (with nextUntil). function checkStreak($player) { // Set Ambassador skill if necessary $ok = 1; $streak = 0; /* $lastEvents = $player->get("name=history")->find("template=event, sort=-date")->not("task.name=donated|donation|absent, limit=10"); */ /* foreach ($lastEvents as $e) { */ /* if ($ok == 1) { */ /* if ($e->task->HP >= 0) { */ /* $streak++; */ /* } else { */ /* $ok = 0; */ /* } */ /* } */ /* } */ $lastEvent = $player->get("name=history")->children("template=event, sort=-date")->not("task.name=donated|donation|absent")->first(); $streak = $lastEvent->nextUntil("task.HP<0")->count(); return $streak; } But I know it's ugly and... I sometimes wish I had a tutor to help me improve my coding style In words, what I'm doing is : - Check the last events recorded for a 'player' - I want to check the number of positive events in a row (before a negative occurs) - My function gets the last 10 events (the limit to get a bonus) and checks each one, but stops if it encounters a negative event and return the streak. BUT : looking at the API cheatsheet (thanks @soma), I've noticed this nextUntil() which I would like to use... but my use always returns 0 If someone can understand why and help me improve on that one, I would appreciate. Thanks ! By the way, feel free (if you have a few minutes) to give me advice on how to improve those foreach() I feel like I'm overusing...
-
Hello, I'm struggling with this : a 504 Gateway Timeout when generating my PDF. I used to be able to generate a particular PDF listing 52 places with a photo (small), a little text and a few pieces of information for each in a table. It worked and I had a PDF of about 350Ko. Now, I'm trying to generate a PDF of about 250Kos and I get the 504 error. I've tried to re-generate my places catalogue and again, I have the 504 error. All my templates work fine (although it takes a little while) to generate smaller PDF files. The page I'm trying to generate is : http://planetalert.tuxfamily.org/players/4e/amandine If someone have advice on how I could find my way out of this, I'd greatly appreciate Thanks !
-
Thank you so much ! I can't believe I've passed through this one... It caused me a real headache having to manually repair the bad work with my 'delete' function. Now I've learned something again tonight thanks to both of you and I'm still enjoying more and more discovering ProcessWire Thanks again !
-
Hello, I'm coming back to you since I've finally managed to extract the 'buggy' part of my code. Here's my problem : When a player loses a level, I want this player to lose all his equipment, so I wrote : foreach ($player->equipment as $equipment) { $equipment->delete(); } But here's what happens : The original equipment pages get deleted ! Not just the item in the AsmSelect ! And I just can't figure why this happens ! Yet I'm sure I am misunderstanding some basic principle here... So if anyone could give me a hint, I'd appreciate. To be more precise : my equipment list is in my tree in equipment/weapons/ and has many pages, such as sword, bow, gun... (It looks violent but it's not, it's a classroom experiment to motivate teenagers ) and my AsmSelect resides in a player template so whenever a player has the possibility, he can select an equipment page. Everything works fine, except when I use this 'delete' line In other words, how could I clean this asmSelect without actually deleting the pages in the original equipment tree? Thanks in advance !
-
Just as a follow-up : I've noticed this happened just because of my 'Alt-Gr' keyboard latency. I explain : when I type ' || ' on my keyboard, I need the 'Alt-Gr' key and the second space character is then often hit with 'Alt-Gr' down making it a non-breaking space And VIM didn't show any difference. (but PHP did!) To finish : here's what I found that helped (in case it helps others) : https://wincent.com/blog/making-vim-highlight-suspicious-characters
-
@arjen : Your code works fine. Thanks! I like the syntax very much and try and use it in the future. My entire code would be a little long to put here, I think and I'm not sure it would help. I can't imagine a ';' or a '}' is missing because everything worked fine before. My previous line was : $class = $page->name == "blog" ? "on" : ""; And i just tried : $class = $page->name == "blog" || $page->name == 'documentation' ? "on" : ""; and $class = ($page->name == "blog" || $page->name == 'documentation') ? "on" : ""; And in both cases I had the error. Then, I tried the longer version I mentionned a tfirst, and still the error occured. And I had to face the same issue (twice actually) a couple of days ago in another part of my code. I eventually found the workaround of copying the || from another place where it works, and as I said, just this manipulation of copying and pasting ' || ' makes the code work as expected. Which is why I wondered if there could have been an issue of character encoding that I would be absolutely unaware of, and this is why I decided on posting here And I'm again glad I did since you're teaching me a nice concise syntax that I should use (and that avoids my problem). So thanks a lot! But if you insist on seeing my code to try and understand the issue, I'll do it. If you have other ideas of where I should look from the info I've just added, tell me. I'd be happy to really understand this problem. @Fokke : Thanks for your quick comment (hence my editing of this post ) : I'm using VIM to code. And guess what : I've just tested your idea : getting rid of my spaces and re-typing them and....... YES! It works ! That's so cool! Now I'll try and understand why is my VIM acting this way and find a solution, but that's another matter. Anyway, a big THANKS to both of you ! This place is really one of the best place on the Internet, and I mean it. I have learned so much here and the community is so 'responsive' when you need help. That's really cool
-
Hi there, Here's my problem which lets me... with a big ? in the head I have this simple piece of code : if ($page->name === 'blog' OR $page->name === 'documentation') { $class = 'on'; } else { $class = ''; } It triggers the error : Parse Error: syntax error, unexpected '$page' (T_VARIABLE) (line 114 of /home/celfred/PlanetAlert/site/templates/head.inc) This error message was shown because you are logged in as a Superuser. Error has been logged. If I get rid of the OR statement, it works fine. If I choose the right part of the OR statement alone, it works fine. If I type || instead of OR (what I did at first), it throws the error. And here's the best part : If I copy/paste the || from another IF statement that works fine in my site, it WORKS !! This is becoming a nightmare. I can't type a regular OR statement in my PHP code. I have to copy/paste the characters and it works. If anyone has a clue to help me on that, I would really appreciate because as I often say, being no professional coder, I kind of take A LOT of time on programming issues, but here, this weird behavior is over my head. I feel desperate when I stumble upon such basic parts of code Thanks in advance ! PS : I've tried to dig into my PHP config that would have changed since some kind of upgrade, but with no luck... I've looked at my file encoding (utf8)... Well, I'm stuck ! EDIT : Just to illustrate more : Copy/paste from another file that works : if ($page->name == 'blog' || $page->name == 'documentation') { If I retype the || operator and save and reload on my localhost : tada! Error !!!