Jump to content

Guy Verville

Members
  • Posts

    204
  • Joined

  • Last visited

Posts posted by Guy Verville

  1. Hi Teppo,

    Thank you very much for your great work! I wonder if it would be possible to prevent a user to be logged. Let me explain, one of our sites has a synchronisation process which use a user 'synchro'. This automated process does not need to be logged, since there are a lot of changes made by this process. We only want to log 'regular administrative' users.

    I suppose I can hook myself over your own hook, but I am not sure how to proceed.

    I would like to something like:

    if (thisUser or theseUsers) don't log.

     

  2. I have perhaps a beginning of an answer. Using Tracy debugger, I checked three times the file object in the $page, before making the changes, after making the changes, and after having saved the page. The $page object changed after the save. The image file is now in an array...

    The first, being read before change anything.
    1265936017_Capturedcranle2019-09-3010_27_20.png.abd70c56b28c185bd07a32022778fed9.png

    The second, the changes have been set. The image object is the same.

    1576927635_Capturedcranle2019-09-3010_27_43.png.0824e8061f0cfb3facdec02608a35c66.png

    I apply the changes. Boom!

    1140398295_Capturedcranle2019-09-3010_28_30.png.a697b831c2420331364ba4e5593df928.png

    While the formatted value should not interfere here, since the output formatting is off there is perhaps something to look here...

    image.thumb.png.9b2e62b2a0545f4cd84349a04000df26.png

    On my log, I wrote the filename before and after the save. The second name does not show if I call with $page->sku_image->basename. I have to drop the ->base name part. But this does not explain why the image entry disappear.

    if ($existingPage->template->name = "sku-ceramic") {
        $image = $existingPage->sku_image->basename;
    }
    $this->savePage($existingPage,true);
    if ($existingPage->template->name = "sku-ceramic") {
        $this->wire('log')->save('centura-synchro-images', $existingPage->id . "|". $image . "|". $existingPage->sku_image);
    }

    image.thumb.png.c8c2355e982a4940248a508372e11455.png

  3. Hi, the CSV file is the same, and this field is not involved. The CSV file contains essentially basic data such as sku name, prices for different regions. The price is the data that changes from time to time. The image is not a field in this CSV file.

    I made my test on that file and everything operates normally. This is when the $page is saved that something is lost. So my next step is to stop the process and see what's inside the object.

  4. No, p21fields are the reference to csv file we read daily. "sku_image" is an image that must be treated manually.

    I queried about the hooks, but nothing relevant here, certainly not around the image.

    My programmer colleague suggested me to desactivate the processChangeLog module which was installed recently, which track changes. But I doubt that it can cause problems.

    And this table is so simple...

    Capture d’écran, le 2019-09-30 à 08.28.27.png

  5. Hi BitPoet,

    No, the script load the actual page object and processes it.

    if($existingPage = $this->pageExists($query = 'name=' . $itemSku)) {
    	$extractedData = "";
    			// we compare the previous json data from the page with the actual jsonEncoded csv line
    			if($existingPage->p21_json != '') {
    				$extractedData = $existingPage->p21_json;
    			}
    			...
    			//These are two strings to compare
    			$equal = $this->comparePage($extractedData, json_encode($data));
    			if($equal) {
    				...
    				no change made
    				return false
    			}
    			// there is difference, so we populate the page with the new data.
    			// image field and other fields are not affected by $data
    			// the function "prepareData" uses $existingPage->set($field, $data [XX]);
    			$existingPage = $this->prepareData($existingPage, $data);
    			...
    			$this->savePage($existingPage,true);
    			return true;
    }
    protected function savePage(Page $page, $reportErrors = true) {
    		try {
    			$page->of(false);
    			$page->save();
                $this->wire('log')->save('centura-synchro', $page->title);
    		} catch(Exception $e) {
    			if($reportErrors) {
    				$this->error($e->getMessage());
                    $this->wire('log')->save('centura-synchro-errors', $page->title . "=> " . $e->getMessage());
    			}
    		}
    		return $page;
    	}
    
    protected function prepareData($p, $data = null) {
    
    		$fields = $this->generalTools->p21fields;
    		...
    		foreach($fields as $field) {
    				...
    					$p->set($field, $data[$ctn]);
    				...
    		}
    		$p->p21_json = json_encode($data);
    		...
    		return $p;
    	}
    
    public function pageExists(string $query) {
    		$page = $this->pages->get($query);
    
    		if($page->id === 0) {
    			// page do not exist
    			return false;
    		}
    		return $page;
    	}

     

  6. We have a script that synchronizes data from a CSV file on a daily basis. The data that is synchronized all belong to a page type. However, not all data of this type of template is inspected. For example, we have a field called "sku_image" that is manually filled in by the administrator. 
    When there is data to synchronize, the script modifies the relevant fields, then saves the page with the help of a function:

    protected function savePage(Page $page, $reportErrors = true) {
    		try {
    			$page->setOutputFormatting(false);
    			$page->save();
                $page->setOutputFormatting(true);
                $this->wire('log')->save('centura-synchro', $page->title);
    		} catch(Exception $e) {
    			if($reportErrors) {
    				$this->error($e->getMessage());
                    $this->wire('log')->save('centura-synchro-errors', $page->title . "=> " . $e->getMessage());
    			}
    		}
    		return $page;

    However, for some time now, and we don't know why, the entries in the "sku image" field for saved pages have been systematically deleted from the "field_sku_image" table!

    The image files remain in each folder, but the reference in the table disappears. The field is a very standard image field and is not processed during synchronization except that when the page object is saved. The other data that is not processed in the synchronization remains in place. It is as if the variable $page forgot the data it is supposed to contain. It's a great mystery.

    Synchronization is performed with a special "user" who has editing rights for these pages.

    What could cause such behaviour?

  7. Hi,

    ProcessWire has excellent functionality when it comes to solving URLs in another language.

    For example, suppose I have the following addresses: domain.com/en/career and domain/fr/carriere.

    If a user types domain.com/carriere, ProcessWire will be able to deduce that the correct address is domain.com/fr/carriere.

    On my machine, I can switch between Apache and nginx and the expected behavior works very well with Apache, but not with nginx which will systematically send me back /en/career.

    I tried to study the ProcessWire code, including the getPage() function and the LanguageSupportPageNames module, but I can't find where it fails. All I perceive is that the user's language does not switch, it remains in English.

    I would like to point out that otherwise, ProcessWire works smoothly with nginx.

    • Like 1
  8. Hi @teppo

    We have difficulty using your module with the TemplateEngineFactory and the attribution of $view.

    $view = wire("view");
    $code = .....;
    $view->set('myVariable',$code);

    $view is NULL when trying to get a preview, so we get an error.

    Any idea how to resolve this?

     

    PS. This is the TemplateEngineFactory module that prevents previewing pages under /admin.

  9. 5 minutes ago, dragan said:

    Disclaimer: I have never set up a multi-domain PW site myself.

    However, I guess if you want to take a test-run yourself (without having to buy 4 new domains ?), you could do the following:

    Install PW locally. Do the necessary steps as outlined by @Soma, and then edit your .hosts file with 4 dummy-domains. Configure your local Apache setup for the domains, then play around with different roles / users / permissions and multilanguage features. I guess you'll need modules such as AdminRestrictBranch as well.

    Hi Dragan,

    I have MAMP Pro and will do this without effort. I was just wanted to hear any experience on the particular subject. Remember that, apart from having 4 sites, each of them have two domains associated with them. Why keep it simple when you can make it complicated? ?

  10. 16 hours ago, Sergio said:

    @wbmnfktr (had to copy the username ? )  pointed up important questions. The other questions I may think are crucial to the developing effort are:
    1 - Are the content updates very frequent and on all sites to justify a single database?

    2 - Will be the content of the website entered in parallel? Or maybe one site is fully edited and can be copied to the other ones before people start working on them.

    For more complicated reasons than any other, the customer must divest himself of his four sites made with Liferay. We do not have access to this CMS and I have to evaluate on behalf of a consultant who does not yet have all the information. The people who will work on the site are not technically very advanced even though they have a lot, a lot of money, it seems, they want something simple to use (Facebook syndrome). Some people will be administrators for the four sites, but others will operate only one site. Boards of directors may be a mix of roughly the same people with additions. In short, a beautiful spaghetti as this evaluation promises!
    I think the challenge is mainly to have a single connection for these four sites without using an LDAP server. I have to give an approximation of what the system might look like without doing the actual analysis at this time.

    Translated with www.DeepL.com/Translator

  11. Thank you for answering.

    The client is a financial group. They are all in the same building and they all know that their site have to be in both languages (it's almost a prerogative for doing things in Canada...)

    But I agree with you that I would got with 4 different instances. Since they will share the main design with perhaps difference in colors, there is certainly a way to make sure that the core CSS is identical.

    • Like 1
  12. I know it is possible to have a different domain name for each language of a site. For exemple:

    • monsite.com (for French)
    • mysite.com (for English)

    I know also that we can have several sites in one installation with the help of Soma's Multisite module.

    I have a company who has four independent sites (four different companies under a same umbrella). The new design and structure of those sites will be practically identical. There will be different administrators for each site, but a lot of data will be shared, so using Soma's module seems to be a good idea. The problem is that those 4 sites have different names for the French and English version.

    • compagnieUn.com (for French)
    • companyOne.com (for English)
    • compagnieDeux.com (for French)
    • companyTwo.com (for English)
    • etc.

    Will we shoot ourselves in our feet to develop with just one installation? Would it be preferable to make those sites able to talk to each other instead?

    Your input would be very much welcome!

  13. 21 hours ago, Guy Verville said:

    Some people have this strange problem. We did migrate from a Pantheon site (it was on Drupal, remember), and it's as if the SSL certificate is still stuck in Pantheon, which is not. My IT teams is on the case. Not all people has this problem.

    We finally discovered the culprit. An IPV6 entry that was still pointing to Pantheon. Everything should be ok by now.

    • Like 1
  14. 26 minutes ago, Sergio said:

    Olá, Guy! ?

    I'm hosting the app on Laravel Forge with FastCGI enabled. I've based my config on this @u-nikos post:

    Here's my version:

    
    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name example.com;
        root /home/forge/example.com/public;
    
        
        index index.html index.htm index.php;
    
        charset utf-8;
    
        
        # -----------------------------------------------------------------------------------------------
    	# Access Restrictions: Protect ProcessWire system files
    	# -----------------------------------------------------------------------------------------------
    
    	# Block access to ProcessWire system files
    	location ~ \.(inc|info|module|sh|sql)$ {
    		deny all;
    	}
    
    	# Block access to any file or directory that begins with a period
    	location ~ /\. {
    		deny all;
    	}
    
    	# Block access to protected assets directories
    	location ~ ^/(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) {
    		deny all;
    	}
    
    	# Block acceess to the /site/install/ directory
    	location ~ ^/(site|site-[^/]+)/install($|/.*$) {
    		deny all;
    	}
    
    	# Block dirs in /site/assets/ dirs that start with a hyphen
    	location ~ ^/(site|site-[^/]+)/assets.*/-.+/.* {
    		deny all;
    	}
    
    	# Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php
    	location ~ ^/(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ {
    		deny all;
    	}
    
    	# Block access to any PHP-based files in /templates-admin/
    	location ~ ^/(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ {
    		deny all;
    	}
    
    	# Block access to any PHP or markup files in /site/templates/
    	location ~ ^/(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in /site/assets/
    	location ~ ^/(site|site-[^/]+)/assets($|/|/.*\.php)$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in core or core module directories
    	location ~ ^/wire/(core|modules)/.*\.(php|inc|tpl|module)$ {
    		deny all;
    	}
    
    	# Block access to any PHP files in /site/modules/
    	location ~ ^/(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module)$ {
    		deny all;
    	}
    
    	# Block access to any software identifying txt files
    	location ~ ^/(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md)$ {
    		deny all;
    	}
    
    	# Block all http access to the default/uninstalled site-default directory
    	location ~ ^/site-default/ {
    		deny all;
    	}
    	#Amplify dashboard
    	location /nginx_status {
            stub_status on;
            allow 127.0.0.1;
            deny all;
        }
    
    	# -----------------------------------------------------------------------------------------------
    	# If the request is for a static file, then set expires header and disable logging.
    	# Give control to ProcessWire if the requested file or directory is non-existing.
    	# -----------------------------------------------------------------------------------------------
    
    	location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|eot|woff|ttf)$ {
    		expires 15d;
    		log_not_found off;
    		access_log off;
    		try_files $uri $uri/ /index.php?it=$uri&$query_string;
    	}
    	
    	# -----------------------------------------------------------------------------------------------
    	# ProCache Rules
    	# -----------------------------------------------------------------------------------------------
    
    	set $cache_uri $request_uri;
    
    	if ($request_method = POST) {
    		set $cache_uri 'nocache';
    	}
    
    	if ($http_cookie ~* "wires_challenge") {
    		set $cache_uri 'nocache';
    	}
    	
    	if ($http_cookie ~* "persist") {
    		set $cache_uri 'nocache';
    	}
    
    
    	# -----------------------------------------------------------------------------------------------
    	# This location processes all other requests. If the request is for a file or directory that
    	# physically exists on the server, then load the file. Else give control to ProcessWire.
    	# -----------------------------------------------------------------------------------------------
    
    	location / {
    		expires -1;
    		try_files /site/assets/ProCache-b3d534d...d/$cache_uri/index.html $uri $uri/ /index.php?it=$uri&$args;
    	}
        
    
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
    
        access_log off;
        error_log  /var/log/nginx/example.com-error.log error;
    
        error_page 404 /index.php;
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    
        location ~ /\.ht {
            deny all;
        }
    }

     

     

    Muito obrigado!

  15. 12 minutes ago, Sergio said:

    I'm getting a 404 on your website due to Chrome's blocking scripts on http as insecure. See screenshot. Version 70.0.3538.110 (Official Build) (64-bit) on Windows 10

     image.thumb.png.45801fd95813a462a2c0d58233fec68e.png

    Some people have this strange problem. We did migrate from a Pantheon site (it was on Drupal, remember), and it's as if the SSL certificate is still stuck in Pantheon, which is not. My IT teams is on the case. Not all people has this problem.

    • Like 1
  16. 20 hours ago, Nicolas said:

    Great write up Guy, thanks for the post

    You've mentionned Twig. How did you implement that ? Is there any chance to have more details about the programming architecture?

    Bonjour @Nicolas,

    We started a long time ago to use https://modules.processwire.com/modules/template-engine-twig/. That code inspired one of our programmers to create his own module to take advantage of Twig 2.0 since the module Template Engine Twig still rely on Twig 1.35.

  17. 22 hours ago, Sergio said:

    Hey @Guy Verville, excellent write-up!! Thank you for that!

    I've been using ProCache for about 3 years now in Nginx without any issues. So, go ahead! ?

    PS: I'd like to suggest you post in on Medium, etc. as well to increase reach. If you decide so, I also suggest to add to Ryans role: creator and maintainer of Processwire... instead of just designer, as people may only read "graphic/web designer" when they see that. 

    Olá @Sergio,

    It would be great to let us know how you implemented ProCache in nginx. Out IT implemented the fastcgi cache present in nginx. Have you implemented both ProCache and that? Thanks for the suggestion, I will look into it.

    Please note that we published a revised version on our own website: https://www.spiria.com/en/blog/website-creation/choosing-processwire-for-spiria-com/

  18. On 11/30/2018 at 6:35 AM, Noel Boss said:

    Thank you very much for this great Article and Congrats to the new/old site ? looks fantastic!

    One question, what do you mean by that; are you talking about a custom checkbox you added on all relevant templates?

    Hi @Noel Boss,

    We simply add an extra selector in our query like this:

        $visitedLanguage = getVisitedLanguage();
    	if($visitedLanguage == "en") {
    		$queryExtra = "non_existent_english!=1";
    	} else {
    		$queryExtra = "";
    	}

     

×
×
  • Create New...