Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo content install issue #25

Closed
DevWael opened this issue Jul 26, 2016 · 32 comments
Closed

Demo content install issue #25

DevWael opened this issue Jul 26, 2016 · 32 comments

Comments

@DevWael
Copy link

DevWael commented Jul 26, 2016

hello guys,
i'm facing this error while i'm trying to install demo content
Invalid byte position (current: 0, received: 0)

this is the code i'm using in my functions.php

add_filter( 'fw:ext:backups-demo:demos', 'window_demo_content' );
function window_demo_content( $demos ) {
    $demos_array = array(
        'news-demo'  => array(
            'title'        => esc_html__( 'News Demo', 'window' ),
            'screenshot'   => 'http://bbioon.com/window/demo/content/news.png',
            'preview_link' => 'http://bbioon.com/window/news'
        ),
        'sport-demo' => array(
            'title'        => esc_html__( 'Sport Demo', 'window' ),
            'screenshot'   => 'http://bbioon.com/window/demo/content/sport.png',
            'preview_link' => 'http://bbioon.com/window/sport'
        ),
        'blog-demo'  => array(
            'title'        => esc_html__( 'Blog Demo', 'window' ),
            'screenshot'   => 'http://bbioon.com/window/demo/content/blog.png',
            'preview_link' => 'http://bbioon.com/window/blog'
        ),
    );

    $download_url = 'http://www.bbioon.com/window/demo_content/';

    foreach ($demos_array as $id => $data) {
        $demo = new FW_Ext_Backups_Demo($id, 'piecemeal', array(
            'url' => $download_url,
            'file_id' => $id,
        ));
        $demo->set_title($data['title']);
        $demo->set_screenshot($data['screenshot']);
        $demo->set_preview_link($data['preview_link']);

        $demos[ $demo->get_id() ] = $demo;

        unset($demo);
    }

    return $demos;
}

and this is the code i'm using in config.php

$cfg = array(
    'files' => array(
        'news-demo'  => dirname(__FILE__) . '/content/news.zip',
        'sport-demo' => dirname(__FILE__) . '/content/sport.zip',
        'blog-demo'  => dirname(__FILE__) . '/content/blog.zip',
    ),
);

i can provide you with any login data that you need

@ghost ghost self-assigned this Jul 27, 2016
@ghost
Copy link

ghost commented Jul 27, 2016

Your download link is 404 http://www.bbioon.com/window/demos/

It should be an empty page with 400 error code, like this

screenshot from 2016-07-27 11-19-04

@ghost ghost closed this as completed Jul 27, 2016
@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

i moved the url to http://www.bbioon.com/window/demo_content/

it gives me an empty page

what should i do?

@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

@moldcraft i need help here

@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

this is the error

@ghost
Copy link

ghost commented Jul 27, 2016

It works http://www.bbioon.com/window/demo_content/?id=news-demo&position=0

Maybe you have antivirus that is blocking requests to your site (if it is on localhost).

If the site is live, can you send me admin/ftp access to moldcraft[at]email.com?

@ghost
Copy link

ghost commented Jul 27, 2016

Or you can debug this script on your sever to check where the execution is not going well.

@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

i solved the error Invalid byte position (current: 0, received: 0)
i tried to upgrade php version from 5.4 to 5.6 and it worked

but i'm getting a new error Zip open failed (code 19). Please try again

i tried with two different zip files

what is the wrong with this?

@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

this is my activated php extensions

@ghost
Copy link

ghost commented Jul 27, 2016

I don't know, I need to inspect your code to find the problem.

@DevWael
Copy link
Author

DevWael commented Jul 27, 2016

i sent you an email with the access details.

thank you.

@ghost ghost reopened this Jul 27, 2016
@ghost ghost added the in progress label Jul 27, 2016
@ghost
Copy link

ghost commented Jul 27, 2016

Thanks, I will take a look in a few hours.

@ghost
Copy link

ghost commented Jul 27, 2016

Hello,

It took me a lot of time to investigate that issue, so I will inspect this issue tomorrow.

@DevWael
Copy link
Author

DevWael commented Jul 30, 2016

it still give me the error Zip open failed (code 19). Please try again
i tried the theme and files on another server and it gives me the same error.

i also tried another zip files, other host. i can't find the solution.

did you find any solution ? @moldcraft

@ghost
Copy link

ghost commented Jul 31, 2016

Hello,

I was busy with other tasks and forgot about this, sorry.

Error code 19 means Not a zip archive

I inspected your server:

  1. I downloaded wp-content/uploads/fw-backup/tmp/piecemeal.zip

  2. I tried to open it with php

    add_action('admin_notices', function(){
        $zip = new ZipArchive();
        fw_print(
            $zip->open(
                fw_fix_path(ABSPATH) 
                .'/wp-content/uploads/fw-backup/tmp/piecemeal.zip'
            )
        );
    });

    and I get the 19 error code on both your server and my localhost.

  3. It opens on my PC with Archivator App, but I get error when I do extract.

  • Maybe the problem is in these files which contains corrupted characters in their name.
  • One time a similar problem, the problem was in Windows Archivator App, for some reason the archives created with it couldn't be opened in PHP. The solution was to create the archives for demo install with WinRar.

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

do you mean i have to download this archive and decompress it then compress it again with my zip archiver to .zip file ?
or to .rar file?

as you wrote above i tried to extract the news.zip on my server and compressed it again and it gives me the same error Code 19.

can you describe the solution you provided for more help?
i'm about uploading the theme to themeforest and i only have to fix this issue to create the demo content for the buyers.

Thank you for your help.

@ghost
Copy link

ghost commented Jul 31, 2016

You need .zip.

  1. Can you upload to dropbox (or some similar service) your Content Backup zip and send me the download link to moldcraft[at]email.com?
  2. Have you tried to remove those files with corrupted name from the archive?

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

this is what i did:

  1. I downloaded the content zip file.
  2. extracted it and compressed it again and uploaded it to the server.
  3. The same error again.

i extracted the files on the server and removed 2 files:

88103  07-26-2016 03:08   f/uploads/2016/07/Window-???-news-logo-1.png
 3709  07-26-2016 03:08   f/uploads/2016/07/Window-???-news-logo.png

as you meant files with corrupted name above
and compressed the file again and still give me the error.

i have sent you the download link for the original file (without any edit).

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

Small notice: when i use the same file in the restore backup page it works correctly, which it means there is no issue with the file but the issue may be with the demo install system.

@ghost
Copy link

ghost commented Jul 31, 2016

Inspecting... Please don't do anything on the server. I will let you know when I am done

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

okay...

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

this is the main demo http://bbioon.com/window/news i can provide you with the access information when you need it.

@ghost
Copy link

ghost commented Jul 31, 2016

I compared the original news.zip and the downloaded piecemeal.zip and they differ by 3 bytes at the beginning of the file. I am trying to figure out where they come from

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

if you need to create a new demo content zip i can provide you with the admin access on the main demo site.

@ghost
Copy link

ghost commented Jul 31, 2016

  1. I added here

    file_get_contents('http://requestb.in/...?'. http_build_query(array(
        's' => strlen($data)
    )));

    and it shows s=3000000

  2. I added here

        file_get_contents('http://requestb.in/...?'. http_build_query(array(
            's'  => strlen($response['body'])
        )));

    and it shows s=3000003.

    Also to check if the problem maybe is in wp_remote_get(), I added here

        file_get_contents('http://requestb.in/...?'. http_build_query(array(
            's' => strlen(file_get_contents(add_query_arg(
                array(
                    'id' => urlencode($args['file_id']),
                    'position' => $state['position'],
                    'size' => $state['piece_size'],
                ),
                $args['url']
            )))
        )));
    
        return new WP_Error('t', 'Test');

    and it also shows s=3000003.

So something is adding 3 bytes to server response content.


I added here

file_get_contents('http://requestb.in/...?'. http_build_query(array(
    'c' => substr(file_get_contents(add_query_arg(
        array(
            'id' => urlencode($args['file_id']),
            'position' => $state['position'],
            'size' => $state['piece_size'],
        ),
        $args['url']
    )), 0, 3)
)));

and it shows cc=%EF%BB%BF.

Google shows that others encountered this problem, and it turns out that this character sequence is related to UTF-8 BOM.


I will add a fix that removes those extra bytes.

@ghost ghost closed this as completed in 401c079 Jul 31, 2016
@ghost ghost removed the in progress label Jul 31, 2016
@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

which explains that the same file works correctly in the restore backup page and didn't work with the same file when needs to request it from the server

@ghost
Copy link

ghost commented Jul 31, 2016

The release will be tomorrow ThemeFuse/Unyson-Extensions-Approval#241

So better submit your theme tomorrow in the evening when the update will be live and the TF staff will be able to test your theme without encountering this problem.

@DevWael
Copy link
Author

DevWael commented Jul 31, 2016

i can wait you, take your time.

thank you for the help.
Best regards...

@UxLabByNinja
Copy link

@eyeswizard Hi, If

this Invalid byte position (current: 0, received: 0)

is your error so just check the your config.php file for proper linking your zip file. 'news-demo' => dirname(FILE) . '/content/news.zip', this is your content link so try to change "/content" to "content" no need to add "/" if your download script in "demo_content" folder. By the way, I got the same problem in my theme solved the problem by changing the path.

@andreiglingeanu
Copy link
Collaborator

@moldcraft Nice one!

@nobingit
Copy link

The release will be tomorrow ThemeFuse/Unyson-Extensions-Approval#241

So better submit your theme tomorrow in the evening when the update will be live and the TF staff will be able to test your theme without encountering this problem.

hello i am new in unyson i want to implement demo import can you help me to do this?

@DevWael
Copy link
Author

DevWael commented May 18, 2022

Hi @nobingit
Unyson framework is a great framework, but it's now discontinued project, I would suggest you to get another framework like carbonfields.net.

Hope it will be back to live again one day.

Regards.

@nobingit
Copy link

nobingit commented May 18, 2022 via email

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants