• I was testing this plugin but the audio was not generated. Instead I got an exception in the logfile:

    
    [06-Mar-2019 13:58:06 UTC] PHP Fatal error:  Uncaught Error: Call to a member function exists() on boolean in htdocs/wp-content/plugins/amazon-polly/admin/AmazonAI-PollyService.php:299
    

    Turns out that this is called by generate_audio which calls $common->prepare_wp_filesystem. This is supposed to return an object I assume.

    In here I find this line (line 1021 in admin/AmazonAI-Common.php):

    
            if ( ! WP_Filesystem( $creds ) ) {
                request_filesystem_credentials( $url );
                return true;
            }
    

    Is this correct? Because the true is not what is needed. The other options actually return $wp_filesystem

    So how do I solve this problem?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mrtopf

    (@mrtopf)

    I should maybe add that I have my WordPress secured in that the WWW user can only write in uploads which might be the issue here. The question then might be if another method of writing a temp file can be used (e.g. one using real temporary files).

    Plugin Contributor tstachlewski

    (@tstachlewski)

    :/ I have to admit that we didn’t predict this kind of case. And although the final mp3 can be saved on S3 instead of WordPress server, the intermediate files needs to be saved on WordPress site itself ??

    Will leave this case open, perhaps we will find a way in future to solve it.

    i have a site hosted on pantheon, and they similarly lock down file writing to wp-content, so polly fails.

    does the plugin download/create the temp files in a specific local folder? i am able to create symlinks to the proper wp-content folder.

    Thread Starter mrtopf

    (@mrtopf)

    Thanks for the reply.

    For now I solved it by telling the FS component, that we are always in “direct” mode by adding this to my functions.php:

    
    function my_filesystem_method($method, $args, $context, $allow_relaxed_file_ownership) {
        return "direct";
    }
    
    add_filter( 'filesystem_method', 'my_filesystem_method', 10, 4);
    

    This means though that the FTP prompt will never show up anymore like for plugin updates (I guess it will just fail). For me that’s no problem though as I update my plugins via wp-cli.

    I still wonder though how other plugins do it, like cache plugins etc. Those seem to work.

    (hypergeneric: It does actually create the file in uploads/ but the FS system does test the writability in general, like on the WP core files.)

    @mrtopf — thanks man. i will have to test this out. this is a great little undocumented wordpress gem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Audio ist not generated because $wp_filesystem is a boolean’ is closed to new replies.