cphalcon: [BUG]: TagFactory __invoke and Html\Helper\Meta,Link,Script,Style. Store reset at each call

Describe the bug When calling multiple times the Meta helper, previous stored values disappear.

To Reproduce

//IndexController.php
$this->tag->meta()->addName('robots', 'index, nofollow');

//index.phtml
<?= $this->tag->meta()->addName('author', 'Me'); ?>

Only output

<meta name="robots" content="index,nofollow">

Another quick example

var_dump($this->tag->meta()->addName('test1', 'test1')->addName('test2', 'test2')->__toString());
var_dump($this->tag->meta()->addName('test3', 'test3')->__toString());

image

Expected behavior A clear and concise description of what you expected to happen.

//IndexController.php
$this->tag->meta()->addName('robots', 'index, nofollow');

//index.phtml
<?= $this->tag->meta()->addName('author', 'Me'); ?>

Must output

<meta name="robots" content="index,nofollow">
<meta name="author" content="me">

Details

  • Phalcon version: 5.3.0
  • PHP Version: 8.1.23
  • Operating System: DEbian
  • Installation type: pecl
  • Server: Apache

Additional context

Each time you call $this->tag->meta() AbstractSeries::__invoke reset the store image

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 23 (7 by maintainers)

Most upvoted comments

Resolved in https://github.com/phalcon/cphalcon/pull/16455

Added a reset() method and removed the clearing of the internal store on __invoke().

At the moment manipulation of entries (remove for instance) is not feasible since they do not have a unique name. That could be a NFR for the future.

Initially I was thinking of introducing a ->reset() method which would clear the store. It looks that we need that.

Thank you for testing

@yannux I’m glad you found your solution with the current Phalcon.