Post by justcurious » Fri Oct 03, 2014 5:41 pm

I have updated a couple of my extensions for Opencart 2.0 compatability and I am unable to install them via the extension installer.

To the best of my knowledge I have followed the guidance on the Modification System wiki on github but I'm getting the following error (javascript popup):

Code: Select all

Syntax error: Unexpected Token <
OK
<b>Warning</b>: ftp_mkdir(): can't create directory: File exists in <b>/home/xxxx/public_html/xxxx/admin/controller/extension.php</b> on line <b>307</b>
The warning line repeats so many times, it takes the popup dialog past the end of the screen.

I have created a zip file myextension.ocmod.zip which contains an upload folder and a file myextension.ocmod.xml. The upload folder contains two other folders - admin and catalog, both of which contain the relevant controller, language, model and view files.

Although I'm getting the above error message, the extension files are being uploaded correctly to their respective locations. That leads me to suspect the problem lies with the ocmod .xml file. But . . .

. . .If I use ftp to upload the files, then use the Extension Installer to upload the mod file "myextension.ocmod.xml" separately, it installs successfully.

Is this a bug, or am I doing something wrong?

I've raised this on the Atlassian Bug Tracker just in case.

Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions


User avatar
Active Member

Posts

Joined
Sat Dec 24, 2011 4:36 pm
Location - UK

Post by Johnathan » Fri Oct 03, 2014 11:59 pm

I've tested the extension uploader a few times myself, and never have been able to get it to work. I don't consider that part of 2.0 to be stable at this point. (Honestly, I'd recommend just waiting to update for new features -- like the extension installer -- until a lot of the initial bugs are worked out. It'll save you some time on extension development.)

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by esponi » Sat Oct 04, 2014 6:38 pm

Any doc about 2.0 extensions-howto available?

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by justcurious » Sat Oct 04, 2014 8:51 pm

Johnathan wrote:I've tested the extension uploader a few times myself, and never have been able to get it to work. I don't consider that part of 2.0 to be stable at this point. (Honestly, I'd recommend just waiting to update for new features -- like the extension installer -- until a lot of the initial bugs are worked out. It'll save you some time on extension development.)
It's a shame. I am aware of the general feeling towards OCMOD as opposed to VQMOD, but I thought I'd give OCMOD a shot anyway. The problem is that once an extension is developed with VQMOD, I think that most developers will be unlikely to bother to make it backwards compatible with OCMOD at a later date when there is a fully functional alternative readily available.

Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions


User avatar
Active Member

Posts

Joined
Sat Dec 24, 2011 4:36 pm
Location - UK

Post by opencart-templates » Tue Oct 07, 2014 5:00 pm

Just been testing this and works pretty well for me uploaded all the files fine but I was surprised to see that it doesn't actually install the extension, only uploads the files.

Not sure on the logic behind install.php/xml/sql, why would you want to upload, apply any custom changes before the extension is actually installed. Prefer to use the old way using a method called install which handles any database changes.

User avatar
Active Member

Posts

Joined
Mon May 16, 2011 7:24 pm
Location - UK

Post by yubnub » Wed Oct 08, 2014 5:39 pm

Hi,

I am also having the issue :

PHP Warning: ftp_mkdir(): Can't create directory: File exists.......

I have tried to installs on 2 different hosts/servers and get the same error on both.

As this seems to be working for some people and not for others is it due to server config?

regards,

anthony

New member

Posts

Joined
Mon Nov 28, 2011 1:38 am

Post by esponi » Wed Oct 08, 2014 6:04 pm

me too!

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by yubnub » Wed Oct 08, 2014 8:52 pm

In the end i commented out the line being referenced in the error - seems to work fine for me now!

Obviously this is a complete hack - in no way am i suggesting this is a solution!.

It has however allowed me to create and upload and prove that my ocmod works.

My lines in the admin/controller/extension/installer around line 307 now look like :

Code: Select all

							//	if (!in_array($destination, $list)) {
								//	if (!ftp_mkdir($connection, $destination)) {
									//	$json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
							//		}
						//		}
I hope soon someone can figure out where the fault is or what needs to be set/enabled to allow it to work out of the box for all.

New member

Posts

Joined
Mon Nov 28, 2011 1:38 am

Post by esponi » Wed Oct 08, 2014 9:45 pm

No one of our extensions are working in 2.0 and we have downloaded several from the store that are supposed to be updated and 50% are giving fails during installation.
Tested in our production server with EasyPHP and in our hosting with native linux.

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by budgetneon » Wed Oct 15, 2014 4:20 am

Just a "me too" post, but I have tried various incantations to get our page cache extension to work with the ocmod installer...no luck.

This is with the simplest type of install file possible...just a zip file with upload/ and some files underneath.

Depending on which version/iteration of opencart 2.x I pull, I get either

- The installer insisting on using ftp, which shouldn't come into play.
- The installer says "Success: You have installed your extension!", but, alas, the extension is not installed.

If I install by hand, the extension works fine.

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by budgetneon » Wed Oct 15, 2014 5:38 am

budgetneon wrote: - The installer says "Success: You have installed your extension!", but, alas, the extension is not installed.
I was curious about what it was doing, so I had a look at admin/controller/extension/installer.php. Yes, I'm answering my own post :)

If you're trying to go the route of an uploaded zip file, as I am, you may not have much luck. It's currently coded such that it will only accept uploaded files that are going to overwrite an existing file:

Code: Select all

while ($entry = zip_read($zip)) {
    $zip_name = zip_entry_name($entry);
    //....
    $file = DIR_APPLICATION . substr($zip_name, 13);
    if (is_file($file) && substr($zip_name, 0, 13) == 'upload/admin/') {
        $json['overwrite'][] = substr($zip_name, 7);
    }
    // ... more if blocks like the one above, but for other paths, like upload/system
}
So, if the file (within your zip file) doesn't already exist (in the opencart installation), the extension installer just skips over it. Which means this isn't really a bug...looks more like the work on the extension installer just wasn't ever finished.

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by rph » Wed Oct 15, 2014 6:20 am

That's just the notice for files being overwritten. The code for unzipping and FTPing are several lines above it (starts at ~123).

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by budgetneon » Wed Oct 15, 2014 6:50 am

rph wrote:That's just the notice for files being overwritten. The code for unzipping and FTPing are several lines above it (starts at ~123).
This code, right?

Code: Select all

$json['step'][] = array(
                  'text' => $this->language->get('text_unzip'),
                  'url'  => str_replace('&', '&', $this->url->link('extension/installer/unzip', 'token=' . $this->session->data['token'], 'SSL')),
                  'path' => $path
);
That look like it only extracts to DIR_DOWNLOAD, later, here:

Code: Select all

 $zip->extractTo(DIR_DOWNLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']));
Am I supposed to be structuring the files in the zip file a different way?

I have them zipped up with relative paths, like below. Nothing ever gets installed.

Code: Select all

dev@octurbo:~/dev/v2pagecache$ unzip -l v2pagecache-1.0.ocmod.zip 
Archive:  v2pagecache-1.0.ocmod.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      200  2014-10-14 21:04   install.xml
     9486  2014-10-14 19:45   upload/system/library/v2pagecache.php
    12583  2014-10-14 19:51   upload/admin/view/template/module/v2pagecache.tpl
     3028  2014-10-14 19:47   upload/admin/language/english/module/v2pagecache.php
       79  2014-10-14 19:47   upload/admin/language/english/extension/v2pagecache.php
    15365  2014-10-14 19:50   upload/admin/controller/module/v2pagecache.php

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by rph » Wed Oct 15, 2014 2:18 pm

Add a breakpoint in the ftp() method and step through it with your debugger.

The installer controller process is:

1) Upload file to the server and ensure it has extension *.ocmod.zip or *.ocmod.xml.
2) Move the file to a temp directory in DIR_DOWNLOAD renamed as upload.zip or install.xml.
3) Begin creating installation steps that are sent back to the browser as JSON.
4) If mod is a zip file, unzip() and ftp() steps are added. The installer checks for install.sql, install.xml, or install.php files and adds them to the installation steps. If any files in the zip already exist on the server an overwrite confirmation step is added.
5) The JSON response is sent back to the user.
6) The installer page will either prompt the user for confirmation if overwrite prompts exist or execute the install steps.

The steps that get executed for an *.ocmod.zip file are:

7) Extract the files in the temp DOWNLOAD_DIR directory and delete the upload.zip file. (unzip() method)
8) Move the contents of the /upload directory wherever they need to be. File type doesn't matter. Any directories that don't exist will be created. (ftp() method)
9) Execute any of the install files (install.sql, install.xml, install.php). (sql(), xml(), and php() methods)

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by budgetneon » Wed Oct 15, 2014 7:45 pm

rph wrote:Add a breakpoint in the ftp() method and step through it with your debugger.....
Appreciate the help, I'll run through that.

A high level question though. Why would a file that's by definition, already on the server, need to pass through an ftp() method? It's a little silly to ftp files from the local host back to itself.

This seems like perhaps it's designed for shared hosting, where ftp is (reluctantly) enabled. Most people running on a vps or dedicated host wouldn't have ftp enabled. Even if they did, they would have this insecure daemon configured so that it wasn't able to install files into the web server area.

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by Qphoria » Wed Oct 15, 2014 9:19 pm

justcurious wrote:
Johnathan wrote:I've tested the extension uploader a few times myself, and never have been able to get it to work. I don't consider that part of 2.0 to be stable at this point. (Honestly, I'd recommend just waiting to update for new features -- like the extension installer -- until a lot of the initial bugs are worked out. It'll save you some time on extension development.)
It's a shame. I am aware of the general feeling towards OCMOD as opposed to VQMOD, but I thought I'd give OCMOD a shot anyway. The problem is that once an extension is developed with VQMOD, I think that most developers will be unlikely to bother to make it backwards compatible with OCMOD at a later date when there is a fully functional alternative readily available.
Not to worry, vQmod 2.5.0+ is fully compatible with 2.0 so you always have the fallback to vQmod

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by budgetneon » Wed Oct 15, 2014 9:58 pm

budgetneon wrote: This seems like perhaps it's designed for shared hosting, where ftp is (reluctantly) enabled. Most people running on a vps or dedicated host wouldn't have ftp enabled. Even if they did, they would have this insecure daemon configured so that it wasn't able to install files into the web server area.
Just found this...localcopy (instead of ftp) for oc 2.x installer

I suppose for now, I'll just point everyone to that. Would be nice to have something like that added to the core. Pain-free installation of extensions is one of the things that would increase OC adoption.

New member

Posts

Joined
Sat Sep 20, 2014 11:32 pm


Post by justcurious » Wed Oct 15, 2014 11:39 pm

Qphoria wrote:Not to worry, vQmod 2.5.0+ is fully compatible with 2.0 so you always have the fallback to vQmod
I'm already going down that route. "Tweaking" the vqmod is much easier than ocmod. With ocmod you need to:
  • Edit the Mod File
  • Go to Extensions > Modifications
  • Select The modification
  • Click Delete
  • Go to Extensions > Extension Installer
  • Click the Upload Button
  • Find the file you want to upload and select it
  • Go to Extensions > Modifications
  • Click the Refresh Button
  • Go back to the relevent extension to see the results
With vqmod:
  • Edit the Mod File from the server using Filezilla
  • Save the changes
  • Go back to Filezilla to confirm upload changes to the server
  • Go back to the browser and refresh the page
Also, with ocmod, if you make a change that causes a fatal error, you have to disable the changes manually (by deleting the files in the system/modification folder) then reloading the page before you can go through the change process outlined above. With vqmod, there are no additional steps in the process.

I'm likely to stick with vqmod.

Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions


User avatar
Active Member

Posts

Joined
Sat Dec 24, 2011 4:36 pm
Location - UK

Post by rph » Wed Oct 15, 2014 11:54 pm

budgetneon wrote:A high level question though. Why would a file that's by definition, already on the server, need to pass through an ftp() method? It's a little silly to ftp files from the local host back to itself.
I asked the same question in another thread since it creates a couple big setup and security issues. Apparently it's for handling directory/file permissions. I would have preferred a dedicated mod/vendor directory with tweaked routing but we have what we have.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by tifosi » Fri Oct 17, 2014 8:07 am

Looks like it's been - or at least being - addressed... https://github.com/opencart/opencart/issues/1961

The patch seems to work for situations where ftp is being used.

I'll have to test the localcopy mod on wamp to see if that bypasses the ftp problem. Still, needs to be integrated into core to cope for situations where ftp_* functions aren't usable.

Hopefully 2.0.0.1 will be out soon!

New member

Posts

Joined
Tue Feb 17, 2009 8:14 am
Who is online

Users browsing this forum: No registered users and 10 guests