Jump to content

rusjoan

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by rusjoan

  1. Woohoo! Thank you guys, now it works! I simply copied those files of mentioned commit because I have no idea how to work with 2 repos in one git-project while all of your dirs except "wire" should contain only your data but not from PW-repo. Maybe anyone can tell me about the way to keep PW up-to-date? @WillyC there were most of pages with filled fields
  2. Good solution, thank you. But my trouble is a bit different...
  3. Hi! This topic is not about a real big data, but nonetheless PW can't hold it I created a template ("task") with couple of text fields and one repeater field. This repeater has 3 text fields and 2 textarea fields. There are 2374 pages using this template. When I've decided to restructure my DB I went in a real trouble. Restructuring is in that I make new template with all of mentioned repeater fields and I remove 2 "massive" textarea fields from repeater. Then task-template pages should become smaller in DB and I'll get ability to do stats analysing faster, and task page still can get 2 textarea fields values from another page if needed. I moved all of mentioned 2 fields data to new pages then tried to remove these fields from repeater. But here's what I've got: Then I launched script to clear values in these fields (set to ""). This was slow and boring but it's done. And after new attempt I've got the same error. My suggestion is: script, that removes fields, tries to do $pages->find() for all of pages that use given field. But data size from DB is too big to locate in allowed RAM — textarea uses MEDIUMTEXT innodb type what's about 16 Mib. This case is why I made my script to clear fields values by iterations of 10-50 pages to avoid memory overflow. How I can remove these fields? The only solution is to temporarily give PW more RAM by performing ini_set( )?
  4. Thanks guys, so now I know a real reason of this issue. It's true that server and local PHPs has different versions Changing user password under other admin account helped me
  5. I published my site to remote host and now I can't login to admin with old credentials. All config and DB same as on my local. Tried to switch off "session fingerprint" and other stuff and it doesn't help me. Any suggestions? Thanks.
  6. What is more "expensive" — simple query to DB or simple check file existence on file system (let's suggest that we work with SSD)? This question was originated to me recently when I decided to make "Cancel" function in file downloading script. This script works as background for limited time. It compares current execution time with limitation and breaks download task if time has expired. Also breaking mean removing of all downloaded files, and then task status equals "Fail". "Cancel" function works the same — clear task dir when download has canceled. So execution time check function doesn't require access to hdd or db and we can check it on each file download iteration. Also script makes query to DB to update task download status (percents) no more than once a second (controlled by a separate function). When I decided to make "cancel download task" function I stuck on a question — what is more optimal to make script check his status for "cancel"? Check for file existence (e.g. "cancel-{taskID}.txt") or check the same in DB? This all goes from that I'm using PW engine and I can't combine SQL-queries (update task status, check task cancel status..) by engine's native tools. If you work only with engine selectors and don't write any "clear" SQL-queries in a whole project it's obvious to try continue the same UPD: I know that access DB is cheaper than access HDD. But what about SSD?
  7. Now googled same topic: https://processwire.com/talk/topic/4655-find-pages-by-createduser/ So I decided to try created_users_id=.. and it works! OK, then now another question: where is official information about this behavior? I'm sure that PW-novices should know about these nuances from API doc but not from self-searches
  8. It's so strange that I can't select pages like this: template=foo, createdUser=1018 It gives such error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.createdUser' in 'where clause'' in ... My suggestion is in: error causes because of selector engine allows to select by createdUser, but this is a service field and it doesn't exist in DB.
  9. $config->debug = true really helpful. Now I see this: Also I tried to reinstall VKAPI module..
  10. OK, I'm agree with you, moreover I used this technique all time. Otherwise if internet-shop provide using online-constructors there is a real trouble to store all of user constructed data in sessions or cookie variables. The trouble itself is on we should to choose format to store data from different types of constructors. And then when user makes order, this data would be transformed to pages-form in PW DB. Is there a way to convert pages into session-storable variables? Wish there a way to convert page into assoc array and then json_encode it.
  11. What does this red banner in modules admin section mean? This is the trouble module: VKAPI.module But I'm sure all correct... I see no reason to display error banner. Help please. P.S. Also I tried to publish this module to PW modules library but there're a lot of fields, and I stopped at "Enter forum topic for ur module" and "Enter github repo url". Why I can't just upload module? Checking versions via git is so good, but not in any situation.
  12. My situation is potential, so now I haven't so big DB size but this is achievable in the future. What about template with lots of fields — this is not in my case but you got me interested in it. What does allow to build one "big" field what contains a lots of rows? It isn't Fieldset?
  13. Let's talk about possibility to archive pages from DB. I mean if your site collected a big amount of data and after some time you won't to store it in DB then you should have a tool to do archiving. Simply delete old pages is not best practice sometimes (e.g. in my situation). Archiving in my look is a process when old unused data compressing in DB (I don't know how, just my suggestion) with no ability to access it. And if you want this data again — you must decompress it. So we have 2 time-consuming processes — compressing and decompressing, but we save on DB size. But on other way we can do it more simply: you export a number of pages to one file to HDD and remove they from DB. How can this be organized (I mean first method)? What does PW provide in this instance?
  14. I continue my monolog. I removed if ( empty(wire('user')->token) ) wire('session')->logout(); in the start of userProcess( ) because this method is calling before Pare::render by installed hook. But /login page calls process( ) method while page renders. So $user->token will be empty or wrong at this time. And, as I suggest, session->logout doesn't allow to run session->login on process( ) method.
  15. Let's skip this question, I set hook before of Page::render. But now funny situation again. This is the section of module where regular init method is placed: public function userProcess() { if ( ! wire('user')->isLoggedin() || wire('user')->isSuperuser() ) return; if ( empty(wire('user')->token) ) wire('session')->logout(); $userapi = new userapi(wire('user')->token); $requestResult = $userapi->api( "users.get", ['uids' => wire('user')->name, 'fields' => 'first_name,last_name,photo'] ); if ( ! isset($requestResult['response'][0]) ) { wire('session')->logout(); return; } $requestResult = $requestResult['response'][0]; wire('user')->of(false); wire('user')->title = $requestResult['first_name'] . ' ' . $requestResult['last_name']; wire('user')->photo = $requestResult['photo']; wire('user')->lastvisit = date('H:i d.m.Y', time()); wire('user')->save(); } public function init() { $this->setFuel("oAuth", $this); require_once(wire('config')->paths->templates . "/vkapi.class.php"); $this->addHookBefore('Page::render', $this, 'userProcess'); } When I'm adding echo $this->user->token at the beginning of userProcess() for debug purposes, login via oAuth works well (but displays user's token at the start of page). But when this sentence doesn't exists user authorization doesn't work. My suggestion is in that "echo" issues write cookies that wire('session')->login provides in process() method. Any suggestions?
  16. Can't believe it! Using wire('..') helped me so fine! I knew about it before but forgot to use here. I set module again to autoload=true and all works fine. OK, now I'm goin' to make init() function do what it should do. I moved all instructions except first two to other function. So current task is to select proper hook... Which one is more correct in my situation?
  17. Before all I just want to say that I'm really, really angry. I've spent ton of hours by solving a lot of stupid issues instead of doing main task of my project... I love PW and exited of his flexibility and usability. But some sides of developing aren't showed so fine. My project works around one main algorithm what I planned to make today but it's impossible because of really stupid behavior of PW and poor docs... Please, help me. I hope in u to make me work faster with your advices. So, first my issue... I built module with such structure: <? class Oauth extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( 'title' => 'oAuth 2.0 module', 'summary' => 'First create "token" field in system user template', 'version' => 100, 'singular' => true, 'autoload' => false ); } public static function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); $field = wire('modules')->get('InputfieldText'); $field->name = 'getTokenUrl'; $field->label = "Requesting address to get access token"; if(isset($data['getTokenUrl'])) $field->value = $data['getTokenUrl']; $inputfields->add($field); $field = wire('modules')->get('InputfieldText'); $field->name = 'appID'; $field->label = 'oAuth application ID'; if(isset($data['appID'])) $field->value = $data['appID']; $inputfields->add($field); $field = wire('modules')->get('InputfieldText'); $field->name = 'appSecret'; $field->label = 'Application secret'; if(isset($data['appSecret'])) $field->value = $data['appSecret']; $inputfields->add($field); return $inputfields; } public function process($redirectUrl) { if ( ! isset($_GET['code']) || isset($_GET['error']) ) throw new Exception("Missing get parameter", 1); $hui = $this->appID; var_dump($hui); $authCode = $_GET['code']; $requestUrl = $this->getTokenUrl . '?client_id=' . $this->appID . '&client_secret=' . $this->appSecret . '&code=' . $authCode . '&redirect_uri=' . $redirectUrl; $requestResult = @file_get_contents($requestUrl); //$requestResult = json_decode($requestResult, true); if ( ! isset($requestResult['access_token']) ) throw new Exception("Missing access token from server: " . $requestUrl .":". $requestResult, 2); $tempUser = $pages->get("template=user,name=" . $requestResult['user_id']) or new User(); $tempUser->name = $requestResult['user_id']; $tempUser->token = $requestResult['access_token']; $tempUser->pass = md5($tempUser->token); $tempUser->addRole('oauth'); $userapi = new userapi($requestResult['access_token']); $requestResult = $userapi->api( "users.get", ['uids' => $tempUser->name, 'fields' => 'first_name,last_name,photo'] ); $requestResult = $requestResult['response'][0]; $tempUser->title = $requestResult['first_name'] . ' ' . $requestResult['last_name']; $tempUser->photo = $requestResult['photo']; $tempUser->lastvisit = date('H:i d.m.Y', time()); $tempUser->save(); $session->login($tempUser->name, md5($tempUser->token)); return true; } public function init() { $this->setFuel("oAuth", $this); require_once($config->paths->templates . "/vkapi.class.php"); if ( ! $user->isLoggedin() || $user->isSuperuser() ) return; if ( empty($user->token) ) $session->logout(); $userapi = new userapi($user->token); $requestResult = $userapi->api( "users.get", ['uids' => $user->name, 'fields' => 'first_name,last_name,photo'] ); $requestResult = $requestResult['response'][0] or $session->logout(); if ( ! $user->isLoggedin() ) return; $user->title = $requestResult['first_name'] . ' ' . $requestResult['last_name']; $user->photo = $requestResult['photo']; $user->lastvisit = date('H:i d.m.Y', time()); } } This module is configurable with 3 fields. But I can't use this values! I dont know why, because in other mine module all works fine. This module should check user auth status on every page load (so it's only idea to place these instructions to init() but when I write die() instruction at the beginning of init() — nothing happens, site works as usual... But my suggestion is in that every module initializes after API but before page will load. So docs haven't helped me (forum too). Next, I call process() method from module in /login/ page, here's full code: <? if ( $input->urlSegment1 == "logout" ) { $session->logout(); header("location: /"); exit; } try { $redirectUrl = "http://" . $config->httpHost . "/login/"; $oAuth = $modules->get("Oauth"); if ( $oAuth->process($redirectUrl) ) echo "Success"; } catch (Exception $e) { echo "<p>" . $e->getCode() . "</p>" . "<p>" . $e->getMessage() . "</p>"; } Also I tried to do that by $modules->get("Oauth")->process($redirectUrl); But it doesn't matter how I can see. And now — magic! 1. If I set module autoload = false /login page gives that error: 2. When autoload isn't set (not false or true, it isn't defined in config array) Then process() method doesn't work correctly because I can't take value from config fields. Issuing $this->appID gives NULL We can try to define process() as static method but it's obviously not a good idea. 3. autoload = true Well here quite simple.. Init() method isn't able to require class-file because of wrong path. And path is wrong because $config->paths array is empty and I can't take right path to templates folder. And, to one heap, I had to use $_GET['code'] because $input->get->code always empty...
  18. Hope to Ryan that select between DB engines will be real soon
  19. OK, thanks. Can you say how I can organize unregistered customer cart where different types of templates have place? Maybe it'd good to create new cart in "Carts" branch and place here all of that customer will choose? (Each cart will have PageListSelectMultiple inputfield)
  20. Hi everyone! I need your help in one interesting question. I'm creating now my own internet shop on Processwire engine. And this shop will contain different types of goods. For example, t-shirts, mugs, stickers, etc. And I should give some options of goods to my customers. Customer can select different sizes of t-shirts, different colors of stickers, different image (print) of mugs. And how to do this option differentiation of type of goods on the PW? Is there any solution except that I should create specific templates for specific goods? Sorry for my english, but I hope you have understood me
  21. OK, guys. I've tried to manually execute field creating SQL and what does MySQL said: "#1214 - The used table type doesn't support FULLTEXT indexes" All of this because of updateDatabaseSchema function in module. You just have to comment it out (I mean "$this->updateDatabaseSchema($field, $schema);" row in getDatabaseSchema) Hope I helped to someone P.S. Ryan, I think you should reupload new module version with this bug fixed. Search tags: Table doesn't exist, mapmarker, new field
  22. I don't know why, but this module doesn't work. It installs right but then when i'm creating new field with type "MapMarker" it isn't creating. It says that Table 'database.field_googlemap' doesn't exist I've tried to find SQL in installing function that creates field table. Is it right that "getDatabaseSchema" function is for create new field? Help me please! Running 2.3.0
×
×
  • Create New...