Skip to content

Update the signature of dba_open() and dba_popen() #1267

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

Merged
merged 7 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 58 additions & 22 deletions reference/dba/functions/dba-open.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
<type class="union"><type>resource</type><type>false</type></type><methodname>dba_open</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam><type>string</type><parameter>mode</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>handler</parameter></methodparam>
<methodparam rep="repeat"><type>string</type><parameter>args</parameter></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>handler</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>permission</parameter><initializer>0644</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>map_size</parameter><initializer>0</initializer></methodparam>
Comment on lines +14 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should have a note that named arguments do not work, as this signature is only the case since PHP 8.2 IIRC when I landed the changes

<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>flags</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
<function>dba_open</function> establishes a database instance for
<parameter>path</parameter> with <parameter>mode</parameter> using
<parameter>handler</parameter>.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
Expand Down Expand Up @@ -154,49 +157,71 @@
<listitem>
<para>
The name of the <link linkend="dba.requirements">handler</link> which
shall be used for accessing <parameter>path</parameter>. It is passed
all optional parameters given to <function>dba_open</function> and
can act on behalf of them.
shall be used for accessing <parameter>path</parameter>. It is passed
all optional parameters given to <function>dba_open</function> and
can act on behalf of them. If <parameter>handler</parameter> is &null;,
then the default handler is invoked.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>args</parameter></term>
<term><parameter>permission</parameter></term>
<listitem>
<para>
Optional &string; parameters which are passed to the driver.
</para>
<para>
The <literal>cdb</literal>, <literal>cdb_make</literal>, <literal>flatfile</literal>,
<literal>inifile</literal>, <literal>qdbm</literal> and <literal>tcadb</literal> drivers
do not support additional parameters.
Optional &integer; parameter which is passed to the driver. It has the same meaning as
the <parameter>permissions</parameter> parameter of <function>chmod</function>,
and defaults to <literal>0644</literal>.
</para>
<para>
The <literal>db1</literal>, <literal>db2</literal>, <literal>db3</literal>,
<literal>db4</literal>, <literal>dbm</literal>, <literal>gdbm</literal>,
and <literal>ndbm</literal> drivers supports a single additional parameter <literal>$filemode</literal>,
which has the same meaning as the <literal>$mode</literal> parameter of <function>chmod</function>,
and defaults to <literal>0644</literal>.
<literal>ndbm</literal>, and <literal>lmdb</literal> drivers support the
<parameter>permission</parameter> parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>map_size</parameter></term>
<listitem>
<para>
Optional &integer; parameter which is passed to the driver. Its value should be a multiple of the
page size of the OS, or zero, to use the default map size.
</para>
<para>
The <literal>lmdb</literal> driver accepts two additional parameters. The first
allows to specify the <literal>$filemode</literal> (see description above), and the
second to specify the <literal>$mapsize</literal>, where the value should be a multiple
of the page size of the OS, or zero, to use the default mapsize. The <literal>$mapsize</literal>
parameter is supported as of PHP 7.3.14 and 7.4.2, respectively.
Only the <literal>lmdb</literal> driver accepts the <parameter>map_size</parameter> parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
Flags to pass to the database drivers. If &null; the default flags will be provided.
Currently, only the LMDB driver supports the following flags
<constant>DBA_LMDB_USE_SUB_DIR</constant> and
<constant>DBA_LMDB_NO_SUB_DIR</constant>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a positive handle on success&return.falseforfailure;.
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<para>
&false; is returned and an <constant>E_WARNING</constant> level error is issued when
<parameter>handler</parameter> is &null;, but there is no default handler.
</para>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
Expand All @@ -208,10 +233,22 @@
</row>
</thead>
<tbody>
<row>
<entry>8.2.0</entry>
<entry>
<parameter>flags</parameter> is added.
</entry>
</row>
<row>
<entry>8.1.0</entry>
<entry>
<parameter>handler</parameter> is now nullable.
</entry>
</row>
<row>
<entry>7.3.14, 7.4.2</entry>
<entry>
The <literal>lmdb</literal> driver now supports an additional <literal>$mapsize</literal>
The <literal>lmdb</literal> driver now supports an additional <parameter>map_size</parameter>
parameter.
</entry>
</row>
Expand All @@ -230,7 +267,6 @@
</para>
</refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
96 changes: 77 additions & 19 deletions reference/dba/functions/dba-popen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
<type class="union"><type>resource</type><type>false</type></type><methodname>dba_popen</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam><type>string</type><parameter>mode</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>handler</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>args</parameter></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>handler</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>permission</parameter><initializer>0644</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>map_size</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>flags</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
<function>dba_popen</function> establishes a persistent database instance
for <parameter>path</parameter> with <parameter>mode</parameter> using
<parameter>handler</parameter>.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
Expand Down Expand Up @@ -50,46 +53,102 @@
The name of the <link linkend="dba.requirements">handler</link> which
shall be used for accessing <parameter>path</parameter>. It is passed
all optional parameters given to <function>dba_popen</function> and
can act on behalf of them.
can act on behalf of them. If <parameter>handler</parameter> is &null;,
then the default handler is invoked.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>args</parameter></term>
<term><parameter>permission</parameter></term>
<listitem>
<para>
Optional &string; parameters which are passed to the driver.
</para>
<para>
The <literal>cdb</literal>, <literal>cdb_make</literal>, <literal>flatfile</literal>,
<literal>inifile</literal>, <literal>qdbm</literal> and <literal>tcadb</literal> drivers
do not support additional parameters.
Optional &integer; parameter which is passed to the driver. It has the same meaning as
the <parameter>permissions</parameter> parameter of <function>chmod</function>,
and defaults to <literal>0644</literal>.
</para>
<para>
The <literal>db1</literal>, <literal>db2</literal>, <literal>db3</literal>,
<literal>db4</literal>, <literal>dbm</literal>, <literal>gdbm</literal>,
and <literal>ndbm</literal> drivers supports a single additional parameter <literal>$filemode</literal>,
which has the same meaning as the <literal>$mode</literal> parameter of <function>chmod</function>,
and defaults to <literal>0644</literal>.
<literal>ndbm</literal>, and <literal>lmdb</literal> drivers support the
<parameter>permission</parameter> parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>map_size</parameter></term>
<listitem>
<para>
Optional &integer; parameter which is passed to the driver. Its value should be a multiple of the
page size of the OS, or zero, to use the default mapsize.
</para>
<para>
The <literal>lmdb</literal> driver accepts the <parameter>map_size</parameter> parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
The <literal>lmdb</literal> driver accepts two additional parameters. The first
allows to specify the <literal>$filemode</literal> (see description above), and the
second to specify the <literal>$mapsize</literal>, where the value should be a multiple
of the page size of the OS, or zero, to use the default mapsize. The <literal>$mapsize</literal>
parameter is supported as of PHP 7.3.14 and 7.4.2, respectively.
Allows to pass flags to the DB drivers. Currently, only LMDB with
<constant>DBA_LMDB_USE_SUB_DIR</constant> and <constant>DBA_LMDB_NO_SUB_DIR</constant> are supported.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a positive handle on success&return.falseforfailure;.
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<para>
&false; is returned and an <constant>E_WARNING</constant> level error is issued when
<parameter>handler</parameter> is &null;, but there is no default handler.
</para>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.2.0</entry>
<entry>
<parameter>flags</parameter> is added.
</entry>
</row>
<row>
<entry>8.1.0</entry>
<entry>
<parameter>handler</parameter> is now nullable.
</entry>
</row>
<row>
<entry>7.3.14, 7.4.2</entry>
<entry>
The <literal>lmdb</literal> driver now supports an additional <parameter>map_size</parameter>
parameter.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
Expand All @@ -100,7 +159,6 @@
</para>
</refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down