Skip to content

TemplateProcessor deleteBlock is not working #2581

Open
@diantonio85

Description

@diantonio85

Describe the Bug

$templateProcessor->deleteBlock is not working with attached DOCX and PHP 8.1 or above

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\TemplateProcessor;
[test.docx](https://github.com/PHPOffice/PHPWord/files/14487611/test.docx)

$templateProcessor = new TemplateProcessor($inputFileName);
$templateProcessor->deleteBlock('NASCONDI_SITI', '');

Expected Behavior

I expected sections between NASCONDI_SITI to get deleted , but this is not happening

Current Behavior

Currently only the section on page 2 is getting delete, while on page 1 they are still there

Context

Please fill in your environment information:

  • PHP Version: 8.1
  • PHPWord Version: composer require phpoffice/phpword

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions