• Resolved KTS915

    (@kts915)


    Just come across this. It looks beautifully simple, and I’d really like to use it. I have found a few problems, though. To avoid confusion, I’ll report each one a separate thread.

    The first is that, on PHP 7.1 (though I think it will be the case for PHP 7.0.14 and above), when going to the Add New Invoice or Add New Estimate screen, I get this:

    
    Fatal error: Uncaught Error: [] operator not supported for strings in ~/wp-content/plugins/littlebot-invoices/views/html-admin-invoice-line-items.php:12 Stack trace: #0 ~/wp-content/plugins/littlebot-invoices/includes/class-lbi-post-line-items.php(62): require_once() #1 ~/wp-admin/includes/template.php(1048): LBI_Line_Items->render_line_items(Object(WP_Post), Array) #2 ~/wp-admin/edit-form-advanced.php(703): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post)) #3 ~/wp-admin/post-new.php(85): include('/var/www/html/n...') #4 {main} thrown in ~/wp-content/plugins/littlebot-invoices/views/html-admin-invoice-line-items.php on line 12
    

    This seems to be resolved by just making the following change to the file html-admin-invoice-line-items.php. Add $line_items = array(); to line 3. Then I think you can also delete the following code that currently appears just below:

    	
    if ( !is_array( $line_items ) ) {
    		$item = array();
    		$item['item_title'] = '';
    		$item['item_desc'] = '';
    		$item['item_qty'] = '';
    		$item['item_rate'] = '';
    		$item['item_percent'] = '';
    		$item['item_amount'] = '';
    		$line_items[] = $item;
    	}
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author justinwhall

    (@jwind)

    Thanks @kts915 – I’m going to look at this today if I get a chance.

    Plugin Author justinwhall

    (@jwind)

    I’m not getting this error on any PHP version. I’m going to look more but I can tell you that adding:

    $line_items = array(); will cause this problem: https://ww.wp.xz.cn/support/topic/line-items-disappear-from-back-end/#post-9211200

    Plugin Author justinwhall

    (@jwind)

    Nope, My mistake. 7.1.4 throws the error you are talking about. Thanks for point this out. Patch coming.

    Plugin Author justinwhall

    (@jwind)

    This will work, however. I’ll push this out soon along with a few other warning fixes.

    
    	$line_items = get_post_meta( $post->ID, '_line_items', true ); 
    
    	if ( ! is_array( $line_items ) ) {
    		$line_items = array();
    	}
    
    	if ( !is_array( $line_items ) ) {
    		$item = array();
    		$item['item_title'] = '';
    		$item['item_desc'] = '';
    		$item['item_qty'] = '';
    		$item['item_rate'] = '';
    		$item['item_percent'] = '';
    		$item['item_amount'] = '';
    		$line_items[] = $item;
    	}
    
    Thread Starter KTS915

    (@kts915)

    Thanks, this fix does the job!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Fatal Error on PHP 7.1’ is closed to new replies.